Close specific notification android -


i need close specific notification click buttom it. problem how know notification_id know close. code:

    intent.setaction("eliminar");     bundle = new bundle();     bundle.putint("respuesta", 1);     intent.putextras(bundle);         pintent = pendingintent.getbroadcast(getapplicationcontext(), (int) system.currenttimemillis(), intent, pendingintent.flag_update_current);                  n  = new notification.builder(getapplicationcontext())                         .setcontenttitle("recordar")                         .setstyle(new notification.bigtextstyle().bigtext(nota.gettext()))                         .setsmallicon(r.drawable.ic_icono)                         .setcontentintent(pintent)                         .setcolor(color.parsecolor("#4caf50"))                         .setongoing(true) //notificacion persistente                         .addaction(r.drawable.ic_borrar, "quitar nota", pintent).build();                   notificationmanager = (notificationmanager) getsystemservice(notification_service);                  notificationmanager.notify(cpos, n); 

cpos id of every notification

as mentioned :

cpos id of every notification.

the above statement false. each notification has own unique id acts identifier notification.

you can use notificationmanager.cancel(cpos); clear notification status bar.

you can create button , on click of button can call :

notificationmanager.cancel(cpos);

to close notification.


Comments

Popular posts from this blog

mysql - Dreamhost PyCharm Django Python 3 Launching a Site -

java - Sending SMS with SMSLib and Web Services -

python 3.5 - Pyqtgraph string in x tick -