从最近的应用程序列表中删除

从最近的应用程序列表中删除

本文介绍了如何从最近的应用程序列表中删除应用程序?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想,Android将不会让人们做到这一点,因为他们认为自己有完美的句柄任务/应用程序。可是,我真的需要做到这一点在我的情况。

I guess that Android won't let people to do this, because they think they have perfect handle for the task/applications. However, I really need to do this in my case.

我有一个活动的一个充当我的应用程序的入口点。在该活动中,它读取preference,并决定启动该活动,说B或C之后,它完成本身。因此,活动一个永远不会出现给用户。

I have an activity A acting as the entry point of my application. In that activity, it reads the preference and decided which activity to start, say B or C. After that, it finishes itself. So, activity A never appears to the users.

我的应用程序商店的东西在SD卡,并从中读取不断。所以,当SD卡被卸载,我需要显示一个消息,该SD卡是不是打开B或C.不可用,我设在一个检查,以显示该消息时,SD卡是unavilable用户。当显示的消息,也不会尝试启动B或C

My application stores things on sdcard, and reads from it constantly. So, when the sdcard is unmounted, I need to display a message to the user that the sdcard is unavailable, instead of opening B or C. I set a check in A to display that message when sdcard is unavilable. When that message is displayed, A will not try to start B or C.

东西完美地工作,如果用户只输入从应用程序启动我的应用程序。然而,我发现,用户也可以输入长pressing回家时,我的应用程序,并从最近的应用程序列表中进行选择吧,如果他最近打开了它。当用户这样做,它跳过,直接进入B或C.我没有在他们两人的检查,因此抛出异常,当我试图访问SD卡,并强制关闭对话框弹出。

Things works perfectly if user only enter my application from application launcher. However, I found that user can also enter my application by long pressing home and choose it from the recent application list, if he has opened it recently. When user does that, it skips A and goes directly to B or C. I don't have the check in both of them, so exception is thrown while I am trying to access sdcard, and force close dialog pops up.

我可以简单地将我的支票,以两个B和C​​来解决这个问题。但在未来,活动次数从A开始将增加。如果有6人,我需要这个检查拷贝到6位。不用说,这看起来很丑陋,是一个维护的噩梦。

I can simply move my check to both B and C to fix this problem. But in the future, the number of activities started from A will increase. If there are 6 of them, I'll need to copy this check to 6 places. Needless to say, this looks very ugly, and is a maintenance nightmare.

所以,最好的解决应该从最近的应用程序列表中删除我的应用程序,当SD卡被uunmounted。但是,我找不到如何做到这一点。甚至杀害的过程中,或者使用ActivityManager.restartPackage,它仍然出现在列表中。谁能告诉我如何从列表中删除吗?

So, the best fix should be removing my application from recent application list when the sdcard is uunmounted. However, I can't find how to do this. Even killing the process or use ActivityManager.restartPackage, it still appears in the list. Can anyone tell me how to remove it from the list?

推荐答案

尝试

<activity android:name=".MainActivity"
        android:excludeFromRecents="true" ...

的Andr​​oidManifest.xml 的活动宣言。

这篇关于如何从最近的应用程序列表中删除应用程序?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-13 02:54