Original address: http://henzil.easymorse.com /? P = 481
Androidmanifest. xml file in Android,
The activity tag has an attributeAndroid: taskaffinity = "string".
If this attribute is not set, an application has only one stack by default. The stack is measured in application package.
The following are my three experiments:
1. Create two projects,Application01AndApplication02
Application01SetAndroid: taskaffinity = "AAA. AAA" Android: allowtaskreparenting = "true"
Application02Also setAndroid: taskaffinity = "AAA. AAA" Android: allowtaskreparenting = "true"
RunApplication01And then click the Home KeyApplication01Run in the background and then runApplication02Now press the return key. The current display isApplication01OfMainactivityClick the return key to return to the home page.
However, long press the Home Key and only the programs that have runApplication01.
2. Next, I did another experiment on this basis.Application01Create a newSecondactivity, Set
Android: taskaffinity = "AAA. BBB" Android: allowtaskreparenting = "true"
InMainactivityIn startactivity, set the flag attribute in intentFlag_activity_new_taskNote that the flag attribute must be new task.
Then runApplication01, Click to enterSecondactivityClick the Home key to bring the program back to the background,
Then runApplication02, Click return, the currently displayedApplication01InMainactivityAnd then click return.Application01MediumSecondactivity, As expected.
3. HeapApplication01Modify again and addThirdactivity, Set PropertiesAndroid: taskaffinity = "AAA. AAA" Android: allowtaskreparenting = "true"
AndSecondactivityIn startactivity, set the flag attribute in intentFlag_activity_new_task;
RunApplication01, Click to enterSecondactivity, And then enterThirdactivity, Click return, and returnMainactivity, Click return to returnSecondactivityAnd then click return to the home page, which is consistent with the expectation.