Exemplo n.º 1
0
        NotificationCompat.Action BuildServiceAction(string action, string text, int icon, int requestCode)
        {
            var pendingIntent = BuildServicePendingIntent(action, requestCode);
            var builder       = new NotificationCompat.Action.Builder(icon, text, pendingIntent);

            return(builder.Build());
        }
        NotificationCompat.Action BuildAction(string ACTION, int drawableIcon, string caption)
        {
            var actionIntent = new Intent(this, GetType());

            actionIntent.SetAction(ACTION);
            var pendingIntent = PendingIntent.GetService(this, 0, actionIntent, 0);

            var builder = new NotificationCompat.Action.Builder(drawableIcon, caption, pendingIntent);

            return(builder.Build());
        }
Exemplo n.º 3
0
        NotificationCompat.Action BuildStopServiceAction()
        {
            var stopServiceIntent = new Intent(this, GetType());

            stopServiceIntent.SetAction(Constants.ACTION_STOP_SERVICE);
            var stopServicePendingIntent = PendingIntent.GetService(this, 0, stopServiceIntent, 0);

            var builder = new NotificationCompat.Action.Builder(Android.Resource.Drawable.IcMediaPause,
                                                                GetText(Resource.String.action_disconnect),
                                                                stopServicePendingIntent);

            return(builder.Build());
        }
Exemplo n.º 4
0
        /// <summary>
        /// Builds the Notification.Action that will allow the user to stop the service via the
        /// notification in the status bar
        /// </summary>
        /// <returns>The stop service action.</returns>
        private NotificationCompat.Action BuildStopServiceAction()
        {
            Intent stopServiceIntent = new Intent(this, GetType());

            stopServiceIntent.SetAction(ActionStopService);
            Android.App.PendingIntent stopServicePendingIntent = Android.App.PendingIntent.GetService(this, 0, stopServiceIntent, 0);

            var builder = new NotificationCompat.Action.Builder(Resource.Drawable.ic_stat_cancel,
                                                                GetText(Resource.String.service_stop_comm),
                                                                stopServicePendingIntent);

            return(builder.Build());
        }
        /// <summary>
        /// Builds a Notification.Action that will instruct the service to restart the timer.
        /// </summary>
        /// <returns>The restart timer action.</returns>
        NotificationCompat.Action BuildRestartTimerAction()
        {
            var restartTimerIntent = new Intent(this, GetType());

            restartTimerIntent.SetAction(Constants.ACTION_RESTART_TIMER);
            var restartTimerPendingIntent = PendingIntent.GetService(this, 0, restartTimerIntent, 0);

            var builder = new NotificationCompat.Action.Builder(Resource.Drawable.ic_action_restart_timer,
                                                                GetText(Resource.String.restart_timer),
                                                                restartTimerPendingIntent);

            return(builder.Build());
        }
Exemplo n.º 6
0
        public NotificationCompat.Action CreateAction(int icon, string title, string action, Action <NotificationCompat.Action.Builder> build = null)
        {
            var intent = new Intent(_context, typeof(RadioStationService)).SetAction(action);

            var flags = PendingIntentFlags.UpdateCurrent;

            if (action.Equals(RadioStationService.ActionStop))
            {
                flags = PendingIntentFlags.CancelCurrent;
            }

            var pendingIntent = PendingIntent.GetService(_context, 1, intent, flags);
            var builder       = new NotificationCompat.Action.Builder(icon, title, pendingIntent);

            build?.Invoke(builder);

            return(builder.Build());
        }
Exemplo n.º 7
0
        /// <summary>
        /// Builds the Notification.Action that will allow the user to stop the service via the
        /// notification in the status bar
        /// </summary>
        /// <returns>The stop service action.</returns>
        private NotificationCompat.Action BuildStopServiceAction()
        {
            Intent stopServiceIntent = new Intent(this, GetType());

            stopServiceIntent.SetAction(ActionStopService);
            Android.App.PendingIntentFlags intentFlags = 0;
            if (Build.VERSION.SdkInt >= BuildVersionCodes.S)
            {
                intentFlags |= Android.App.PendingIntentFlags.Mutable;
            }
            Android.App.PendingIntent stopServicePendingIntent = Android.App.PendingIntent.GetService(this, 0, stopServiceIntent, intentFlags);

            var builder = new NotificationCompat.Action.Builder(Resource.Drawable.ic_stat_cancel,
                                                                GetText(Resource.String.service_stop_comm),
                                                                stopServicePendingIntent);

            return(builder.Build());
        }