How to know if i am successfully connected to my o

2020-07-11 05:00发布

问题:

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.