Using onCreate vs. onRestoreInstanceState


This method is called after onStart() when the activity is being re-initialized from a previously saved state, given here in savedInstanceState. Most implementations will simply use onCreate(Bundle) to restore their state, but it is sometimes convenient to do it here after all of the initialization has been done or to allow subclasses to decide whether to use your default implementation.

onRestoreInstanceState guarantees you receive a non-null Bundle object also in the lifecycle of activity it’s called after onStart
But onCreate: you should always check if the Bundle object is null or not to determine the configuration change and as you know it’s called before onStart
So It’s all up to you and depends on your needs.

Leave a Comment