完全关闭一个应用程序不仅仅是一个活动是一个、应用程序

2023-09-12 05:56:12 作者:风绾梦境悠

我试图关闭应用程序有一个按钮,用这种方法:System.exit(0); 但是,我回到了其他活动!我该如何解决呢? 谢谢

I'm trying to close an app with a button with this method:System.exit(0); But I get back to the other activity ! How can I fix that ? Thanks

推荐答案

这不是推荐的,但这应该彻底杀死的应用程序。

It's not recommended, but this should completely kill off the app.

android.os.Process.killProcess(android.os.Process.myPid());

要正常退出,你应该只调用完成()从您的主要活动。

To exit normally you should just invoke Finish() from your main activity.