learntodroid/AndroidQRCodeScanner

App crashing when the permission is already granted

fazy95 opened this issue · 0 comments

The code actually crashes when the permission of accessing the camera is already given. The following functions solved that issue for me. Please make a check before requesting a camera in the onCreate function.
private boolean isCameraPermissionGranted(){
int selfPermission= ContextCompat.checkSelfPermission(getBaseContext(), Manifest.permission.CAMERA);
return selfPermission==PackageManager.PERMISSION_GRANTED;
}