System.exit()的Andr​​oid中 [英] System.exit() in android

查看:119
本文介绍了System.exit()的Andr​​oid中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我知道system.exit(0),不应使用。 我看过很多的教程,以及说明为什么它不建议用于退出应用程序和完成()是一个更好的选择,但在这个肮脏的解决办法是用比我的主要问题非常罕见的情况下的可以将它伤害的Andr​​oid设备或设备的任何方面,如果用?

I know system.exit(0) should not be used. I have read plenty of tutorials as well stating why it's not recommended for exiting applications and finish() is a better alternative ,but in very rare case when this dirty workaround is used than my main question is can it harm the android device or any aspect of device if used?

推荐答案

简短的回答:没有

长的答案:不,它不会损害设备或设备的任何方面。它只是删除了应用程序的内存和清除所有使用的资源。如果您有任何打开的文件,就可以成为损坏,但文件系统不会。机器人应该释放你已经在使用的时候都和任何资源(GPS,WIFI等),但它们可以在一个不确定的状态。比较System.exit()的的影响到一个应用程序崩溃:这会不会影响到你的设备无论是

long answer: No, it doesn't harm the device or any aspect of the device. It just removes the app from memory and cleans up all used resources. If you have any files open, they can become corrupted, but the filesystem won't. Android should release all and any resources (GPS, WiFi, etc) that you have in use at the time, but they could be in an undefined state. Compare the effects of System.exit() to a an app-crash: that wouldn't affect your device either.

这篇关于System.exit()的Andr​​oid中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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