Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

OnCreate() vs OnStart() [duplicate]

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!

like image 608
Josh Beckwith Avatar asked Sep 17 '12 23:09

Josh Beckwith


People also ask

What is the difference between onCreate () and onStart?

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.

Is onStart before onCreate?

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.

What is difference between onStart and onResume?

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.

Is it mandatory to implement onCreate and onStart () in android?

It is mandatory to implement onCreate() in our activity. onStart() can be called multiple times. It is not mandatory to implement onStart() .


1 Answers

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.

like image 69
DaveJohnston Avatar answered Oct 10 '22 00:10

DaveJohnston