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,我的问题就像你的问题,你如何解决,在哪个行动注册您的接收器显示 –