문제

It seems when screen orientation changes, the activity's onCreate() method is called. In my onCreate() method, I have an AlertDialog which pops up when the activity is called. The problem is when I switch the screen sideways, the popup is displayed again.

How can I avoid this?

도움이 되었습니까?

해결책

Modify your AndroidManifest with:

android:configChanges="orientation|keyboardHidden"

Your Activity should look like this:

<activity android:name=".activities.MyActivity"
                  android:label="@string/my_activity_name"
                  android:configChanges="orientation|keyboardHidden"/>

This will avoid the call to onCreate() when there is a change in the orientation.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top