Possible Duplicate:
Difference between onCreate() and onStart()?
Android Activity Life Cycle - What are all these methods for?
What is the difference between OnCreate and OnStart?
My understanding is that OnCreate is only called the very first time the application is opened and is never called again. Is this true? Can someone please elaborate in their own words rather than copying and pasting a definition? Thank you!
Android App Development for BeginnersonCreate() is called when the when the activity is first created. onStart() is called when the activity is becoming visible to the user.
In your activity onCreate() is called before onStart(), but in your onCreate() method you only add the childEventListener, while the event onChildAdded only occurs after onStart() is called, and that's what you see in the logs. This is indeed what is happening.
onStart() -> called when the activity becomes visible, but might not be in the foreground (e.g. an AlertFragment is on top or any other possible use case). onResume() -> called when the activity is in the foreground, or the user can interact with the Activity.
It is mandatory to implement onCreate() in our activity. onStart() can be called multiple times. It is not mandatory to implement onStart() .
As long as your device does not kill the activity, for example due to low system resources, then any time you leave your app and go back, onStart is called. If however the application process is killed, then when you return onCreate will be called again, because all of your resources will have been released.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With