[英]click on key during the Call on android
hey i want to press 1 or 2 during the call. 嘿,我想在通话中按1或2。 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.
例如,当您致电呼叫中心并希望按1键进入销售部门而无需用手单击此号码时,但我想在通话过程中有问题地单击它。
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: 可以通过编程方式拨打电话,并根据需要添加DTMF音调和暂停:
Intent i = new Intent("android.intent.action.CALL",Uri.parse("tel://" + number + ',' + dtmf));
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 . 尽管这是一项请求的功能 ,但无法在通话过程中决定将DTMF音调插入音频上行链路。
Your code is going to generate a key down event for your activity, not for the Phone application. 您的代码将为您的活动而非电话应用程序生成按键事件。
As far as I know, it is impossible to achieve what you want, but I could be wrong. 据我所知,不可能实现您想要的,但是我可能是错的。 However, if it was possible, it's a potential issue, as any application could then send any touchtones during a phone call and trigger bad things without the user be aware.
但是,如果可能的话,这是一个潜在的问题,因为任何应用程序都可以在通话过程中发送任何按键音,并在用户不知情的情况下触发不良情况。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.