Reputation: 784
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?
Upvotes: 1
Views: 3571
Reputation: 87
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.
Upvotes: 1
Reputation: 7486
onResume()
is called without onStart()
when the activity resumes from the background.
Upvotes: 0
Reputation: 28589
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.
Upvotes: 5
Reputation: 2485
Check below chart:
In case your activity is visible but not active - onPause will be called, and then when you return to this Activity - onResume
Upvotes: 1
Reputation: 1712
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.
Upvotes: 0