在摘机状态下处理呼叫等待

时间:2015-02-19 10:07:42

标签: android phone-state-listener

我正在制作一个监听来电的应用。当我通过识别PhoneStateListener中的当前状态和先前状态来调用或接听电话(传出和传入)时,该应用程序正常工作。

例如,当前一状态为TelephonyManager.CALL_STATE_IDLE且新状态为TelephonyManager.CALL_STATE_OFFHOOK时,则表示是拨出电话。

如果Previous状态为TelephonyManager.CALL_STATE_RINGING且新状态为TelephonyManager.CALL_STATE_OFFHOOK,则为来电。

如果之前的状态为TelephonyManager.CALL_STATE_RINGING而新状态为TelephonyManager.CALL_STATE_IDLE,则肯定是未接来电。

现在问题来了,当我需要处理呼叫等待时。我这里有两个场景。第一个是当用户没有接听电话而等待的电话成为未接来电时。另一种情况是用户通过将当前呼叫置于保持状态来挂起新呼叫,挂起新呼叫并选择保持呼叫。问题是我在两个场景中都获得相同的状态,即使呼叫号码相同。这是状态的变化 -

(Numbers have been changed for privacy reasons)
OFFHOOK. Number = 123456 //Dials an outgoing call
RINGING. Number = 654321 //Gets a new call while on call
OFFHOOK. Number = 654321 //Rejects the new incoming call. Why it shows the new incoming number while the call is offhook with the outgoing call.
IDLE. Number = 123456 //Ends the outgoing call

OFFHOOK. Number = 123456 //Dials an outgoing call
RINGING. Number = 654321 //Gets a new call while on call
OFFHOOK. Number = 654321 //Accepts the new incoming call
//Hanging the incoming call has no events surprisingly
IDLE. Number = 123456 //Ends the outgoing call

所以我的问题是,有什么方法可以在通话时识别这两种情况。我知道有一种方法可以通过在通话结束后检查通话记录来完成,但我需要在通话时这样做。

0 个答案:

没有答案