android - How can i enter in my application through notification? -


this code of notification. want onclick application starts. right nothing happen

private void checknoti(){          notificationcompat.builder notificationbuilder = new notificationcompat.builder(                                 service.this);                 notificationbuilder.setcontenttitle("title");                 notificationbuilder.setcontenttext("context");                 notificationbuilder.setticker("tickertext");                 notificationbuilder.setwhen(system.currenttimemillis());                 notificationbuilder.setsmallicon(r.drawable.ic_stat_icon);                  intent notificationintent = new intent(this, service.class);                 pendingintent contentintent = pendingintent.getactivity(this, 0,                                 notificationintent, 0);                  notificationbuilder.setcontentintent(contentintent);                  notificationbuilder.setdefaults(notification.default_sound                                 | notification.default_lights | notification.default_vibrate);                  mnotificationmanager.notify(1,                                 notificationbuilder.build());     }   } 

this code inside class. it's not inside mainactivity. can't like:

intent.setclassname("your.package.name", "activitytolaunch"); 

i think because doing intent notificationintent = new intent(this, service.class);

to bring app foreground if running need set different flags on intent:

notificationintent.setflags(intent.flag_activity_clear_top | intent.flag_activity_single_top); 

for running specific method pass information along intent , interpret in application decide method run.

see answer here


Comments

Popular posts from this blog

php - Calling a template part from a post -

Firefox SVG shape not printing when it has stroke -

How to mention the localhost in android -