Android O : Phone_state Broadcast Limitation
Solution 1:
Eventually, the action was added to the "Implicit Broadcast Exceptions" list so you can add ACTION_PHONE_STATE_CHANGED
to your manifest and it will work:
https://developer.android.com/guide/components/broadcast-exceptions
ACTION_CARRIER_CONFIG_CHANGED, TelephonyIntents.ACTION_*_SUBSCRIPTION_CHANGED, "TelephonyIntents.SECRET_CODE_ACTION", ACTION_PHONE_STATE_CHANGED, ACTION_PHONE_ACCOUNT_REGISTERED, ACTION_PHONE_ACCOUNT_UNREGISTERED
OEM telephony apps may need to receive these broadcasts.
Solution 2:
You have only one solution, use a foreground service and register the broadcast receiver in the service.
Solution 3:
As there is NO proper solution to read the PHONE_STATE from Android O. The best alternative we can go for is to trigger a job on new call log entry from the content provider. By this, the behaviour is maintained of showing a screen(with a few sec of delay) after the call ends.
NOTE : The disadvantage is we cannot get the state of the phone call(Ringing or off_the_hook etc.,). The call back will only be received after the new call log has been added to the System DB.
Solution 4:
For me, and my production app, the solution would be to avoid targeting api 25 and above, until a better workaround/api comes up.
- Getting Error "file Name Must End With .xml" While Using The "android:fontfamily" Of Android O?
- How To Offer Actions Of My App To Other Apps, Via Smart-linkify (aka "smart Text Selection")?
- How To Turn Off Wifi Hotspot Programmatically In Android 8.0 (oreo) (setwifiapenabled Is Not Support This Version Anymore)
If your app targets level 24 or below, you're not affected by the new Implicit Broadcast Limitations and your app can still listen to PHONE_STATE broadcasts even when your app is not running.
An app targeting lower APIs can still be downloaded and installed normally on new Android versions, the only reason to update your sdkTarget value is if your app requires usage of new APIs.
Solution 5:
There seems to be an broadcast exception for ACTION_NEW_OUTGOING_CALL
but not one for incoming call (or when call ends). It seems like a bug to have one for outgoing but not one for incoming. There's been a bug report filed in google issue tracker. Hopefully their answer will clarify what we should be doing.
I'll update this answer if/when the bug tracker gets updated.
Post a Comment for "Android O : Phone_state Broadcast Limitation"