我有以下代碼,並且我已經閱讀了撥出電話當兩方之間的電話連接時,振鈴狀態處於活動狀態,並且其他方可以實際看到您正在呼叫並應答您的呼叫。空閒狀態是當呼叫斷開時,OFF_HOOK狀態是您按下按鈕進行撥號的時刻。我進入OFF_HOOK和IDLE狀態,但無法進入振鈴狀態。可能是什麼問題? 。任何幫助將不勝感激。振鈴狀態撥打電話
public void onReceive(final Context context, Intent intent) {
TelephonyManager Tm=(TelephonyManager)context.getSystemService(Context.TELEPHONY_SERVICE);
Tm.listen(new PhoneStateListener(){
public void onCallStateChanged(int state,String number) {
super.onCallStateChanged(state, number);
switch (state) {
case TelephonyManager.CALL_STATE_IDLE:
//when Idle i.e no call
Toast.makeText(context, "Phone state Idle", 1).show();
break;
case TelephonyManager.CALL_STATE_OFFHOOK:
//when Off hook i.e in call
//Make intent and start your service here
Toast.makeText(context, "Phone state Off hook", 1).show();
break;
case TelephonyManager.CALL_STATE_RINGING:
Toast.makeText(context, "Phone state Ringing", 1).show();
break;
default:
break;
}
}
},PhoneStateListener.LISTEN_CALL_STATE);
所以沒有辦法來檢測時,對方應答了呼叫? – user2137186
正如我所告訴的..有沒有這個公共api ..你可以檢查內部apis .. – stinepike