Take the 2-minute tour ×

onCreate method is called every time on Activity whenever screen is rotated. Is it just onCreate being called again or whole activity is re-created?

share|improve this question

2 Answers 2

up vote 6 down vote accepted

It is not just onCreate(). When the screen is rotated, the activity is paused, stopped, and restarted. See this question for more info: Activity lifecycle - onCreate called on every re-orientation

If the question is "Why does this happen?" the answer has to do with functionality inside of Android's activities and windows. More specifically, android currently does not have a way to move, resize, and relayout each and every view when the orientation is changed. To make handling this scenario possible, the simpler implementation of just tearing down the activity and bringing it back up in a different orientation was implemented.

share|improve this answer
Thank you for the answer. Offtopic question: how can I send or save data between activities when screen orientation changes? And there is a twist, it can't be stored in database or file because it has sensative data. –  jM2.me Oct 23 '12 at 6:03
@jM2.me see this question and feel free to post a new question if you have a new specific question stackoverflow.com/questions/151777/… –  spatulamania Oct 24 '12 at 4:29

When the orientation change the onDistroy method will call which indicated the Activity is closed, and again new activity is created with new height and width..

when orientation change all the objects in the Activity class will destroy and when Activity relaunch they will create again, if there is large amount of data it takes more time to load all the data again.. so it is prefer to separate and store all the data in Non Activity class and use in Activity class by creating objects to NonActivity class..

when the orientation change onSaveInstanceState method also called and
by using onSaveInstanceState the data will set or store some values when activity destroy and recreate

    protected void onSaveInstanceState(Bundle icicle) {
      icicle.putLong("param", value);

when activity restarts the on create method call again and this time the Bundle returns the vale which you saved in onSaveInstanceState

public void onCreate(Bundle icicle) {
  if (icicle != null){
    value = icicle.getLong("param");
share|improve this answer
So with onSaveInstanceState I can pass to the new Activity that is being created because of rotation? Can I pass a list from old activity to new using onSaveInstanceState? –  jM2.me Nov 1 '12 at 1:09

Your Answer


