[英]Kill application and remove from recent apps list [Android]
I know this has been answered earlier but I could not find the appropriate solution which fits in my case. 我知道这个问题早已得到解决,但是我找不到适合我情况的适当解决方案。 I have an app with multiple activities in it. 我有一个包含多个活动的应用程序。 On the first Activity, when the user presses the back button, a close confirmation dialog box is opened to ask the user for confirmation. 在第一个活动上,当用户按下“后退”按钮时,将打开一个关闭确认对话框,要求用户进行确认。
When the user presses 'Yes', the application is closed but it is still in the recent apps list. 当用户按“是”时,该应用程序已关闭,但仍在最近的应用程序列表中。
What I want is to remove it from the recent apps list as well but only when the user comes out of the app using this Close dialog. 我想要的是也将其从最近的应用程序列表中删除,但是仅当用户使用此“关闭”对话框离开应用程序时才将其删除。 ie If the user presses the home button or Apps List button, the app should still be listed in the recent apps list. 即,如果用户按下主页按钮或“应用程序列表”按钮,则该应用程序仍应列在最近的应用程序列表中。
I tried using android:excludeFromRecents="true"
property for this activity but it excludes the complete app from the recent apps list even if any other Activity is being worked upon. 我尝试为此活动使用android:excludeFromRecents="true"
属性,但即使正在处理其他任何活动,它也会从最近的应用程序列表中排除整个应用程序。
In short, I want to remove the app from the recent apps list on a button click. 简而言之,我想通过单击按钮从最近的应用程序列表中删除该应用程序。
如果您想从最近的任务中删除自己的活动,则可以使用finishAndRemoveTask()
。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.