I am showing a notification with this intention:
Intent intentOpen = new Intent(this, MainActivity.class);
intentOpen.setAction("ACTION_SHOW_BACKUP_FRAGMENT");
intentOpen.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_SINGLE_TOP);
PendingIntent pendingIntentOpen = PendingIntent.getActivity(this, 0, intentOpen, PendingIntent.FLAG_UPDATE_CURRENT);
notificationBuilder.setContentIntent(pendingIntentOpen);
As you can see, the action is set to "ACTION_SHOW_BACKUP_FRAGMENT", so when the user clicks on the notification, my main singleTop MainActivity can get the action in the method onResume()with getIntent().getAction().
For this to work, I had to implement it onNewIntent()as follows:
protected void onNewIntent(Intent intent) {
super.onNewIntent(intent);
setIntent(intent);
}
, , , . , "", , , onResume() , "ACTION_SHOW_BACKUP_FRAGMENT" ! , .
Intent PendingIntent, . setIntent(new Intent()); onResume(), onNewIntent() "ACTION_SHOW_BACKUP_FRAGMENT" .
?