gpt4 book ai didi

android - 当应用程序处于后台时, Activity 在“最近”中不可见

转载 作者:塔克拉玛干 更新时间:2023-11-02 19:25:23 24 4
gpt4 key购买 nike

问题描述

在我的一个应用程序中,我看到了非常奇怪的行为:当我的应用程序在前台运行时(最上面的一个),我可以在系统的“最近”中看到它的 Activity 。但是,一旦我将其置于后台,刚才列出的相同 Activity (即 AccountsActivity)就不再出现在 Recents 中。我的 list 文件的相关部分:

<application
android:name=".WebnetApplication"
android:allowBackup="false"
android:allowClearUserData="true"
android:hardwareAccelerated="true"
android:icon="@drawable/ic_launcher"
android:label="@string/app_name"
android:theme="@style/AppTheme" >

<activity
android:name=".StartActivity"
android:alwaysRetainTaskState="true"
android:excludeFromRecents="true"
android:label="@string/app_name"
android:theme="@android:style/Theme.NoDisplay" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>

<activity
android:name=".AccountsActivity"
android:excludeFromRecents="false"
android:launchMode="singleTask"
android:windowSoftInputMode="adjustResize" />

...

调查结果

因为这是我唯一一个出现这种行为的应用程序,所以我检查了所有样式以及我的 WebnetActivityWebnetApplication 以确保我不会调用任何可能影响的内容最近。没有这样的事。

然后我开始剥离 Manifest 文件,看看是否有什么变化。正如预期的那样,罪魁祸首潜伏在那里,我仍然不清楚为什么。开始时,Manifest 中的 AccountsActivity 条目根本没有 android:excludeFromRecents 条目 - 这导致 AccountsActivity 在 Recents 中根本不可见。当我添加 android:excludeFromRecents="true" 时, Activity 在“最近”中变得可见,但只有当它在前面时。当我移到后面时,它从“最近”中消失了。当我从 StartActivity 声明中删除 android:excludeFromRecents="true" 时,无论应用程序在前面还是在后台,AccountsActivity 都会在 Recents 中可见我也可以毫无问题地从它的条目中完全删除 android:excludeFromRecents

问题

此刻我正在低头试图理解为什么这一切都是这样 - 这是正常的(而且我不知道什么)或者它可能是框架中的错误?任何人都遇到过类似的问题,可以分享经验、想法或解释吗?

最佳答案

从主要 Activity 中删除 android:excludeFromRecents="true"

引自 android:excludeFromRecents :

Whether or not the task initiated by this activity should be excluded from the list of recently used applications ("recent apps"). That is, when this activity is the root activity of a new task, this attribute determines whether the task should not appear in the list of recent apps. Set "true" if the task should be excluded from the list; set "false" if it should be included. The default value is "false".

关于android - 当应用程序处于后台时, Activity 在“最近”中不可见,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24436884/

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