我不明白为什么会发生这种情况:我需要在单个实例中创建每个 Activity,所以我放入android:launchMode="singleInstance"
了 Manifest。但是当我在设备上按下“主页”并再次打开它时,系统会清除堆栈并打开根 Activity,而不是最后一个打开的 Activity。如何为用户保留最后一个打开的活动但保留singleInstance
在清单中?
编辑:清单
...
<application
...>
<activity
android:name=".ui.login.LoginActivity"
android:launchMode="singleInstance"
android:screenOrientation="portrait"/>
<activity
android:name=".ui.activity.MainActivity"
android:label="${app_title_constant}"
android:launchMode="singleInstance"
android:screenOrientation="portrait">
<intent-filter>
<action android:name="android.intent.action.MAIN"/>
<category android:name="android.intent.category.LAUNCHER"/>
</intent-filter>
<intent-filter>
<data android:scheme="${scheme}"/>
<action android:name="android.intent.action.VIEW"/>
<category android:name="android.intent.category.DEFAULT"/>
<category android:name="android.intent.category.BROWSABLE"/>
</intent-filter>
</activity>
<activity
android:name=".ui.more.service.ScannerActivity"
android:screenOrientation="portrait"
android:theme="@style/AppTheme"/>
<activity
android:name=".ui.activity.CardsListForSendActivity"
android:launchMode="singleInstance"
android:screenOrientation="portrait"/>
<activity
android:name=".ui.activity.CountriesActivity"
android:launchMode="singleInstance"
android:screenOrientation="portrait"/>
<activity
android:name=".ui.activity.StepperCardPurchaseActivity"
android:launchMode="singleInstance"
android:screenOrientation="portrait"/>
<service
android:name=".service.CacheContactsIntentService"
android:exported="false"/>
<service
android:name=".managers.push.PushNotificationExtenderService"
android:exported="false">
<intent-filter>
<action android:name="com.onesignal.NotificationExtender"/>
</intent-filter>
</service>
<receiver
android:name=".managers.push.PushBroadcastReceiver"
android:enabled="true">
</receiver>
</application>
</manifest>