Home > Back-end >  Android problems with READ_CALL_LOG permission
Android problems with READ_CALL_LOG permission

Time:10-07

Android 8.1, Java

I am new to this and am making a very basic redial app and I just need to get the last number dialed. To get that number I am using the getLastOutgoingCall which requires the READ_CALL_LOG permission. I requested like this:

if(ActivityCompat.checkSelfPermission(MainActivity.this, Manifest.permission.READ_CALL_LOG) != PackageManager.PERMISSION_GRANTED){
            ActivityCompat.requestPermissions(MainActivity.this, new String[]{Manifest.permission.READ_CALL_LOG}, 100);
        }

Which works if I request other permissions like READ_CONTACT but for some reason the read call log just returns permission denied without even prompting for the permission. How can I correctly get this permission or is there a better way to get the last number dialed?

CodePudding user response:

From the documentation on READ_CALL_LOG

This is a hard restricted permission which cannot be held by an app until the installer on record whitelists the permission. For more details see PackageInstaller.SessionParams.setWhitelistedRestrictedPermissions(Set).

Sounds like your device is set to hard block that permission.

Also, your app is unlikely to be allowed on Google Play. See https://support.google.com/googleplay/android-developer/answer/10208820?hl=en#zippy=,permitted-uses-of-the-sms-and-call-log-permissions,exceptions for the restrictions on that permission. I think you have an argument for it, but it would be up to the whims of the Google people looking at exceptions.

  • Related