如何知道的那一刻,当被呼叫的人拿起他的电话 [英] How to know the moment when the called person picks up his phone
本文介绍了如何知道的那一刻,当被呼叫的人拿起他的电话的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
可能重复:
<一href="http://stackoverflow.com/questions/2250455/detect-if-an-outgoing-call-has-been-answered">Detect如果传出的电话已经接
如何才能知道的那一刻,当我打电话的人拿起他的电话?
How can I know the moment when the person I call "picks up" his phone?
推荐答案
使用 PhoneStateListener
。当他们'拿起'的电话时,状态更改为 CALL_STATE_OFFHOOK
。
Using PhoneStateListener
. When they 'pick up' the phone, the state changes to CALL_STATE_OFFHOOK
.
TelephonyManager tm = (TelephonyManager)getSystemService(TELEPHONY_SERVICE);
tm.listen(mPhoneListener, PhoneStateListener.LISTEN_CALL_STATE);
private PhoneStateListener mPhoneListener = new PhoneStateListener() {
public void onCallStateChanged(int state, String incomingNumber) {
try {
switch (state) {
case TelephonyManager.CALL_STATE_RINGING:
// do something...
break;
case TelephonyManager.CALL_STATE_OFFHOOK:
// this state is the one you're looking for
break;
case TelephonyManager.CALL_STATE_IDLE:
// do something...
break;
default:
Log.d(TAG, "Unknown phone state=" + state);
}
} catch (RemoteException e) {}
}
};
这篇关于如何知道的那一刻,当被呼叫的人拿起他的电话的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文