2
我想要查找一些事件後,我撥打一個號碼,即在目的地方,呼叫被接受或拒絕或忙或不可達。如何在android中找到這些事件。我在android.TelephonyManager中發現了一些API,但在IN_COMMING_CALL中發現了一些。我使用BroadcastReceiver()查找撥打號碼後的事件。這段代碼是通過android BroadcastReceiver傳出的呼叫信息
public void onReceive(Context context, Intent intent) {
System.out.println("before if condition");
if (intent.getAction().equals(Intent.ACTION_NEW_OUTGOING_CALL)) {
System.out.println("**outgoingcall***");
}
};
我無法找到呼叫被接受或拒絕或在目標設備繁忙。有沒有任何基於網絡的API來在android的outgoing_call期間找到這些事件?請幫我
也是我用PhoneStateListener,代碼
private class ListenToPhoneState extends PhoneStateListener {
public void onCallStateChanged(int state, String incomingNumber) {
Log.i("telephony-example", "State changed: " + stateName(state));
}
String stateName(int state) {
switch (state) {
case TelephonyManager.CALL_STATE_IDLE:
System.out.println("phone is idle****");
break;
case TelephonyManager.CALL_STATE_OFFHOOK:
System.out.println("phone is offhook****");
break;
case TelephonyManager.CALL_STATE_RINGING:
System.out.println("phone is Ringing***");
break;
}
return Integer.toString(state);
}
}
但我沒有得到關於Outgoing_call事件.. 感謝 SHIV
非常感謝hovanessyan。我的代碼與ACTION_PHONE_STATE_CHANGED API一起工作正常。 – Shiv
@Shiv,我的問題就像你的問題,你如何解決,在哪個行動註冊您的接收器顯示 –