How to exclude from recents an exported activity?

心已入冬 提交于 2020-02-20 08:17:48

问题


I have an app with an exported activity that can be invoked from other apps (Specifically the sharing action - android.intent.action.SEND)

How can an exported activity be excluded from recents?

I don't see a way to set the FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS flag, because it is invoked from the outside.

The reason I want to do this is because this intent becomes the last one in my activity stack, thus when clicking on the recents, a file is being re-shared instead of the main activity to pop up.

Note: android:launchMode="singleTask" solves the problem in a specific case, only where another activity is on top. BUT, this isn't an option because it disrupts the user task flow and doesn't work if there is no other app's activity at the root.


回答1:


You can add the android:excludeFromRecents attirbute to your <activity> element in the manifest with a value of true:

<activity
    android:name="XYZ"
    android:excludeFromRecents="true">


来源:https://stackoverflow.com/questions/15202259/how-to-exclude-from-recents-an-exported-activity

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!