[英]Why does my android launcher re-open on Home Press
I'm developing a launcher application. 我正在开发启动器应用程序。 When I'm on the launcher, and I press home, the activity animates away and opens a new instance of the activity.
当我在启动器上并按Home键时,该活动会动画化并打开该活动的新实例。 What can I do to just stay on the home screen activity when pressing 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>
...
将活动的launchMode设置为“ singleTask”或“ singleTop”可以解决此问题。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.