I am working on Android application that needs to be notified when phone receives a call. I use approach with BroadcastReceiver since I want to get notification about incoming call even when application is not active. Therefore, approach with using TelephonyManager and PhoneStateListener does not suit my needs. So, my application has appropriate permission in manifest:
<uses-permission android:name="android.permission.READ_PHONE_STATE"/>
It also properly registers broadcast receiver in manifest:
<receiver android:enabled="true" android:name=".CallReceiver" >
<intent-filter>
<action android:name="android.intent.action.PHONE_STATE" />
</intent-filter>
</receiver>
Class CallReceiver implements BroadcastReceiver, but once I start application, its method onReceive of CallReceiver never gets invoked the is never invoked. Reason for this is that system denies to deliver Intent to my broadcast receiver, as I found following messages in log each time phone rings:
W/BroadcastQueue: Permission Denial: receiving Intent { act=android.intent.action.PHONE_STATE flg=0x10 (has extras) } to com.example.incomingcall/.CallReceiver requires android.permission.READ_PRIVILEGED_PHONE_STATE due to sender android (uid 1000)
W/BroadcastQueue: Permission Denial: receiving Intent { act=android.intent.action.PHONE_STATE flg=0x10 (has extras) } to com.example.incomingcall/.CallReceiver requires android.permission.READ_PHONE_STATE due to sender android (uid 1000)
As I explained, I already put READ_PHONE_STATE permission in the manifest, while other permission specified here is system permission that can't be placed into the manifest. Any ideas how to overcome this problem? Device on which this appears in Nexus 6p with Android 6.0.1