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.

To solve this problem, I used the Intent.FLAG_ACTIVITY_CLEAR_TASK flag, but it can happen that the user has not finished working with the current activation and has not minimized it, but already clicked on the notification. Accordingly, you need to show him the dialogue "Are you sure? You will go out forever!" But how? What method is called when using 'Intent.FLAG_ACTIVITY_CLEAR_TASK'?

If no, then how to solve this problem?

    2 answers 2

    You do not need FLAG_ACTIVITY_CLEAR_TASK (remove it) - when you call an existing Activity, it executes the method

    Activity.onNewIntent(Intent intent)

    Redefine this method and describe the logic you need in it (Show dialogue / restart Activity, etc.)

    • Ideally, I’ll check and answer if it works. - user3239600

    Override the onPause() method in the Activity calling AlertDialog in it AlertDialog

    Link to the documentation there you can find the life cycle of the Activity

    • 1) Link is broken; 2) The user can minimize and maximize the screen (well, for example, if SMS arrives), the arrival of the notification is not regulated by anything, sent on a specific request from other users - user3239600
    • @ user3239600 then you need to make a new Task (intent.FLAG_ACTIVITY_NEW_TASK) when you click on a notification, and there when you close it, the main one is not deleted unless of course cleaning the current Task, plus you have to tinker with the intent. Then the old task pauses. - Eugene Suetin