Exemplo n.º 1
0
        public override void OnReceive(Context context, Intent intent)
        {
            switch (intent.Action)
            {
            case AppWidgetManager.ActionAppwidgetUpdate:
                var updateValue = intent.GetStringExtra(KEY_CLICKUPDATE);
                isClick = updateValue?.Equals(VALUE_CLICKUPDATE) ?? false;
                break;

            case Intent.ActionMain:
                var runValue = intent.GetStringExtra(KEY_RUNAPP);

                if (runValue?.Equals(VALUE_RUNAPP) ?? false)
                {
                    var runIntent = new Intent(context, typeof(MainActivity));
                    runIntent.SetFlags(ActivityFlags.NewTask);
                    runIntent.PutExtra(KEY_WAITEM_CLICK, VALUE_WAITEM_CLICK);
                    runIntent.PutStringArrayListExtra(KEY_WAITEM_LIST, intent.GetStringArrayListExtra(KEY_WAITEM_LIST));
                    context.StartActivity(runIntent);
                }
                break;

            case ACTION_PREVIOUS:
                var rv = new RemoteViews(context.PackageName, Resource.Layout.WAWidget);
                rv.ShowPrevious(Resource.Id.WAWidgetIconFlipper);
                AppWidgetManager.GetInstance(context).UpdateAppWidget(intent.GetIntExtra(AppWidgetManager.ExtraAppwidgetId, 0), rv);
                break;

            case ACTION_NEXT:
                var rv2 = new RemoteViews(context.PackageName, Resource.Layout.WAWidget);
                rv2.ShowNext(Resource.Id.WAWidgetIconFlipper);
                AppWidgetManager.GetInstance(context).UpdateAppWidget(intent.GetIntExtra(AppWidgetManager.ExtraAppwidgetId, 0), rv2);
                break;
            }

            base.OnReceive(context, intent);
        }