我正在开发一个启动器应用程序。当我在启动器上,并按下home键时,该活动将以动画形式显示,并打开该活动的一个新实例。如何才能在按下主页时仅停留在主屏幕活动上?
<application
android:name=".BaseApplication"
android:allowBackup="true"
android:launchMode="singleTask"
android:clearTaskOnLaunch="true"
android:stateNotNeeded="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:supportsRtl="true"
android:theme="@style/AppTheme">
<activity android:name=".MainActivity"
android:launchMode="singleInstance"
android:excludeFromRecents="true"
android:windowSoftInputMode="adjustPan"
android:screenOrientation="sensorPortrait"
android:configChanges="orientation|keyboardHidden">
<intent-filter>
<action android:name="android.intent.action.MAIN"/>
<category android:name="android.intent.category.HOME"/>
<category android:name="android.intent.category.DEFAULT"/>
</intent-filter>
</activity>
...发布于 2016-08-13 04:45:54
将活动的launchMode设置为"singleTask“或"singleTop”解决了此问题。
https://stackoverflow.com/questions/38923954
复制相似问题