“This is the second day of my participation in the Gwen Challenge in November. See details: The Last Gwen Challenge in 2021”
Default rule: If you start an Activity in different tasks, multiple instances of it will be created and placed in each Task without interfering with each other. (For example, when you create a contact in the SMS click, you open the contact app and find that the contact is unrelated)
There is special logic: click the email address in the message, jump directly to the email APP; This can be done by changing lunchmod to SingleTask in ActivityManifest;
The mailbox APP creation object will be put into a separate Task, and then stacked on the SMS app (not only activities can be stacked in the Task, but also different tasks can be stacked, Task stacking is only provided for the foreground Task, when the foreground Task enters the background, it will be opened immediately. Foreground Task The most common scenarios for accessing background tasks are as follows: Press the Home button to return to the desktop. Press the Recent Task button to view the latest task. Front Task in the Task list recently when he was shown into the background, rather than after the switch to the other applications, which is when after entering the email address, click the email link after pressing the recent Task list to check the recent tasks, back to your email APP interface, have been press the return key at this time, will not be back in the SMS APP, Only one foreground Task left)
If you leave lunchmod unchanged and change the allowTaskReparenting attribute to True, then when you open your email in a text message, it will still go to the Task in the email APP, but then you click from the desktop to go to the email APP, The Activity placed in the SMS will be moved to the Task of the email APP, displayed at the top of the rollback stack, and then cut back to the SMS will find that the Activity has disappeared (if you need to use it, you need to do a test, android9, 10 May not work).
SingleTask: In addition to the Activity being created in a fixed Task, the guarantee is that if the object is already in the stack, the existing object will be reused and no new object will be created. Instead of calling onCreate(), its onNewIntent() method will be called. Enable it to parse data from the intent to refresh the interface. If the Activity is loaded with other activities before calling onNewIntent(), the system pops them all off the stack. Ensure that there is only one Activity object in each Task, (unique)
SingleInstance: a singleInstance whose behavior logic is basically the same as that of a SingleTask, except that there is only one Activity in the Task, and no old or new Activity is allowed. For example, if you set the Activity to singleInstance, the user will create an Activity object and a separate Task to hold after clicking on the email address in the SMS message. If the Activity and Task have been created before, Then, like singleTask, it will reuse the Activity directly by calling its onNewIntent(), and the Task will also be pressed on the SMS Task, showing the animation of switching APP. (At this point, if you click the back button, the system will directly revert to the SMS APPTask. If you do not directly click the back button, but press the recent Task button to view the recent Task list, and then return to the Task of mail APP, then click back, the Task is not stacked and will directly return to the desktop;) If a new Activity is started at this point, the Activity will be placed on top of the new Task and (unique, exclusive) will not be finished