Friday, 15 April 2011

Android Push Notification using older data -



Android Push Notification using older data -

i have unusual problem force notifications using info older force notifications, think. app has list of companies , utilize force notifications info when user clicks on notification takes them company in app. while testing, first message send works fine , takes me right company. when send message supposed go different company, goes first one. know app receiving right information, because when log company id matches supposed be. when app opened clicking notification, company id shows in log not right one.

here code handles notification

private void sendnotification(string title, string msg, string cat, string comp) { mnotificationmanager = (notificationmanager) this.getsystemservice(context.notification_service); log.i("send notif",""+comp); intent launch = new intent(this, accountsetup.class); launch.putextra("cat", cat).putextra("comp", comp); pendingintent contentintent = pendingintent.getactivity(this, 0, launch, 0); notificationcompat.builder mbuilder = new notificationcompat.builder(this) .setsmallicon(r.drawable.ic_launcher) .setcontenttitle(title) .setstyle(new notificationcompat.bigtextstyle() .bigtext(msg)) .setcontenttext(msg); mbuilder.setcontentintent(contentintent); mnotificationmanager.notify(notification_id, mbuilder.build()); }

this working expected, here code have pulling info out oncreate()

intent thispage = getintent(); if(thispage.getstringextra("comp") != null ) { log.i("mainactivity extras","received cat " + thispage.getintextra("cat", 11) + " comp " + thispage.getstringextra("comp")); mainpage.putextra("currentlocation", user._location) .putextra("selectedcategory", thispage.getintextra("cat", 11)) .putextra("selectedcompany", -1) .putextra("companyid", thispage.getstringextra("comp")); }

this im having problem, when activity launches, still has old company id, regardless of force notification message clicked.

am missing something? title , body of message correct, , log shows company id right too, when click intent extras showing whatever sent in first message.

well facing similar issue too. solved using pendingintent.flagoneshot. here's line code:

pendingintent contentintent = pendingintent.getactivity(this, 0, intent, pendingintent.flag_one_shot);

there 5 types of pendingintent flags 1 of them might work if not one.

android push-notification

No comments:

Post a Comment