androidphone-state-listener

Not receiving PHONE_STATE broadcast on Android P devices


This works on all pre-Android P versions and in the Android P emulator, does not on devices with Android P (tested on Xiomi Android P preview1, Nokia 7 plus DP3 and Pixel 2 DP4) any ideas why this could be?

I have the receiver declared in my manifest:

<receiver android:name="com.myap.PhoneCallReceiver">
            <intent-filter android:priority="2147483647">
                <action android:name="android.intent.action.PHONE_STATE"/>
            </intent-filter>
        </receiver>-

I also have the permissions:

<uses-permission android:name="android.permission.READ_CALL_LOG"/>
<uses-permission android:name="android.permission.ANSWER_PHONE_CALLS" />
<uses-permission android:name="android.permission.READ_CONTACTS"/>

In my class PhoneCallReceiver onReceive is never called on those devices, but it is in Emulator with Android P and pre Android P devices.


Solution

  • The problem was the app being used to "fake" the call to the device was not triggering the broadcast, despite the phones were ringing and actually reciving a call, directly calling the device with another device worked.