Android notifications actions without opening the app
20,232
Solution 1
After some research I managed to achieve this using a broadcast receiver. I posted the example code here. http://shashikawlp.wordpress.com/2013/05/08/android-jelly-bean-notifications-with-actions/
Solution 2
You can also add custom buttons or layouts with onClickEvents to your notification compat (e.g. events which do not open the app ;)):
- Create a custom RemoteViews Layout and add it to the builder
builder.setContent(remoteView);
In this layout you can define Buttons
- Set an onClickPendingIntent to your control
remoteView.setOnClickPendingIntent(R.id.button, pendingIntent);
The PendingIntent can hold a BroadcastReceiver to trigger an action without jumping INTO the app
Happy coding
![Shashika](https://i.stack.imgur.com/CgM7K.jpg?s=256&g=1)
Comments
-
Shashika almost 4 years
I want to implement a notification action in JB. But it shouldn't open the app. The behaviour is similar to the Gmail apps delete notification action. How can I do this?
Thanks in advance, Shashika