How to know if i am successfully connected to my outgoing number in Android?

為{幸葍}努か 提交于 2019-12-09 17:53:43

问题


Need to know this so that i could send DTMF and that is going to be my second question!


回答1:


You can use the PhoneStateLisenter to listen out for changes in the call state.

So you listen for the LISTEN_CALL_STATE change.

With the onCallStateChanged method.

So when the state changes from RINGING to OFFHOOK you know a phone call has been connected

Same principle applies for IDLE to OFFHOOK in your situation, listen out to the change from IDLE to OFFHOOK and you'll know your connected to a call.

You can also look into the ACTION_NEW_OUTGOING_CALL intent, Android allows you to "trap" this when a call is dialled and you may be able to get a result code back stating whether the call was connected of not.

For DTMF tones look into ToneGenerator, this allows you to create DTMF tones and .startTone() should allow you to play the DTMF tone then.

However you cant send DTMF tones through the uplink.



来源:https://stackoverflow.com/questions/2635945/how-to-know-if-i-am-successfully-connected-to-my-outgoing-number-in-android

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