Need to know this so that i could send DTMF and that is going to be my second question!
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.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With