[英]How to handle exiting Android app?
I found a couple of places that suggest System.exit(0), but then I read a couple of places that this is bad practice, since android handles closing an application for you. 我找到了一些建议System.exit(0)的地方,但是随后我读到了一些地方,这是不好的做法,因为android会为您关闭应用程序。
My issue is, I have an auto logout function that takes users back to the login page, BUT I'm wondering what's in memory at this time. 我的问题是,我有一个自动注销功能,可以将用户带回到登录页面,但是我想知道此时的内存是什么。 Do I have to have a de-constructor setup to set my values to null when activities change or do objects automatically get nulled out between activity changes?
我是否必须具有解构函数设置才能在活动更改时将我的值设置为null,或者在活动更改之间对象是否自动为空?
You can use Activity#finish()
when you're done with any Activities. 完成任何活动后,可以使用
Activity#finish()
。 For example, when the auto-logout occurs, call finish()
on any open Activities. 例如,当自动注销发生时,请在任何打开的活动上调用
finish()
。
https://developer.android.com/reference/android/app/Activity.html#finish() https://developer.android.com/reference/android/app/Activity.html#finish()
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.