My app has a main activity and occasionally on some user action it opens up another activity (and remains in the activity stack).
My understanding is, Android, if needed, can decide to kill the main activity when it's in background though the currently visible one will be unharmed. I am pretty sure I have seen this phenomenon in past (2-3 years back).
Here are the questions -
- Under what conditions Android might decide to kill the background activity though the app is in foreground?
- Does some specific version of Android/vendors have more chances of doing this than the other?
- If I remember correctly, in such cases activity's onStop may or may not be called. Is this assumption right?
There's no
main activity
concept in Android. Your app can be killed as whole or some unused elements can be garbage collected.This is not a phenomenon but normal Android system behavior.
Does not matter really. All you need to bother is that you can be killed/restarted and knowing that all you need to do is to ensure your data can survive.
Again the same - it does not matter. Ensure your app handles such case correctly and that's it.
No, unless your process is really killed, not garbage collected.