2

我想在拨打一个号码后查找一些事件,即在目的地端,呼叫被接受或拒绝,或者忙或无法接通。如何在android中找到这些事件。我在 android.TelephonyManager 中找到了一些 API,但那些用于 IN_COMMING_CALL 的。在我拨打号码后,我正在使用 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 的传出调用期间找到这些事件?请帮我

我也使用了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

4

1 回答 1

0

使用PhoneStateListener或观察ACTION_PHONE_STATE_CHANGED广播意图。

于 2011-11-22T13:10:40.190 回答