Reputation: 2877
How to listen Phone calls for Android version Oreo onward limits for background service. Looking for working examples.
Note: Application may not be in foreground state.
Upvotes: 0
Views: 774
Reputation: 2877
Found the solution !
Actually action android:name="android.intent.action.PHONE_STATE" is a part of implicit broadcast exceptions, so shouldn't have any issues registering broadcast receiver. It will still work.
I was missing permission android.permission.ANSWER_PHONE_CALLS while asking other two permissions 1)READ_PHONE_STATE and 2) CALL_PHONE at run time, declaring in manifest was not enough.
We must have to include all below permissions in manifest file as well as asking permissions at run-time 1) android.permission.READ_PHONE_STATE 2) android.permission.CALL_PHONE 3) android.permission.ANSWER_PHONE_CALLS [this is important, and needed for Android 8.0 Oreo (API 26+)]
Upvotes: 3