I was trying to retrieve the phone number from intent extra through onrecieve() method for the following broadcast receiver registered in manifest file.
<intent-filter>
<action android:name="android.intent.action.PHONE_STATE" />
<action android:name="android.intent.action.NEW_OUTGOING_CALL" />
</intent-filter>
I can successfully able to read the phone number for all the version except android pie upgraded in my pixel 2 device. According to the documentation, app requires additional permission for reading phone number which are READ_CALL_LOG permission and the READ_PHONE_STATE permission but even after allowing these permission I still get missing permission for READ_CALL_LOG therefore I couldn't able to read the phone number. Please help me in resolving this issue.
Make sure you grant READ_PHONE_STATE and READ_CALL_LOG permissions at runtime in Android 6.0+:
https://developer.android.com/distribute/best-practices/develop/runtime-permissions
Also, note that after granting these two permissions, you will receive ACTION_PHONE_STATE_CHANGED broadcast intent action twice; one with the EXTRA_INCOMING_NUMBER populated with the phone number, and another with it blank.
You can find more information here:
https://developer.android.com/reference/android/telephony/TelephonyManager.html#ACTION_PHONE_STATE_CHANGED
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With