Actions with Android notifications without opening the application.

I want to implement a notification action in JB. But he should not open the application. The behavior is similar to the action of deleting Gmail app notifications. How can i do this?

Thanks in advance, Shashika

+13
android notifications android-4.2-jelly-bean
May 6 '13 at 4:35
source share
3 answers

After some research, I was able to achieve this with a broadcast receiver. I posted a sample code here. http://shashikawlp.wordpress.com/2013/05/08/android-jelly-bean-notifications-with-actions/

+22
May 08 '13 at 9:21
source share

You can also add custom buttons or layouts using onClickEvents to your notification (for example, events that do not open the application;)):

  • Create your own RemoteViews layout and add it to the builder.setContent(remoteView); constructor builder.setContent(remoteView);

    In this layout you can define buttons

  • Set the onClickPendingIntent control to your remoteView.setOnClickPendingIntent(R.id.button, pendingIntent); control remoteView.setOnClickPendingIntent(R.id.button, pendingIntent);
    PendingIntent may contain a BroadcastReceiver to trigger an action without going to the application

Happy coding

+2
Sep 07 '13 at 11:12
source share

From what I understand about your request, you need to run AlarmManager, which starts the background services at the specified time to create notifications, and then you need to indicate the intention of the notification to do what you want.

If you receive push notifications, start the AlarmManager and simply run the action you want to do, from the intent in the notification.

For a more specific answer, we need a more specific question.

0
May 6 '13 at 4:43
source share



All Articles