简体   繁体   中英

Fragment is still alive after app has been killed (Android)

After I have put my app in background and locked the screen, my smartphone does a "clean in suspend" and, thus, my app is killed. After re-opening the app from Recent Apps , the onCreate() method of the main activity is called. The strange thing is that, the last Fragment used before putting the app in background is "still alive". Therefore, its onActivityCreated() callback is called because the main activity is launched.
Is there a way to make sure that there is no fragments associated with the main activity at startup ?

Ovveride onDestroy() method and stop or pause your running threads. For further details, check the documentation about android life cycle.

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