Android Camera Crashing for some Devices requestPermission()

The root problem I have is that the Android Cordova Camera is crashing on some devices. It works on the Appery tester but fails in the publish application for these devices.

I think I have traced the problem to the the Crodova Plugin writing a temp file of the photo, but the app hasn't requested permission for writing to external storage.

I am trying to determine if I have a permission and then request permission manually to write to external storage.

I got this from developer.Adroid.com but the system crashes when it hits ContextCompat and ActivityCompat.

How do I solve this problem.

// Here, thisActivity is the current activity
if (ContextCompat.checkSelfPermission(thisActivity,
Manifest.permission.READ_CONTACTS)
!= PackageManager.PERMISSION_GRANTED) {

// Permission is not granted
// Should we show an explanation?
if (ActivityCompat.shouldShowRequestPermissionRationale(thisActivity,
Manifest.permission.READ_CONTACTS)) {
// Show an explanation to the user *asynchronously* -- don't block
// this thread waiting for the user's response! After the user
// sees the explanation, try again to request the permission.
} else {
// No explanation needed; request the permission
ActivityCompat.requestPermissions(thisActivity,
new String[]{Manifest.permission.READ_CONTACTS},
MY_PERMISSIONS_REQUEST_READ_CONTACTS);

// MY_PERMISSIONS_REQUEST_READ_CONTACTS is an
// app-defined int constant. The callback method gets the
// result of the request.
}
} else {
// Permission has already been granted
}
1 person has
this problem
+1
Reply