通过Android的广播接收器呼出信息 [英] outgoing call information through android BroadcastReceiver

查看:245
本文介绍了通过Android的广播接收器呼出信息的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想找到一些事件,我拨了一个号码,即在目标端,呼叫被接受或拒绝,或繁忙或不可达之后。如何找到在Android的这些事件。我被发现android.TelephonyManager一些API的,但那些IN_COMMING_CALL。而且我在使用广播接收器()来查找事件后,我拨打的号码。这块code是,

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***");
        }       
};

我无法找到是接受或拒绝,或忙于目标设备通话。是否有基于API的找到Android的outgoing_call在这些事件的任何网络?请大家帮我

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

我也用PhoneStateListener时,code是

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);
    }
}

但我没有得到关于Outgoing_call事件..
谢谢
希夫

But I am not getting the events on Outgoing_call.. Thanks shiv

推荐答案

使用一个 PhoneStateListener 或观看<一个href=\"http://developer.android.com/reference/android/telephony/TelephonyManager.html#ACTION_PHONE_STATE_CHANGED\"相对=nofollow> ACTION_PHONE_STATE_CHANGED 广播意图。

Use a PhoneStateListener or watch for ACTION_PHONE_STATE_CHANGED broadcast Intents.

这篇关于通过Android的广播接收器呼出信息的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆