android - onclicklistener for notification -


this question has answer here:

i had set notification in app. working fine. if click notification in statusbar takes app.
need set work if notification clicked can set this? there method implicitly got invoked when notification clicked?
want remove notification if clicked,how so?

this code

notifmanager = (notificationmanager) getsystemservice(notification_service);   intent inty=getintent(); note = new notification(r.drawable.icon, "new e-mail", system.currenttimemillis());   pendingintent intent = pendingintent.getactivity(mainactivity.this, 0, inty, 0);   note.setlatesteventinfo(mainactivity.this, "new e-mail", "you have 1 unread message.", intent); notifmanager.notify(r.string.search_hint, note);  

you add data intent , in activity in oncreate , onnewintent methods.

for example:

inty.putextra("came notification", true); 

you can read out via intent passed onnewintent or in oncreate using getintent().

intent.getbooleanextra("came notification", false); 

Comments