I have an activity A that is triggered like the starting activity.
in oncreate, if some data is missing, activity A creates a new activity B with a startactivity. It also calls finish() after that. Like this way, I obtain a backstack with only activity B in it.
So far, so good.
Now, when some tasks are completed in activity B, it calls startactivity(activityA) and subsequently calls on itself finish(). It also passes some extras, and activity A will read them without any problem.
private void goToA(){
Intent goHome= new Intent(this, A.class);
goHome.setFlags(Intent.FLAG_ACTIVITY_NO_ANIMATION | Intent.FLAG_ACTIVITY_BROUGHT_TO_FRONT);
goHome.putExtra("test", "test 1");
startActivity(goHome);
finish();
}
Now I have a backstack formed by nothing but activity A. Right? In fact, if I press "back" I go back to the launcher.
Ok, now, on activity A, during an operation I create a notification with a pendingintent in it. The intent calls the activity A itself with new extras values, but with the same parameters passed from activity B before.
Intent notifyIntent= new Intent(MyApplication.getAppContext(), A.class);
notifyIntent.setFlags(Intent.FLAG_ACTIVITY_BROUGHT_TO_FRONT);
notifyIntent.putExtra("test", "test 2");
PendingIntent intentHome= PendingIntent.getActivity(MyApplication.getAppContext(),2,notifyIntent, PendingIntent.FLAG_CANCEL_CURRENT);
Notification notificationToSend= new Notification(R.drawable.icon_notification, "Tracciamento avviato", System.currentTimeMillis());
notificationToSend.setLatestEventInfo(MyApplication.getAppContext(), "Tracciamento sgàget!","Seleziona per tornare al tracciamento", intentHome);
notificationToSend.flags |= Notification.DEFAULT_SOUND;
notificationToSend.flags |= Notification.FLAG_NO_CLEAR;
Now, if I go back to the launcher, I open the notification area and I tap my notification, I go back to the activity A as expected, but when I read the extras in onResume, I get the ones passed by activity B ("test 1")!
I don't think this is a common "update your pendingintent properly" issue, cause the first startactivity does not involve any pendingintent at all. Any suggestion?