android - Opening app on notification click? -


i open app when user clicks on notification, if not in foreground.

so far got this:

private void adnotification(ad ad) {      pendingintent dummyintent = pendingintent.getactivity(this, 0, new intent(), intent.flag_activity_new_task);     intent notificationintent = new intent(this, splashscreen.class);     store storefromad = ad.getstorefromad();     notificationintent.putextra("uzlet", new gson().tojson(storefromad));     pendingintent contentintent = pendingintent.getactivity(this, 0, notificationintent, pendingintent.flag_cancel_current);     mnotificationmanager = (notificationmanager) this.getsystemservice(context.notification_service);     notificationcompat.builder mbuilder = new notificationcompat.builder(this).setsmallicon(r.drawable.icon).setautocancel(true).setcontenttitle(ad.ad_title)             .setstyle(new notificationcompat.bigtextstyle().bigtext(ad.ad_text)).setcontenttext(ad.ad_short_text);     mbuilder.setcontentintent(dummyintent);      //checks whether application in foreground.     if (mainactivity.isinfront) {         log.i("isinfront-servicecheck", "isinfront = true");         mbuilder.setcontentintent(dummyintent);     }     else {         log.i("isinfront-servicecheck", "isinfront = false");         mbuilder.setcontentintent(contentintent);     }     int notifid = integer.parseint(ad.ad_id);     mnotificationmanager.notify(notifid, mbuilder.build()); } 

my activity has an isinfront boolean variable:

    @override protected void onresume() {     super.onresume();     isinfront = true;     log.i("isinfront-onresume", "isinfront = true"); } @override protected void ondestroy() {     super.ondestroy();     isinfront = false;     log.i("isinfront-ondestroy", "isinfront = false");  } 

well, problem is:

of course, working when click on notification immediately, example:

  1. my app in foreground, isinfront variable true.

  2. i got notification, notification builder builds dummy intent, nothing.

  3. instead of clicking notification, close app.

  4. now click notification, , app not opening because notification builder build while isinfront variable true.

so problem is, intent notification not holding current state of application, holding state when has been sent device.

how make work? ideas?


Comments

Popular posts from this blog

java - How to specify maven bin in eclipse maven plugin? -

single sign on - Logging into Plone site with credentials passed through HTTP -

php - Why does AJAX not process login form? -