问题描述
我知道,活动可以在舱单申报为被排除在最近通话与安卓excludeFromRecents
:http://developer.android.com/guide/topics/manifest/activity-element.html#exclude
I know that Activities can be declared in manifest as being excluded from recents with android:excludeFromRecents
:http://developer.android.com/guide/topics/manifest/activity-element.html#exclude
不过,这不是我要找的,我想知道是否有一种方法可以从最近的应用程序的编程
However, that's not what I'm looking for, I would like to know if there is a way to remove the app from recent apps programmatically
推荐答案
是,通常当你想有一个活动的特殊属性
启动时,你提供特殊标志到意图
。在这种情况下<$c$c>FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS$c$c>.
Yes, generally when you want to have special properties for an Activity
when starting it you supply special flags to the Intent
. In this case FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS
.
更新:
如果你需要隐藏当前已经运行的活动,你可能能够使用此标志与FLAG_ACTIVITY_CLEAR_TOP组合,将发送新的意图,以现有的活动。你必须去思考,也许尝试什么作为用户你的筹码周围的动作发生,但并不管,这将使您的应用程序重新出现在最近的应用程序。
If you need to hide the current already running activity, you might be able to use this flag in combination with FLAG_ACTIVITY_CLEAR_TOP which would send the new Intent to the existing Activity. You'll have to think and perhaps experiment with what happens as the user moves around your stack though and whether that will make your app re-appear in the recent apps.
这篇关于从最近的应用程序编程方式删除应用程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!