[英]How to know if i am successfully connected to my outgoing number in Android?
需要知道这一点,以便我可以发送 DTMF,这将是我的第二个问题!
You can use the PhoneStateLisenter to listen out for changes in the call state.您可以使用PhoneStateLisenter来监听呼叫状态的变化。
So you listen for the LISTEN_CALL_STATE change.所以你听听LISTEN_CALL_STATE的变化。
With the onCallStateChanged method.使用onCallStateChanged方法。
So when the state changes from RINGING to OFFHOOK you know a phone call has been connected因此,当状态从 RINGING 变为 OFFHOOK 时,您就知道电话已接通
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.在您的情况下,IDLE 到 OFFHOOK 也适用相同的原则,听从 IDLE 到 OFFHOOK 的变化,您就会知道您已接通电话。
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 or not.您还可以查看 ACTION_NEW_OUTGOING_CALL 意图,Android 允许您在拨打电话时“捕获”它,并且您可能能够返回结果代码,说明呼叫是否已连接。
For DTMF tones look into ToneGenerator, this allows you to create DTMF tones and .startTone() should allow you to play the DTMF tone then.对于 DTMF 音,请查看 ToneGenerator,这允许您创建 DTMF 音,然后 .startTone() 应该允许您播放 DTMF 音。
However you cant send DTMF tones through the uplink.但是,您不能通过上行链路发送 DTMF 音。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.