Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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

like image 768
Mikey Avatar asked Apr 14 '10 08:04

Mikey


People also ask

How do I find incoming and outgoing calls on Android?

Detecting incoming and outgoing calls in Android can be realized in several ways. One of the possibilities is to use a custom PhoneStateListener which can be attached to the TelephonyManager in your onReceive() function of the custom BroadcastReceiver.


1 Answers

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.

like image 147
Donal Rafferty Avatar answered Oct 23 '22 11:10

Donal Rafferty