1, first say the phenomenon
There are now three activity:firstactivity, Secondactivity and Thirdactivity, and the firstactivity is the boot entry
That is, Firstactivity is configured in Androidmanifest.xml with
<intent-filter>
<action android:name= "Android.intent.action.MAIN"/>
<category android:name= "Android.intent.category.LAUNCHER"/>
</intent-filter>
First, add launchmode= "Singletask" to firstactivity
(At this point secondactivity and thirdactivity add launchmode= "singletask" effect)
Go to the app to Thirdactivity or secondactivity and press the home button
① Click on the app icon on the desktop to enter the application will find or enter the Firstactivity, and at this time secondactivity and thirdactivity
The Ondestory () method is called separately.
② Press the Home key to enter the application did not enter the firstactivity, but instead opened the application of the last open activity, and at this time called the most
The Onrestart->onstart->onresume method of the last open activity.
③ adds a deferred finish to the OnCreate method of firstactivity, such as
New Handler (). postdelayed (new Runnable () {publicvoid run () {finish ();}, 15 00);
Then click on the app icon on the desktop to enter the application will find or enter the firstactivity, but this is a new instance, the previous has been finished off, so at this time the secondactivity and thirdactivity
The Ondestory () method is not called.
Second, remove the firstactivity launchmode= "Singletask"
(At this point secondactivity and thirdactivity add launchmode= "singletask" effect)
Press the home key in either interface, and then either open the app from the desktop or long press the home key to open the app is
Enter the activity that was last opened by the app.
2, the specific principle to be further study, there is a clear principle of children's shoes please, greatly appreciated!
Questions about Android home keys and Singletask