Android Home button and Singletask issues

Source: Internet
Author: User

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

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.