简体   繁体   中英

What is called in place of onStop() if Activity is ended after onCreate() but before onStart()?

在此输入图像描述

So I have a very special scenario where I hit the back button right after onCreate() is called so it doesn't end up running onStart() and I have a bunch of code that I put into onStop() that I would need to run to clean things up at the very end but because onStart() is never executed, onStop() isn't reached. Is my scenario even possible? I tried looking at my print statements throughout the program and this is the scenario that I've come up with. Assuming it is indeed possible my scenario, are there are functions that are called if the Activity ends right after onCreate() but before onStart() that I can put my clean up code into?

Let say Class A -> Class B -> closed.

If you are running the code from class (Class B) that doesn't even go to 'onStart()', you don't need to clean anything, since that class hasn't even started yet.

But if you want to clean something, you should consider from the previous class (Class A), in 'onStop()'.

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