android - Notification getIntent().getExtras() gets the same bundle -


the problem im having call sendaffimationnotice() twice passing unique aff_id each time (as confirmed printing "putting " + aff_id).

this prints 'putting 1' , on second call 'putting 2'.

the phone has 2 notifications. though when both clicked both have same id toasted in oncreate method on intents activity.

both times prints "id is: 1" though both notifications unique.

public class possaffnotification{  private static int notif_id = 1; private static notificationmanager notificationmanager; private static notification note; private static pendingintent contentintent;  public static void sendaffimationnotice(context ctx, string title,string contenttext,int aff_id){      notificationmanager = (notificationmanager) ctx.getsystemservice(context.notification_service);     note = new notification(android.r.drawable.btn_star_big_on, contenttext, system.currenttimemillis() );      note.defaults |= notification.default_sound;     note.defaults |= notification.default_vibrate;     note.defaults |= notification.flag_auto_cancel;     note.flags |= notification.flag_auto_cancel;      intent notificationintent = new intent(ctx, com.mindfsck.possaff.mainactivity.class);     notificationintent.putextra("aff_id",aff_id);     system.out.println("putting " + aff_id);      notificationintent.setaction("com.mindfsck.possaff.intent.action.aff");      notificationintent = notificationintent.setflags(intent.flag_activity_reset_task_if_needed);      contentintent = pendingintent.getactivity(ctx, 0, notificationintent, 0);      note.setlatesteventinfo(ctx, title, contenttext, contentintent);      notificationmanager.notify(notif_id,note);      notif_id += 1; }     };      public class mainactivity extends activity{         @override         public void oncreate(bundle savedinstancestate){              super.oncreate(savedinstancestate);              intent serviceintent = new intent(this,paservice.class);             this.startservice(serviceintent);              bundle extras = getintent().getextras();             if(extras !=null) {                 toast.maketext(getapplicationcontext(), "id is: " + extras.getint("aff_id"),                 toast.length_short).show();             }         } } 

your intent same on non-extra parameters (e.g., action). hence, same pendingintent getactivity() call, there 1 pendingintent per distinct intent. need change -- beyond extras -- in second intent, such different action string.


Comments

Popular posts from this blog

apache - Add omitted ? to URLs -

redirect - bbPress Forum - rewrite to wwww.mysite prohibits login -

php - How can I stop spam on my custom forum/blog? -