First knowledge of Android: taskaffinity

Source: Internet
Author: User

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.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.