diff --git a/android-project/app/src/main/java/org/libsdl/app/SDLActivity.java b/android-project/app/src/main/java/org/libsdl/app/SDLActivity.java index 09cafc557..fc6c5ad23 100644 --- a/android-project/app/src/main/java/org/libsdl/app/SDLActivity.java +++ b/android-project/app/src/main/java/org/libsdl/app/SDLActivity.java @@ -260,6 +260,7 @@ public class SDLActivity extends Activity implements View.OnSystemUiVisibilityCh // Get our current screen orientation and pass it down. mCurrentOrientation = SDLActivity.getCurrentOrientation(); + // FIXME: with only one activity, SDL Thread is not yet started and this onNativeOrientationChanged() is ignored SDLActivity.onNativeOrientationChanged(mCurrentOrientation); setContentView(mLayout); diff --git a/src/core/android/SDL_android.c b/src/core/android/SDL_android.c index 8613d4565..96bab018c 100644 --- a/src/core/android/SDL_android.c +++ b/src/core/android/SDL_android.c @@ -583,8 +583,11 @@ JNIEXPORT void JNICALL SDL_JAVA_INTERFACE(onNativeOrientationChanged)( JNIEnv *env, jclass jcls, jint orientation) { - SDL_VideoDisplay *display = SDL_GetDisplay(0); - SDL_SendDisplayEvent(display, SDL_DISPLAYEVENT_ORIENTATION, orientation); + SDL_VideoDevice *_this = SDL_GetVideoDevice(); + if (_this) { + SDL_VideoDisplay *display = SDL_GetDisplay(0); + SDL_SendDisplayEvent(display, SDL_DISPLAYEVENT_ORIENTATION, orientation); + } } /* Paddown */