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

[HTML]View Plaincopy
  1. <application
  2. android:icon="@drawable/ic_launcher"
  3. android:label="@string/app_name"
  4. android:theme="@style/apptheme" >
  5. <activity
  6. android:name=". Mainactivity "
  7. android:label="@string/title_activity_main">
  8. <intent-filter>
  9. <action android:name="Android.intent.action.MAIN" />
  10. <category android:name="Android.intent.category.LAUNCHER" />
  11. </intent-filter>
  12. </Activity>
  13. <activity
  14. android:name=". Otheractivity "
  15. android:label= "@string/title_activity_other" android:launchmode="Singletask">
  16. </Activity>
  17. </Application>

Running Android programs, press the home key to return to the desktop, click the program icon to avoid restarting the program again

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.