Crash : Requires Android.permission.read_call_log Or Android.permission.write_call_log On Some Devices
Solution 1:
You need to get run time permission in 6.0 > devices
get runtime permission like this:
final String[] NECESSARY_PERMISSIONS = new String[] {Manifest.permission.GET_ACCOUNTS };
if (ContextCompat.checkSelfPermission(DialerHomeActivity.this,
Manifest.permission.GET_ACCOUNTS) == PackageManager.PERMISSION_GRANTED) {
//Permission is granted
} else {
//ask for permission
ActivityCompat.requestPermissions(
DialerHomeActivity.this,
NECESSARY_PERMISSIONS, 123);
}
Solution 2:
Add this to your manifest.xml above <appication>
tag:
<uses-permissionandroid:name="android.permission.READ_CALL_LOG"></uses-permission><uses-permissionandroid:name="android.permission.WRITE_CALL_LOG"></uses-permission>
you can read more at : here
Solution 3:
Issue was that if user already has an app without
<uses-permission android:name="android.permission.READ_CALL_LOG"></uses-permission>
<uses-permission android:name="android.permission.WRITE_CALL_LOG"></uses-permission>
in manifest and gives call permission or phone permission , after update if these are added in update call/phone permission is still their but call log permission is not so you need to ask again. Fresh install was working fine for me
Solution 4:
Have you requested permissions on runtime?
// Here, thisActivity is the current activityif (ContextCompat.checkSelfPermission(thisActivity,
Manifest.permission.READ_CONTACTS)
!= PackageManager.PERMISSION_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, we can request the permission.ActivityCompat.requestPermissions(thisActivity,
newString[]{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.
}
}
Check this:
https://developer.android.com/training/permissions/requesting.html
Solution 5:
I was facing the same problem. Use this code for run time permission:
privatestaticfinalintPHONE_LOG=1;
privatevoidcheckCallLogPermission() {
if (ActivityCompat.checkSelfPermission(this, Manifest.permission.READ_CALL_LOG) != PackageManager.PERMISSION_GRANTED
&& ActivityCompat.checkSelfPermission(this, Manifest.permission.WRITE_CALL_LOG) != PackageManager.PERMISSION_GRANTED) {
ActivityCompat.requestPermissions(this,
newString[]{Manifest.permission.READ_CALL_LOG, Manifest.permission.WRITE_CALL_LOG},PHONE_LOG);
return;
}
}
Post a Comment for "Crash : Requires Android.permission.read_call_log Or Android.permission.write_call_log On Some Devices"