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
- <application
- android:icon="@drawable/ic_launcher"
- android:label="@string/app_name"
- android:theme="@style/apptheme" >
- <activity
- android:name=". Mainactivity "
- android:label="@string/title_activity_main">
- <intent-filter>
- <action android:name="Android.intent.action.MAIN" />
- <category android:name="Android.intent.category.LAUNCHER" />
- </intent-filter>
- </Activity>
- <activity
- android:name=". Otheractivity "
- android:label= "@string/title_activity_other" android:launchmode="Singletask">
- </Activity>
- </Application>
Running Android programs, press the home key to return to the desktop, click the program icon to avoid restarting the program again