Is it normal for the "activity.onCreate()" method to be called multiple times

MyName picture MyName · Aug 28, 2010 · Viewed 30.8k times · Source

I have some code in the onCreate method an Activity and noticed that it is being called three times. Is it normal behaviour? Thanks.

Answer

Cheryl Simon picture Cheryl Simon · Aug 28, 2010

You might want to read through the documentation on the Activity lifecycle.

OnCreate will only be called one time for each lifetime of the Activity. However, there are a number of situations that can cause your activity to be killed and brought back to life. Thus, onCreate will be called again.

To support this properly, you can save state information in onSaveInstanceState and restore it fron the state bundle you get in on create.