Android application restarts on orientation change

前端 未结 5 876
长发绾君心
长发绾君心 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 07:07

    Android restarts the activities whenever the orientation change by default.

    You will need to save your data/state by calling onSaveInstanceState() before Android destroys the activities.

    Have a look here: Handling Runtime Changes

    This SO question also proves to be a good read in understanding how you could deal with it.

    You could prevent this by adding android:configChanges="orientation" to your activity in AndroidManifest file.

    Source: http://developer.android.com/guide/topics/manifest/activity-element.html#config

提交回复
热议问题