Listen incoming calls through BroadcastReceiver, without PhoneStateIntentReceiver or PhoneStateListener

后端 未结 2 1217
面向向阳花
面向向阳花 2021-01-31 23:41

Is there any way to listen to incoming calls by extending BroadcastReceiver to listen to OS\'s broadcast,without using PhoneStateIntentReceiver or PhoneStateListener. Also pleas

2条回答
  •  南旧
    南旧 (楼主)
    2021-02-01 00:13

    The action you have defined in your manifest is incorrect. this is an Action Intent that can be used to answer a call and not monitor incoming calls.

    You can use two broadcast receivers that listen to ACTION_PHONE_STATE_CHANGED and NEW_OUTGOING_CALL broadcast intents.

    The ACTION_PHONE_STATE_CHANGED will be received when there is a new incoming call, call answered or hangup (See the documentation for the EXTRAs received with this Intent).

    The NEW_OUTGOING_CALL will be received when there is a new outgoing call placed on your device.

    As for permissions, I think you got it about right in your manifest (I assume the RECORD_AUDIO permission is used for something else in your application)

提交回复
热议问题