Natural selection is testing this #Altcoins season 🌊. In this cycle, many are once again diving deep into research, searching for “the best” after Bitcoin & @Joseinnewworld makes waves 124 #NFTs — Wow, a strong signal for those still weighing their moves. #eCash $XEC #CryptoNews pic.twitter.com/GB3dRvH01U
— NFToa (@nftoa_) September 26, 2025
Since API level 16 (Jelly Bean), it is possible to add actions to notifications with
builder.addAction(iconId, title, intense);
But when I add an action to the notification and that action is pressed, the notification will not close. When the notification itself is clicked, it can be closed with
notification.flags = Notification.FLAG_AUTO_CANCEL; or builder.setAutoCancel(true);
But clearly, this has nothing to do with the action associated with the notification. Any clues? Or is this not part of the API yet? I didn't find anything.
Solution
When you call notify on the notification manager, you give it an id - a unique id that you can use to access it later from the notification manager:
notify( int id, Notification notification)
To cancel, you would call:
cancel( int id)
with the same id So, basically, you need to track that id or maybe put that id in the Bundle that you add to the Intent inside the PendingIntent?
