Reputation: 1
i have remote service in which when particular time comes, i show a notification. in notification i add extra value (ex. k=0) and pass it to proper activity. so first time activity receives correct value ( k=0). but when next time comes again in remoteservice i reset k=1 and add this extra value in notification. but this time activity receives only previous value (k=0) only not new value(k=1). Could some body see my code and correct me if i am wrong. Code in remote service.....
Notification notification = new Notification(R.drawable.tablet, text,System.currentTimeMillis());
Intent intent = new Intent(RemoteService.this, SnoozeActivity.class);
intent.putExtra("k",c);
PendingIntent contentIntent = PendingIntent.getActivity(this, 0,intent, 0);
notification.setLatestEventInfo(this, getText(R.string.remote_service_label),text, contentIntent);
myNM.notify(0, notification);
Code in receiver...
Bundle extras = getIntent().getExtras();
if(extras !=null){
int v = extras.getInt("k");
Log.w("SnoozeActivity","k value : "+v);
}
is it possible to reset putExtra value in intent...if so how to do it?
Upvotes: 0
Views: 305
Reputation: 30855
you need to pass the unique number for 2nd argument for the getActivity method
this was identify the resultcode was different for same or different intent
PendingIntent contentIntent = PendingIntent.getActivity(this, unique_number,intent, 0);
same in the notify() method for notification
Upvotes: 2
Reputation: 15477
try in your receiver
int v = Integer.parseInt(extras.getString("k"));
instead
Upvotes: 0