简体   繁体   中英

Android App Exits when Going into Background

Ever since I added a new Class to my Android app (specifically, a sqlite helper class) may app wants to relaunch after I press the home button. Before adding the class, the app would multitask as expected.

I am stumped. It seems onDestroy is called every time the app goes into the background.

Any tips or thoughts as to why this would happen?

This is by design. Please refer to Android activity lifecycle for more info when/how your activity could be destroyed. Basically, as soon as your app goes into background, your activity can be killed at any moment.

If you want to continue execution, you need to create a Service that represents a long-running components in Android architecture.

原来清单文件中有android:finishOnCloseSystemDialogs =“ true”。

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