diff --git a/java/com/drbeef/jkxr/GLES3JNIActivity.java b/java/com/drbeef/jkxr/GLES3JNIActivity.java index d17ea73..54b1dd6 100644 --- a/java/com/drbeef/jkxr/GLES3JNIActivity.java +++ b/java/com/drbeef/jkxr/GLES3JNIActivity.java @@ -89,7 +89,7 @@ import java.util.Vector; private static final String APPLICATION = "JKXR"; - private int permissionCount = 0; + private boolean permissionsGranted = false; private static final int READ_EXTERNAL_STORAGE_PERMISSION_ID = 1; private static final int WRITE_EXTERNAL_STORAGE_PERMISSION_ID = 2; @@ -160,26 +160,19 @@ import java.util.Vector; GLES3JNIActivity.this, new String[] {Manifest.permission.WRITE_EXTERNAL_STORAGE}, WRITE_EXTERNAL_STORAGE_PERMISSION_ID); - } - else - { - permissionCount++; - } - - if (ContextCompat.checkSelfPermission(this, Manifest.permission.READ_EXTERNAL_STORAGE) - != PackageManager.PERMISSION_GRANTED) - { - ActivityCompat.requestPermissions( - GLES3JNIActivity.this, + } else if (ContextCompat.checkSelfPermission(this, Manifest.permission.READ_EXTERNAL_STORAGE) + != PackageManager.PERMISSION_GRANTED){ + ActivityCompat.requestPermissions( + GLES3JNIActivity.this, new String[] {Manifest.permission.READ_EXTERNAL_STORAGE}, READ_EXTERNAL_STORAGE_PERMISSION_ID); - } + } else { - permissionCount++; + permissionsGranted = true; } - if (permissionCount == 2) { + if (permissionsGranted) { // Permissions have already been granted. create(); } @@ -189,21 +182,13 @@ import java.util.Vector; @Override public void onRequestPermissionsResult(int requestCode, String[] permissions, int[] results) { if (requestCode == READ_EXTERNAL_STORAGE_PERMISSION_ID) { - if (results.length > 0 && results[0] == PackageManager.PERMISSION_GRANTED) { - permissionCount++; - } - else - { + if (results.length > 0 && results[0] != PackageManager.PERMISSION_GRANTED) { System.exit(0); } } if (requestCode == WRITE_EXTERNAL_STORAGE_PERMISSION_ID) { - if (results.length > 0 && results[0] == PackageManager.PERMISSION_GRANTED) { - permissionCount++; - } - else - { + if (results.length > 0 && results[0] != PackageManager.PERMISSION_GRANTED) { System.exit(0); } }