For example, I have an activity named MyActivity
and it doesn't have the function onResume()
.
So basically what would happen if I resume the activity? Will it call the onCreate()
method or something else?
For example, I have an activity named MyActivity
and it doesn't have the function onResume()
.
So basically what would happen if I resume the activity? Will it call the onCreate()
method or something else?
Even if you didn't write the delegate methods like onResume(), onDestroy(), onPause etc.. those standard life cycle methods will meet all the times when you do the respected activity in the screen.
Whenever you need some functionality to be executed in specific delegate then you would need to override the method in your activity screen java file and put your functionality related code inside the overrided method.
You have to understand how the activity life cycle goes.
When you first open the activity A
onCreate is called ====> OnStart is called ====> OnResume is called.
When you return to the activity A (FROM A BACK PRESS).
OnStart is called ====> OnResume is called.
Conclusion
If you don't have (on resume) or (on start) implemented then nothing will happen on create won't be called when your activity is resumed.
If you want to call something when your activity is revisited (from a back press), you must implement your code in (onstart) or (onresume). Because (onCreate) is ignored on activity resumes.
onResume()
is one of the methods called throughout the activity lifecycle. onResume() is the counterpart to onPause()
which is called anytime an activity is hidden from view, e.g. if you start a new activity that hides it. onResume()
is called when the activity that was hidden comes back to view on the screen.