gpt4 book ai didi

java - 启动模式不起作用

转载 作者:行者123 更新时间:2023-11-30 10:20:30 24 4
gpt4 key购买 nike

我在我的 list 文件中定义了启动模式,以便在后台堆栈上只保留一个 Activity ,但不幸的是,它没有解决后退导航问题。也就是说,用户必须反复单击返回导航按钮才能退出应用程序。这是我的 list 配置。

<?xml version="1.0" encoding="utf-8"?>

<application
android:allowBackup="true"
android:icon="@drawable/ic_action_launcher"
android:label="@string/app_name"
android:roundIcon="@drawable/ic_action_launcher"
android:supportsRtl="true"
android:theme="@style/AppTheme">
<activity android:name=".MainActivity"
android:launchMode="singleTop"/>
<activity android:name=".DataViewActivity"
android:launchMode="singleTop"/>
<activity android:name=".FormsViewActivity"
android:launchMode="singleTop"/>
<activity android:name=".ProfileViewActivity"
android:launchMode="singleTop"/>
<activity android:name=".NotificationsActivity"
android:launchMode="singleTop"/>
<activity android:name=".NotificationViewActivity"
android:launchMode="singleTop"/>
<activity android:name=".LoginActivity"
android:launchMode="singleTop">
<intent-filter>
<action android:name="android.intent.action.MAIN" />

<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity android:name=".InitialSetupActivity"
android:launchMode="singleTop">
</activity>
</application>

<uses-permission android:name="android.permission.INTERNET"/>

提前致谢

最佳答案

使用 singleTasksingleInstance 而不是 singleTop

在 Android 文档中:

标准和单顶

An activity with the "standard" or "singleTop" launch mode can be instantiated multiple times. The instances can belong to any task and can be located anywhere in the activity stack. Typically, they're launched into the task that called startActivity() (unless the Intent object contains a FLAG_ACTIVITY_NEW_TASK instruction, in which case a different task is chosen — see the taskAffinity attribute)

单任务和单实例

In contrast, "singleTask" and "singleInstance" activities can only begin a task. They are always at the root of the activity stack. Moreover, the device can hold only one instance of the activity at a time — only one such task.

来源:https://developer.android.com/guide/topics/manifest/activity-element.html

关于java - 启动模式不起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48189598/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com