简体   繁体   English

如何处理退出的Android应用程序?

[英]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.

相关问题 Android alertdialog Box-从应用程序退出 - Android alertdialog Box - Exiting from App 如何处理Android应用程序的用户会话 - How to handle a user session for android app 如何处理android国际象棋应用程序中的拖动? - How to handle drag in an android chess app? 当我已经在使用onBackPressed()使Webview返回时,如何在Android应用程序中弹出警报框以退出? - How to popup alertbox in android app for exiting when i am already using onBackPressed() for webviews to go back? Android,退出/暂停应用程序,如何销毁线程 - Android , exiting / pausing application, how to destroy thread Web应用程序+ Android应用程序,如何处理Android上的数据库连接 - Web application + android app, how handle db connection on android 在 Android Studio (Java) 上使用 FireBase 数据库时退出应用程序 - Exiting the App when Using FireBase Database on Android Studio (Java) Android Studio - 使用什么方法检测退出的应用程序? - Android Studio - What method is used to detect exiting app? 如何在Android应用中处理与Firebase的100多个连接? - How to handle having more than 100 connection to firebase in android app? Google Analytics for Android如何处理离线应用的使用? - How does Google Analytics for Android handle offline app usage?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM