linphone的拨号键盘功能设置在org.linphone.ui.Digit类中通过 DialKeyListener()方法获取每个键盘的text,而不是通过id值。
DialKeyListener() {
mKeyCode = Digit.this.getText().subSequence(0, 1).charAt(0);
}
通过onTouch()方法发送拨号键盘的每个按键的功能
public boolean onTouch(View v, MotionEvent event) {
if (!mPlayDtmf) return false;
if (!linphoneServiceReady()) return true;
if (InCallActivity.isInstanciated()) {
InCallActivity.instance().resetControlsHidingCallBack();
}
//LinphoneCore lc = LinphoneManager.getLc();
if (event.getAction() == MotionEvent.ACTION_DOWN && !mIsDtmfStarted) {
keyBoard12(mKeyCode);
mIsDtmfStarted = true;
} else {
if (event.getAction() == MotionEvent.ACTION_UP) {
stopDtmf();
mIsDtmfStarted = false;
}
}
return false;
}
public void keyBoard12(char mKeyCode){
LinphoneManager.getInstance().playDtmf(getContext().getContentResolver(), mKeyCode);
}
public void stopDtmf(){
LinphoneCore lc = LinphoneManager.getLc();
lc.stopDtmf();
}
text框通过onClick()获取按下拨号键盘的值
public void onClick(View v) {
if (mPlayDtmf) {
if (!linphoneServiceReady()) return;
LinphoneCore lc = LinphoneManager.getLc();
lc.stopDtmf();
mIsDtmfStarted =false;
if (lc.isIncall()) {
lc.sendDtmf(mKeyCode);
}
}
if (mAddress != null) {//拨号键盘的值获取到mAddress
int lBegin = mAddress.getSelectionStart();
if (lBegin == -1) {
lBegin = mAddress.length();
}
if (lBegin >= 0) {
mAddress.getEditableText().insert(lBegin,String.valueOf(mKeyCode));
}
}
}