I am having a notification screen .When notification receives and i tap on notification it will navigate to particular screen.The issue is when i am in the notification screen and i am getting a new notification the on new intent is returning old data.I am calling webservice from the number getting from notication .Because of this i am stuck .Could any one help me.below is the code
notificationIntent.putExtra("from","notification");
notificationIntent.putExtra(Constants.NUMBER,task);
notificationIntent.setAction(Long.toString(uniqueInt));
notificationIntent.addCategory(taskNumber);
PendingIntent pendingIntent = PendingIntent.getActivity(this, new Random().nextInt(), notificationIntent, PendingIntent.FLAG_UPDATE_CURRENT);
and in onNewIntent
if(null != getIntent() && getIntent().getExtras() != null){
if(getIntent().getExtras().containsKey(Constants.NUMBER))
{
String taskNumber = getIntent().getExtras().getString(Constants.NUMBER);
if(null != taskNumber)
{
taskNumber = getIntent().getExtras().getString(Constants.NUMBER);
loadTasks(taskNumber);
}
onNewIntent
has new intent as argument. So you can use it directly or you can set it as starter Intent .
@Override
protected void onNewIntent(Intent intent) {
super.onNewIntent(intent);
setIntent(intent); // Optional if you want set it as starter intent
// Do your stuff with `getIntent()` OR intent
}