views:

66

answers:

1

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

+3  A: 

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.

Mayra
+1 for relevant information. Thanks.
MyNameIsZero