How can I play sound when device receive incoming call in android?

瘦欲@ 提交于 2019-12-12 03:08:42

问题


I want to receive incoming call automatically that was I done already now I want to play my own created sound to my caller rather than android will use its default mike..

Can is it possible to play our own sound after receiving incoming call?

I refereed this. Can anyone tell me is it possible now?

I searched lot related to this topic but still I am not able to find something useful.

If anyone know about this then please help me..

Thanks in advance.


回答1:


I found this may be helpful for you

quote from: How to automatically answer call and play prerecorded sound out to the caller and DTMF on Android

"No, sorry, Android has no access to the in-call audio stream. Closest thing is if the device is in speakerphone mode, you can blend your audio into what the speaker plays, which may get picked up by the microphone."




回答2:


As described here (http://www.krvarma.com/2010/08/detecting-incoming-and-outgoing-calls-in-android/), you should be able to detect this:

To detect the incoming call, we register a BroadcastReceiver for the action android.intent.action.PHONE_STATE. This will be broadcasted when there is a change in phone state. The receiving intent will have an extra string variable TelephonyManager.EXTRA_STATE which describes the phone state. If this state is TelephonyManager.EXTRA_STATE_RINGING then there will be another extra string variable TelephonyManager.EXTRA_INCOMING_NUMBER. This variable contains the incoming phone number. Note that this variable will not be present when the state is not TelephonyManager.EXTRA_STATE_RINGING.



来源:https://stackoverflow.com/questions/10012009/how-can-i-play-sound-when-device-receive-incoming-call-in-android

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!