From c93bc9784b073382a8c30995387a6ab95ff95ffa Mon Sep 17 00:00:00 2001 From: Evan Debenham Date: Mon, 5 Aug 2019 13:24:19 -0400 Subject: [PATCH] v0.7.4b: fixed failing to launch in landscape on some android phones --- .../shatteredpixeldungeon/android/AndroidLauncher.java | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/android/src/main/java/com/shatteredpixel/shatteredpixeldungeon/android/AndroidLauncher.java b/android/src/main/java/com/shatteredpixel/shatteredpixeldungeon/android/AndroidLauncher.java index 9feaa1809..a7f22a5c0 100644 --- a/android/src/main/java/com/shatteredpixel/shatteredpixeldungeon/android/AndroidLauncher.java +++ b/android/src/main/java/com/shatteredpixel/shatteredpixeldungeon/android/AndroidLauncher.java @@ -22,6 +22,7 @@ package com.shatteredpixel.shatteredpixeldungeon.android; import android.app.Activity; +import android.content.pm.ActivityInfo; import android.content.pm.PackageManager; import android.opengl.GLSurfaceView; import android.os.Build; @@ -59,6 +60,15 @@ public class AndroidLauncher extends AndroidApplication { Game.versionCode = 0; } + //set desired orientation (if it exists) before initializing the app. + if (getPreferences("ShatteredPixelDungeon").contains("landscape")) { + if (getPreferences("ShatteredPixelDungeon").getBoolean("landscape")){ + instance.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_SENSOR_LANDSCAPE); + } else { + instance.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_SENSOR_PORTRAIT); + } + } + AndroidApplicationConfiguration config = new AndroidApplicationConfiguration(); config.depth = 0; if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) {