views:

288

answers:

1

I have tried to freeze orientation

setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);

but thought screen stays in portrait orientation, the activity is still recreated. Any ideas how to solve this?

+1  A: 

First, don't use setRequestedOrientation() if you can avoid it. Use the android:screenOrientation attribute in your <activity> manifest element instead.

Second, you will also need android:configChanges="keyboardHidden|orientation" in your <activity> manifest element to prevent the destroy/recreate cycle.

CommonsWare