Skip to content

Commit 723f5ce

Browse files
committed
Fixed bug #4825 - NullPointerException on SDLActivity.getCurrentOrientation() (Thanks Benau!)
1 parent 1b49f09 commit 723f5ce

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

android-project/app/src/main/java/org/libsdl/app/SDLActivity.java

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -379,11 +379,13 @@ protected void onStart() {
379379
}
380380

381381
public static int getCurrentOrientation() {
382-
final Context context = SDLActivity.getContext();
383-
final Display display = ((WindowManager) context.getSystemService(Context.WINDOW_SERVICE)).getDefaultDisplay();
384-
385382
int result = SDL_ORIENTATION_UNKNOWN;
386383

384+
if (mSingleton == null) {
385+
return result;
386+
}
387+
Display display = SDLActivity.mSingleton.getWindowManager().getDefaultDisplay();
388+
387389
switch (display.getRotation()) {
388390
case Surface.ROTATION_0:
389391
result = SDL_ORIENTATION_PORTRAIT;

0 commit comments

Comments
 (0)