android - NotificationManager.cancel(id) is not working inside a broadcast receiver -
android: trying cancel notification notification bar after package being installed. doing following:
 public class mybroadcastreceiver extends broadcastreceiver {                  private static final string tag = "mybroadcastreceiver";                  @override                 public void onreceive(context context, intent intent) {                     string action = intent.getaction();                     if (intent.action_package_added.equals(action)) {                         uri data = intent.getdata();                         //some code goes here                         //get id of notification cancel in way                         notificationhelper._completenotificationmanager.cancel(id);                              }                 }             }   where
public class notificationhelper {     public static notificationmanager _completenotificationmanager = null;      public void complete() {                 if (_completenotificationmanager == null)             _completenotificationmanager = (notificationmanager) _context.getsystemservice(context.notification_service);             notification notification = new notification(                 r.drawable.notification,                 _context.getstring(r.string.notification),                 system.currenttimemillis());         notification.flags |= notification.flag_auto_cancel;         notification.flags |= notification.flag_no_clear;         _completenotificationmanager.notify(text, id, notification);     } }   but notificationhelper._completenotificationmanager.cancel(id) not work. tried use notificationhelper._completenotificationmanager.cancelall(); , works. doing wrong?
in experience, can't cancel notifications particular id, regardless of tag.
that is, if create 2 notifications so:
notificationmanager.notify(tag_one, same_id, notification_one); notificationmanager.notify(tag_two, same_id, notification_two);   then, notificationmanager.cancel(same_id) won't cancel either of them!  suspect because "tag" field, if unspecified in notify() , cancel(), defaults null, have cancel explicitly.
so, cancel these 2 notifications, have call:
notificationmanager.cancel(tag_one, same_id); notificationmanager.cancel(tag_two, same_id);   in case, you're supplying "text" tag cancelling using id, defaults using tag=null.
so, either don't provide text tag:
_completenotificationmanager.notify(id, notification);   or, if need separate notifications , don't want them clobber each other, keep track of active tags:
_completenotificationmanager.notify(text, id, notification); collectionofactivetags.add(text);  ...  (string activetag : collectionofactivetags)         notificationhelper._completenotificationmanager.cancel(activetag, id);   i wish you're trying supported, seems should be.
Android - Notificationmanager.Cancel(Id) Is Not Working Inside A
ReplyDeleteBroadcast Receiver - >>>>> Download Now
>>>>> Download Full
Android - Notificationmanager.Cancel(Id) Is Not Working Inside A
Broadcast Receiver - >>>>> Download LINK
>>>>> Download Now
Android - Notificationmanager.Cancel(Id) Is Not Working Inside A
Broadcast Receiver - >>>>> Download Full
>>>>> Download LINK xq