Question

I have read documentation on onResume() and onStart() but one thing I'm still not cleared is under what scenario does onResume() get called without onStart() being called before it?

Was it helpful?

Solution

Please Refer to the Android Activity Lifecycle Documentation.

onStart is called when your application first starts.

If the user click the home button, or another app takes focus, onPause will be called.

If the activity regains focus, while stil running on the device, onResume will be called, and onCreate will NOT be called again.

If the user uses the activity manager to close the application, and then relaunches it, onCreate will be called again.

Note, every time onCreate is called, onResume is also called.

Lifecycle

OTHER TIPS

Check below chart:

Activity lifecycle

In case your activity is visible but not active - onPause will be called, and then when you return to this Activity - onResume

One such scenario where onResume() is called without onStart() being called is change of Focus. Think about a dialog popping up on the screen while you're using the application. This is the case when onPause() is called, followed by onResume() after dismissal of dialog.

onStart() gets called once each time the app is launched and is actually called after oncreate()

onResume() gets called instead if the app is already running, just in the background.

if you use onPause(), on Resume will likely get called when you bring your app up again, basically onResume() is a reusable onStart() for when the app is already started.

onResume can sometimes be called when switching activities, onStart only gets called when creating one.

onResume() is called without onStart() when the activity resumes from the background.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top