【问题标题】:Why does my android launcher re-open on Home Press为什么我的 android 启动器在 Home Press 上重新打开
【发布时间】:2016-08-12 18:00:22
【问题描述】:

我正在开发一个启动器应用程序。当我在启动器上并按下 home 键时,该活动将动画化并打开该活动的一个新实例。按 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>
        ...

【问题讨论】:

    标签: android homescreen android-launcher android-homebutton


    【解决方案1】:

    将活动的启动模式设置为“singleTask”或“singleTop”解决了这个问题。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2016-10-20
      • 1970-01-01
      • 2016-06-17
      • 1970-01-01
      • 1970-01-01
      • 2015-01-13
      • 2021-02-20
      相关资源
      最近更新 更多