Running Android program, press the home key to return to the desktop, click on the program icon at the time to avoid restarting the program solution again

Source: Internet
Author: User

For example, an Android program contains two activity, mainactivity and otheractivity,mainactivity for program-initiated activity. If the program is located in Otheractivity, click the Home button, the program returns to the desktop,

In the second click of the program icon, the program will automatically restart by default, that is, to re-enter mainactivity, rather than enter the time to click the Home button in the otheractivity of the program.

Workaround:

Modify in Androidmanifest.xml, Mainactivity launchmode, remove android:launchmode= "singletask" boot mode can be.

Configuration code for Androidmanifest.xml

 <application android:icon  = "@drawable/ic_launcher"  Android:label  = "@string/app_name"  Android:theme  = "@style/appthem E "> <activity android:name  =". Mainactivity " Android:label  =" @string/title_activity_main "> &  lt;intent-filter> <action android:name= "Android.intent.action.MAIN"/> <category Android:name= "Android.intent.category.LAUNCHER"/> </intent-filter> </activity> & Lt activity android:name  = ". Otheractivity " Android:label  =" @string/title_activity_other "Android:launch Mode= "Singletask" > </activity> </application> 

Reprint: http://blog.csdn.net/xunyi_hz/article/details/8012445

Running Android program, press the home key to return to the desktop, click on the program icon at the time to avoid restarting the program solution again

Related Article

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.