通过android BroadcastReceiver呼出电话信息
我想在拨打号码后找到一些事件,即在目的地侧,呼叫被接受或拒绝或占线或无法接通。如何在android中找到这些事件。我在 android.TelephonyManager 中找到了一些 API,但是那些用于 IN_COMMING_CALL 的 API。我正在使用 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 上的事件.. 谢谢 刀刃
I want to find some events after I dialed for a number, i.e at the destination side, the call is accepted or rejected or busy or not-reachable. How to find these events in android. I got found some API's in android.TelephonyManager but those for IN_COMMING_CALL. And I am using BroadcastReceiver() to find events after i dialed for number. the piece of code is,
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***");
}
};
I am unable to find the call is accepted or rejected or busy at destination device. are there any network based API's to find these events during outgoing_call in android? please help me
also I used PhoneStateListener, the code is
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);
}
}
But I am not getting the events on Outgoing_call..
Thanks
shiv
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
使用 PhoneStateListener 或监视 ACTION_PHONE_STATE_CHANGED广播意图。
Use a PhoneStateListener or watch for ACTION_PHONE_STATE_CHANGED broadcast Intents.