hey i want to press 1 or 2 during the call. as example when you call a call center and want press 1 key to go to sales department without click this number by your hand, but i want to click it problematically during the Call.
Now i can invoke keypress and handle the call events but it doesn’t work.
PhoneStateListener myCallListener = new PhoneStateListener(){
@Override
public void onCallStateChanged(int state, String incomingNumber) {
// the variable incomingNumber holds the number calling.
// the state variable holds the state of the phone (Ringing, Idle ...)
switch (state) {
case TelephonyManager.CALL_STATE_RINGING:
Log.e("Incoming_call", incomingNumber+" is calling me ...");
break;
case TelephonyManager.CALL_STATE_OFFHOOK:
KeyEvent eventDown = new KeyEvent(KeyEvent.ACTION_DOWN, KeyEvent.KEYCODE_1);
dispatchKeyEvent(eventDown);
// your logic here, right now the incoming caller is logged.
Log.e("Out Call", incomingNumber+" is calling me ...");
break;
default:
break;
}
super.onCallStateChanged(state, incomingNumber);
}
};
TelephonyManager phoneManager = (TelephonyManager)
this.getSystemService(TELEPHONY_SERVICE);
phoneManager.listen(myCallListener,
PhoneStateListener.LISTEN_CALL_STATE);
It’s possible to programmatically make a call, and add DTMF tones and pauses as needed:
It is not possible to decide in the middle of the call to insert DTMF tones into the audio uplink, although it is a requested feature.