Example #1
0
        public override StartCommandResult OnStartCommand(Intent intent, StartCommandFlags flags, int startId)
        {
            Console.WriteLine("WidgetService - OnStartCommand - startId: {0} intent.action: {1}", startId, intent.Action);
            _widgetIds = intent.GetIntArrayExtra(AppWidgetManager.ExtraAppwidgetIds);

            if (intent.Action == SessionsWidgetActions.SessionsWidgetPrevious.ToString())
            {
                _messengerHub.PublishAsync<PlayerCommandMessage>(new PlayerCommandMessage(this, PlayerCommandMessageType.Previous));
            }
            else if (intent.Action == SessionsWidgetActions.SessionsWidgetPlayPause.ToString())
            {
                _messengerHub.PublishAsync<PlayerCommandMessage>(new PlayerCommandMessage(this, PlayerCommandMessageType.PlayPause));
            }
            else if (intent.Action == SessionsWidgetActions.SessionsWidgetNext.ToString())
            {
                _messengerHub.PublishAsync<PlayerCommandMessage>(new PlayerCommandMessage(this, PlayerCommandMessageType.Next));
            }
            else if (intent.Action == "android.appwidget.action.APPWIDGET_UPDATE")
            {
                Console.WriteLine("WidgetService - Updating notification because of APPWIDGET_UPDATE...");
                UpdateWidgetView();
            }

            return StartCommandResult.NotSticky;
        }
Example #2
0
 void HandleMessageReceived(object sender, Android.Content.Intent e)
 {
     if (e.Action == ACTION_CANCELLED)
     {
         if (PasscodeCancelled != null)
         {
             PasscodeCancelled.Invoke(this, EventArgs.Empty);
         }
     }
     else if (e.Action == ACTION_COMPLETED)
     {
         if (PasscodeEntered != null)
         {
             PasscodeEntered.Invoke(this, new PasscodeEnteredEventArgs(e.GetIntArrayExtra(EXTRA_CODE)));
         }
     }
 }
Example #3
0
        public override StartCommandResult OnStartCommand(Intent intent, StartCommandFlags flags, int startId)
        {
            Console.WriteLine("NotificationService - OnStartCommand - startId: {0} intent.action: {1}", startId, intent.Action);
            _widgetIds = intent.GetIntArrayExtra(AppWidgetManager.ExtraAppwidgetIds);

            if (intent.Action == SessionsWidgetActions.SessionsWidgetPrevious.ToString())
            {
                _messengerHub.PublishAsync<PlayerCommandMessage>(new PlayerCommandMessage(this, PlayerCommandMessageType.Previous));
            }
            else if (intent.Action == SessionsWidgetActions.SessionsWidgetPlayPause.ToString())
            {
                _messengerHub.PublishAsync<PlayerCommandMessage>(new PlayerCommandMessage(this, PlayerCommandMessageType.PlayPause));
            }
            else if (intent.Action == SessionsWidgetActions.SessionsWidgetNext.ToString())
            {
                _messengerHub.PublishAsync<PlayerCommandMessage>(new PlayerCommandMessage(this, PlayerCommandMessageType.Next));
            }
            else if (intent.Action == SessionsWidgetActions.SessionsWidgetClose.ToString())
            {
                _isShutDowning = true;
                Console.WriteLine("NotificationService - Closing the application...");

                // Broadcast any component that the application is closing; do not add the lock screen activity until the application is 'restarted'
                Console.WriteLine("NotificationService - Notifying ApplicationCloseMessage...");
                _messengerHub.PublishAsync<ApplicationCloseMessage>(new ApplicationCloseMessage(this));
                _messengerHub.PublishAsync<ActivateLockScreenMessage>(new ActivateLockScreenMessage(this, false));

                // Stop playback and remove notification service from foreground
                _playerService.Stop();
                StopForeground(true); // maybe that is enough and the service doesn't have to be stopped?
                var notificationManager = (NotificationManager)ApplicationContext.GetSystemService(NotificationService);
                notificationManager.Cancel(1);   
                StopSelf();
            }

            return StartCommandResult.NotSticky;
        }