android - PendingIntent sticks around after notification is dismissed -


i wrote following method check if notification active (visible on status bar):

public static boolean isnotificationactive(context context, int id) {   intent intentpopup = new intent(context, popupactivity.class);   pendingintent test = pendingintent.getactivity(context, id, intentpopup, pendingintent.flag_no_create);   return test != null; } 

i create pendingintent 1 want checked (the same 'intentpopup' , 'id' passed pendingintent) and, because of flag_no_create, expect pendingintent null if doesn't exist yet. read method in thread posted years ago here.

if notification has not yet been issued, method returns expected value (false). when notification issued , in status bar, method returns true.

however, after dismiss notification, method still returns true, if pendingintent still there.

what missing here? pendingintent still available or misunderstanding something?

is there better way check if specific notification active (being displayed in status bar)?

edit: here's code creates notification:

    intent intentpopup = new intent(context, popupactivity.class);             intentpopup.putextra("id", id);             intentpopup.putextra("timeq", timeq);      pendingintent pendingintentpopup = pendingintent.getactivity(context, id, intentpopup, pendingintent.flag_update_current);      notificationcompat.builder mbuilder = new notificationcompat.builder(context)                     .setcontentintent(pendingintentpopup)                     .setsmallicon(r.drawable.q_notification_icon)                     .setcontent(contentview)                     .setsound(uri.parse("android.resource://" + context.getpackagename() + "/raw/notification_sound"))                     .setvibrate(vibrate_pattern);              notification notification = mbuilder.build();             notification.flags |= notification.flag_no_clear;             notificationmanager notificationmanager = (notificationmanager) context.getsystemservice(context.notification_service);             notificationmanager.notify(id, notification); 

unfortunately pendingintents embed in notification not automatically disappear when notification dismissed, viewed, or canceled. can't use presence or absence of pendingintent (using pendingintent.flag_no_create you've done) determine whether or not notification active.

to determine if notification active, can call notificationmanager.getactivenotifications(). return active notifications app has posted.


Comments

Popular posts from this blog

python Tkinter Capturing keyboard events save as one single string -

android - InAppBilling registering BroadcastReceiver in AndroidManifest -

javascript - Z-index in d3.js -