Android : Created System Notification. - Can you retrieve parameters on notification CLICK? -


i've created notification. when user clicks notification within android operating system, starts desired activity. calls oncreate on activity_send.class. question is, can access information regarding notification? title of notification, or id or possible pass parameters can set when creating notification can retrieve when calls activity??

the below code im using create notification... revised code

private static void notice(string msgfrom, string msg) { intent intent = null;     string title;  taskstackbuilder stackbuilder = taskstackbuilder.create(appctx);  title = "new message " + msgfrom; senduser = msgfrom;     // sending message to? intent = new intent( appctx, activity_send.class);   intent.putextra("from", msgfrom); intent.putextra("id",integer.tostring(noticecount)); if (whoscreen != null) { stackbuilder.addnextintent(whoscreen); } stackbuilder.addnextintent(intent);  //pendingintent pintent = pendingintent.getactivity(appctx,noticecount,intent, 0); pendingintent pintent = stackbuilder.getpendingintent(noticecount, pendingintent.flag_update_current);  notificationcompat.builder nb =   new notificationcompat.builder(appctx); nb.setsmallicon(r.drawable.pp);     nb.setcontenttitle(title); nb.setcontenttext(modmsg); nb.setautocancel(true); nb.setcontentintent(pintent);       notification notification = nb.build();     notificationmanager nm = (notificationmanager) appctx.getsystemservice(notification_service);     nm.notify(noticecount, notification);        noticecount = noticecount +1; } 

you can put want in intent used start activity_send class extras. example:

intent.putextra("notificationtitle", title); intent.putextra("notificationid", noticecount); 

you haven't posted code use create pintent, should like:

pintent = pendingintent.getactivity(this, 0, intent, 0); 

this pendingintent set on notification using setcontentintent().

in oncreate() of activity_send can extras this:

string notificationtitle = getintent().getstringextra("notificationtitle"); int notificationid = getintent().getintextra("notificationid", -1); 

Comments

Popular posts from this blog

java - Jmockit String final length method mocking Issue -

asp.net - Razor Page Hosted on IIS 6 Fails Every Morning -

c++ - wxwidget compiling on windows command prompt -