Faced such a problem. If the user enters Activation A, and then collapses it, then when opening the same activation (but already through a push-notification, and not the application history), it is not recreated.

This is how I create a notification:

Intent intent = new Intent(this, Activity.A); intent.putExtra("DATA1", SOME DATA); intent.putExtra("DATA2", "SOME DATA"); PendingIntent pendingIntent = PendingIntent.getActivity(this, 0 /* Request code */, intent, 0); Uri defaultSoundUri = RingtoneManager.getDefaultUri(RingtoneManager.TYPE_NOTIFICATION); NotificationCompat.Builder notificationBuilder = new NotificationCompat.Builder(this) .setLargeIcon(bitmap) .setSmallIcon(R.drawable.photo_icon) .setContentTitle(fullTitle) .setContentText(text) .setAutoCancel(true) .setPriority(NotificationCompat.PRIORITY_MAX) .setSound(defaultSoundUri) .setContentIntent(pendingIntent); NotificationManager notificationManager = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE); notificationManager.notify(0 /* ID of notification */, notificationBuilder.build()); 
  • A counter question - why re-create the activation once again? - xkor
  • @xkor, the user did not complete the action on the already created screen (and if he clicks on the notification, he does not want to complete it). After the notification, completely different data is displayed that is not related to the previous one. - user3239600
  • that is, you want to not recreate the activation and open a new one? - xkor

1 answer 1

Add in the launch launch activit:

 Intent intent = new Intent(this, Activity.A); intent.putExtra("DATA1", SOME DATA); intent.putExtra("DATA2", "SOME DATA"); intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_MULTIPLE_TASK); 

By this you inform that he has to open a new activation in a separate task.

  • and if the user has not turned off the screen, but already received a notification? In this case, it is not replaced. How to score on a hard one, so that onDestroy would be called in the current task and a new one would be immediately created via onCreate? - user3239600
  • I myself will answer my question - there is a flag 'Intent.FLAG_ACTIVITY_CLEAR_TASK', if someone needs it :) - user3239600
  • PS It does not help completely. Is there such a function that is performed with this flag? - user3239600