diff --git a/AndroidManifest.xml b/AndroidManifest.xml index 7b4a40f8e..dc2aac11a 100644 --- a/AndroidManifest.xml +++ b/AndroidManifest.xml @@ -29,7 +29,7 @@ android:label="@string/app_name" android:name=".ShatteredPixelDungeon" android:configChanges="keyboardHidden|orientation|screenSize" - android:screenOrientation="portrait"> + android:screenOrientation="sensorPortrait"> diff --git a/src/com/shatteredpixel/shatteredpixeldungeon/ShatteredPixelDungeon.java b/src/com/shatteredpixel/shatteredpixeldungeon/ShatteredPixelDungeon.java index 8b79f0a54..3a90494c8 100644 --- a/src/com/shatteredpixel/shatteredpixeldungeon/ShatteredPixelDungeon.java +++ b/src/com/shatteredpixel/shatteredpixeldungeon/ShatteredPixelDungeon.java @@ -207,9 +207,15 @@ public class ShatteredPixelDungeon extends Game { */ public static void landscape( boolean value ) { - Game.instance.setRequestedOrientation( value ? - ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE : - ActivityInfo.SCREEN_ORIENTATION_PORTRAIT ); + if (android.os.Build.VERSION.SDK_INT >= 9) { + Game.instance.setRequestedOrientation(value ? + ActivityInfo.SCREEN_ORIENTATION_SENSOR_LANDSCAPE : + ActivityInfo.SCREEN_ORIENTATION_SENSOR_PORTRAIT); + } else { + Game.instance.setRequestedOrientation(value ? + ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE : + ActivityInfo.SCREEN_ORIENTATION_PORTRAIT); + } Preferences.INSTANCE.put( Preferences.KEY_LANDSCAPE, value ); }