android 如何判斷去電或來電已經接通
阿新 • • 發佈:2018-11-15
分享一下我老師大神的人工智慧教程!零基礎,通俗易懂!http://blog.csdn.net/jiangjunshow
也歡迎大家轉載本篇文章。分享知識,造福人民,實現我們中華民族偉大復興!
1、在CallNotifier.java (packages\apps\Phone\src\com\android\phone)中定義一個成員變數private Call.State mLastCallState = Call.State.IDLE;2、在函式onPhoneStateChanged的開始新增程式碼
Call.State ringCallState = mCM.getFirstActiveRingingCall().getState();
Call.State fgCallState = mCM.getActiveFgCallState();
if ((mLastCallState.isRinging() && ringCallState == Call.State.IDLE) || //MT
(mLastCallState.isDialing() && fgCallState == Call.State.ACTIVE)) //MO
{
// 進入這裡意味著電話已經接通,sergeycao一些操作
}
mLastCallState = ringCallState.isRinging() ringCallState:fgCallState;