如何关闭/退出在Android的应用程序? [英] How to close/exit an application in android?

查看:133
本文介绍了如何关闭/退出在Android的应用程序?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图关闭使用完成()的应用程序,但完成()方法只是完成的活动,该应用程序没有关闭。 现在,我使用System.exit(0)有时会关闭应用程序它的工作原理,但有时它会抛出异常。如何从一个应用程序完全退出?

I tried closing the application using the finish(), but finish() method just finishes the activity, the application does not closes. Now I am using System.exit(0) to close the application sometimes it works but sometime it throws an exception. How can I completely exit from an application??

推荐答案

好了,你可以做onething让您的应用程序的ProcessID和的onDestroy()杀掉该进程。这就是它

Okay, you can do onething get ProcessID of your application and in onDestroy() kill that process. Thats it

int pid=android.os.Process.myPid();
android.os.Process.killProcess(pid);

这篇关于如何关闭/退出在Android的应用程序?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆