通过android BroadcastReceiver呼出电话信息

发布于 2024-12-17 08:11:32 字数 1359 浏览 3 评论 0原文

我想在拨打号码后找到一些事件,即在目的地侧,呼叫被接受或拒绝或占线或无法接通。如何在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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

拥抱影子 2024-12-24 08:11:32

使用 PhoneStateListener 或监视 ACTION_PHONE_STATE_CHANGED广播意图。

Use a PhoneStateListener or watch for ACTION_PHONE_STATE_CHANGED broadcast Intents.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文