Notification Action/Button

Hey, could anyone tell me how to correctly add action to notification ? I've made some sample but when i .action.add it doesnt work :/
I couldnt find any information. Any advice would be very useful :)

>

  Intent yesReceive = new Intent();
        yesReceive.SetAction(ActionPause);
        Bundle yesBundle = new Bundle();
        yesBundle.PutInt("Pause", 1);
        yesReceive.PutExtras(yesBundle);
        PendingIntent pendingIntentYes = PendingIntent.GetBroadcast(this, 12345, yesReceive, PendingIntentFlags.UpdateCurrent);

        Notification.Action action = new Notification.Action(Resource.Drawable.ic_media_pause, "Yes", pendingIntentYes);

        var Intent = new Intent(this, typeof(MainActivity));
        Intent.SetFlags(ActivityFlags.ClearTop);
        var pendingIntent = PendingIntent.GetActivity(ApplicationContext, 0,Intent, PendingIntentFlags.UpdateCurrent);

        var notification = new Notification
        {
            TickerText = new Java.Lang.String("Song started!"),
            Icon = Resource.Drawable.ic_media_play,
        };
        notification.Actions.Add(action); //////////////////////////////////////////////////

        notification.Flags |= NotificationFlags.OngoingEvent;
        notification.SetLatestEventInfo(ApplicationContext, "Xamarin Streaming",  "Playing music!", pendingIntent);
        StartForeground(NotificationId, notification);

Answers

Sign In or Register to comment.