android - Make Notification cleared by user or once clicked -


i have service may show notification, problem once notification set, doesn't clear neither when clicked, nor when swiped on. using flag notification.flag_auto_cancel doesn't seem anything..

private notificationmanager nm; nm = (notificationmanager)getsystemservice(notification_service); private final int notify_id = 1; private void shownotification(string date, string name) {         try{             charsequence text = "you have new event";             notification notification = new notification(r.drawable.small_icon, text, system.currenttimemillis());             pendingintent contentintent = pendingintent.getactivity(this, 0, new intent(this, viewevents.class).putextra("date", date), 0);             notification.setlatesteventinfo(this, name, "date: "+date, contentintent);             notification.defaults |= notification.default_sound;             notification.defaults |= notification.default_vibrate;             notification.defaults |= notification.default_lights;             notification.defaults |= notification.flag_auto_cancel;             nm.notify(notify_id, notification);         }catch(exception e){             log.i("notification",e.tostring());         }     } 

so doing wrong?

try using notification.builder or notificationcompat.builder instead of rolling notification manually.

among other things, prevent bug in code, applying flag_auto_cancel defaults rather flags.


Comments

Popular posts from this blog

Change php variable from jquery value using ajax (same page) -

Pull out data related to my apps from Android Play Store and iOS App Store -

How can I fetch data from a web server in an android application? -