Fixed java.lang.NullPointerException: Attempt to invoke virtual method 'android.view.WindowManager android.app.Activity.getWindowManager()' on a null object reference
authorSam Lantinga <slouken@libsdl.org>
Thu, 05 Mar 2020 08:43:16 -0800
changeset 1359135b18e76f1a6
parent 13590 0311c59d15f9
child 13592 3ff45857428d
Fixed java.lang.NullPointerException: Attempt to invoke virtual method 'android.view.WindowManager android.app.Activity.getWindowManager()' on a null object reference
android-project/app/src/main/java/org/libsdl/app/SDLActivity.java
     1.1 --- a/android-project/app/src/main/java/org/libsdl/app/SDLActivity.java	Tue Mar 03 12:31:41 2020 -0500
     1.2 +++ b/android-project/app/src/main/java/org/libsdl/app/SDLActivity.java	Thu Mar 05 08:43:16 2020 -0800
     1.3 @@ -1012,6 +1012,9 @@
     1.4      public static boolean isTablet() {
     1.5          DisplayMetrics metrics = new DisplayMetrics();
     1.6          Activity activity = (Activity)getContext();
     1.7 +        if (activity == null) {
     1.8 +            return false;
     1.9 +        }
    1.10          activity.getWindowManager().getDefaultDisplay().getMetrics(metrics);
    1.11  
    1.12          double dWidthInches = metrics.widthPixels / (double)metrics.xdpi;