Android application restarts on orientation change

前端 未结 5 880
长发绾君心
长发绾君心 2020-12-06 06:38

When I change orientation application restarts and I lost my current data.. I am using activity group which contain lots of activities when i change orientation application

5条回答
  •  臣服心动
    2020-12-06 06:51

    There is some good information in the API documentation on why the current Activity gets destroyed and rebuilt. I found it to be very enlightening the last time I worked on something related.

    Unless you specify otherwise, a configuration change (such as a change in screen orientation[...]) will cause your current activity to be destroyed, going through the normal activity lifecycle process of onPause(), onStop(), and onDestroy() as appropriate. If the activity had been in the foreground or visible to the user, once onDestroy() is called in that instance then a new instance of the activity will be created, with whatever savedInstanceState the previous instance had generated from onSaveInstanceState(Bundle).

    http://developer.android.com/reference/android/app/Activity.html#ConfigurationChanges

提交回复
热议问题