Search code examples
androidandroid-notificationsandroid-4.2-jelly-bean

Android - jelly bean notification dismiss button


The google play music app has a little 'X' in the top right corner, instead of displaying the time and a miniature notification icon in that location. Tapping the button kills the player and closes the notification. Great!

I'd like to do the same with my app - Is this only possible by inflating remote views and associating a custom button with an intent to destroy the service, or is there some notification builder methods that I'm overlooking which do that job?


Solution

  • There are no notification builder methods which achieve this. The only solution is to create a custom button with a pending intent to perform the action required.