For example I created project with 2 activities: FirstActivity with android:launchMode="singleTask" flag and SecondActivity.
At first user starts FirstActivity and after this SecondActivity will start on button click. From SecondActivity we create status bar notification.
Intent intent = new Intent(SecondActivity.this, FirstActivity.class);
intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
intent.putExtra(FirstActivity.ARG, true);
NotificationCompat.Builder builder = new NotificationCompat.Builder(SecondActivity.this);
builder.setSmallIcon(R.drawable.ic_launcher)
.setAutoCancel(true)
.setContentTitle("title")
.setContentText("message");
PendingIntent notifyIntent = PendingIntent.getActivity(SecondActivity.this, 0, intent,PendingIntent.FLAG_CANCEL_CURRENT);
builder.setContentIntent(notifyIntent);
NotificationManager notificationManager = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
notificationManager.notify(1000, builder.build());
When I clicked on this notification and my application is running now, FirstActivity#onNewIntent method will be executed and intent contains ARG extra = true. It's Ok situation.
When I clicked on this notification and my application is NOT running now, FirstActivity#onNewIntent method will NOT be executed, but instead of this FirstActivity#onCreate() will be executed and I can get my ARG flag like
getIntent().getBooleanExtra(ARG, false)
This intent contains ARG extra = true. It's correct situation too.
But when I try exit from my app after Situation 2 pressing back button and run app again, I received in FirstActivity#onCreate() intent with ARG = true (old extra value which I handled). Why my flag is "true" after re-open app?