diff --git a/android/src/main/java/com/captureprotection/CaptureProtectionModule.java b/android/src/main/java/com/captureprotection/CaptureProtectionModule.java index 4089492..edcce43 100644 --- a/android/src/main/java/com/captureprotection/CaptureProtectionModule.java +++ b/android/src/main/java/com/captureprotection/CaptureProtectionModule.java @@ -208,17 +208,22 @@ private boolean requestStoragePermission() { return true; } - String requestPermission = Build.VERSION.SDK_INT >= 33 // Build.VERSION_CODES.TIRAMISU - ? "android.permission.READ_MEDIA_IMAGES" // Manifest.permission.READ_MEDIA_IMAGES - : Manifest.permission.READ_EXTERNAL_STORAGE; - - if (ContextCompat.checkSelfPermission(getCurrentActivity(), - requestPermission) == PackageManager.PERMISSION_GRANTED) { - Log.d(NAME, "Permission is granted"); - return true; - } else { - Log.d(NAME, "Permission is revoked"); - ActivityCompat.requestPermissions(getCurrentActivity(), new String[] { requestPermission }, 1); + try { + String requestPermission = Build.VERSION.SDK_INT >= 33 // Build.VERSION_CODES.TIRAMISU + ? "android.permission.READ_MEDIA_IMAGES" // Manifest.permission.READ_MEDIA_IMAGES + : Manifest.permission.READ_EXTERNAL_STORAGE; + + if (ContextCompat.checkSelfPermission(getCurrentActivity(), + requestPermission) == PackageManager.PERMISSION_GRANTED) { + Log.d(NAME, "Permission is granted"); + return true; + } else { + Log.d(NAME, "Permission is revoked"); + ActivityCompat.requestPermissions(getCurrentActivity(), new String[] { requestPermission }, 1); + return false; + } + } catch (Exception e) { + Log.e(NAME, "requestStoragePermission has raise Exception: " + e.getLocalizedMessage()); return false; } } diff --git a/package.json b/package.json index 02de675..df5e1d3 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "react-native-capture-protection", - "version": "1.9.6", + "version": "1.9.7", "description": "It’s a library for React Native to control simple capture events(i.e. Screenshot or Screen record)", "main": "lib/commonjs/index", "module": "lib/module/index",