如何以编程方式退出android应用程序

本文翻译自:How to quit android application programmatically

I Found some codes for quit an Android application programatically. 我找到了一些以编程方式退出Android应用程序的代码。 By calling any one of the following code in onDestroy() will it quit application entirely? 通过在onDestroy()中调用以下任何一个代码,它会完全退出应用程序吗?

  1. System.runFinalizersOnExit(true)
    (OR) (要么)
  2. android.os.Process.killProcess(android.os.Process.myPid());

I dont want to run my application in background after clicking quit button. 我不想在单击退出按钮后在后台运行我的应用程序。 Pls suggest me can i use any one of these code to quit my app? 请问我可以使用这些代码中的任何一个来退出我的应用程序吗? If so which code can i use? 如果可以,我可以使用哪些代码? Is it good way to quit the app in Android? 这是退出Android应用程序的好方法吗?


#1楼

参考:https://stackoom.com/question/qyM0/如何以编程方式退出android应用程序


#2楼

I think that application should be kill in some case. 我认为在某些情况下应用程序应该是kill。 For example, there is an app can be used only after login. 例如,有一个应用程序只能在登录后使用。 The login activity has two buttons, 'login' and 'cancel'. 登录活

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值