Skip to content Skip to sidebar Skip to footer

Crash : Requires Android.permission.READ_CALL_LOG Or Android.permission.WRITE_CALL_LOG On Some Devices

I have made an app that tracks call log in background using ContentObserver and service(runs in foreground). Manifest.permission.CALL_PHONE This is the permission i am checking for

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-permission android:name="android.permission.READ_CALL_LOG"></uses-permission>
<uses-permission android: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 activity
if (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,
            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.
}

}

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:

private static final int PHONE_LOG = 1;

private void checkCallLogPermission() {

    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,
                new String[]{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"