views:

142

answers:

1

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

+1  A: 

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

Donal Rafferty
im calling a Voice response system, so i guess it is not ringing? since my log in the RINGING is not showing in the DDMS, but only IDLE to OFFHOOK? and how do i add dtmf tones with it?
mikedroid
I have added additional info to my answer, hope it helps
Donal Rafferty
You cannot "add dtmf tones with it". You cannot play audio into the telephony stream. At best, you can play the DTMF tones on the device, and if the device is in speakerphone mode, those tones *might* get picked up by the microphone.
CommonsWare
hmm so that means ,the only solution in this case is to add them in the setResultData? (well i did this and IVR can recognize it)
mikedroid
Using an intent as follows may work also: - Intent mIntent = new Intent(Intent.ACTION_CALL, Uri.parse("tel:" +phoneNumber + ";" + dtmfSequence));
Donal Rafferty
just the same as setting in the setResultData, i guess that is the only solution! coz my boss wants to know to send dtmf after i got connected to the IVR...
mikedroid
For now it is yes, There was a comment on the google groups about support for sending dtmf tones during a voice call in future upgrades from a Google developer
Donal Rafferty
yes i guess i've read that somewhere also hehehe, well thanks for the responses @markmurphy and @donal!
mikedroid