Example context: I open an app then I press device...
# android
d
Example context: I open an app then I press device’s home button and I leave the app in the background, so how many second or minute this app will be terminate by Android?
😶 3
r
we can't really measure that in time. since the OSs will do that for you
1
i mean it depends how long the OSs will let you app in tasks bar
e.g memory allocation, doze mode. app buckets, etc
but i think you can get that
listener
from onTerminate or utilize ProcessLifeCycleOwner
d
So you meant there is no official document about this situation? I asked this question because an interviewer asked me, and him said I should figure it out by my self. Then I tested by using a phone which has 8GB RAM but run MIUI, and I open just 1 app, then I leave it 1 minute, then open it again and I saw the app started from beginning. The second I tested using another phone has 8GB RAM but running a pixel_extended ROM(almost the same ROM in google pixel devices) and I saw despite I leaved the app for more than 1 hour and then reopen it, everything(UI, data) are kept.
🤦 1
r
So you meant there is no official document about this situation
about the time afaik is not. but implicit about that there're few docs • https://developer.android.com/topic/performance/vitals/launch-timehttps://developer.android.com/topic/performance/vitals/launch-timehttps://developer.android.com/topic/performance/appstandby
some OSs manufacturers are aggressive, they have opt-in more restrictions than android plain OSs
you can't exactly now within X seconds the OSs will kill your app, it's totally depends the OSs itself by looking few constraints
e.g • memory availability • how many background tasks that you allow • app buckets • doze mode
d
Thank you very much, I’m gonna read all above links
r
you're welcome!
c
Activities aren't killed by themselves. Android will kill a process entirely. How long? Depends on the api level + manufacturer + the system process reaper which reclaims memory when in use. Sounds like the interviewer was being a jerk IMO
😂 1
t
Seems like they’d ask for strategies for dealing with process death instead of wanting some exact duration that isn’t defined. https://developer.android.com/guide/components/activities/process-lifecycle