简体   繁体   中英

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.

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?

You can use Activity#finish() when you're done with any Activities. For example, when the auto-logout occurs, call finish() on any open Activities.

https://developer.android.com/reference/android/app/Activity.html#finish()

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM