关于Android应用设计中多余的“退出”功能

已经有各种文章教你如何在Android程序的任何一个页面执行退出整个程序的功能,Android.os方法、restartPackage方法、system.exit方法,甚至有人为制造异常使程序退出的方法,令人害怕呀。

其实,我们在Android model的基础上想一下,真得需要这个功能:让用户在任何时候,都能看到一个直接退出该应用的按钮吗?

我认为不需要,同样Google官方人员在很早就表达了这个观点:

Question: Does the user have a choice to kill the application unless we put a menu option in to kill it? If no such option exists, how does the user terminate the application?

Answert (Romain Guy): The user doesn't, the system handles this automatically. That's what the activity lifecycle (especially onPause/onStop/onDestroy) is for. No matter what you do, do not put a "quit" or "exit" application button. It is useless with Android's application model. This is also contrary to how core applications work.

请参考我的文章--android进程管理机制,那我们就有理由让Android框架(Activity的生命周期)去自动管理应用的生死吧,目前存在的任何一个退出的方法技巧我觉得在过去或未来的某个时候都会出现错误和异常,而无法完成该功能。与Android框架天然相违背的东西,还是不要在menu上出现了吧。

相关推荐