【问题标题】:How to check if the dialed number is busy or is not answered?如何查看所拨号码是否占线或无人接听?
【发布时间】:2012-07-10 02:38:35
【问题描述】:

我使用以下代码拨打了一个号码:

DataBaseHelper db;
db=new DataBaseHelper(PanicService.this);
try {

    db.createDataBase();

    } catch (IOException ioe) {

    throw new Error("Unable to create database");

    }

Map<String, String > map= db.TelephoneList();
String[] numbers = new String[]{"number1","number2","number3","number4","number5"};


Intent callIntent = new Intent(Intent.ACTION_CALL);
callIntent.setData(Uri.parse("tel:"+map.get(numbers[0])));
callIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
startActivity(callIntent);

这工作正常。 现在我需要知道拨打的号码是忙还是无人接,它是拨打列表中的下一个号码。我只是想知道是否有办法检测通话状态?

我已经检查了这个 URL http://developer.android.com/reference/android/telephony/TelephonyManager.html,但是除了 CALL_STATE_OFFHOOK 之外我找不到任何关于这个概念的东西,这不是我真正想要的。

【问题讨论】:

    标签: android phone-call telephony telephonymanager


    【解决方案1】:

    您无法确定移动网络上的拨出电话是否已接听,因为移动网络不会向手机提供此信息,即使是,Android 也不提供接收该信息的方式。

    虽然可以确定是否应答了拨出 Internet (SIP) 呼叫,但 Android 目前(从 Jelly Bean 开始)不提供执行此操作的方法,我可以通过快速查看源代码找到该方法。

    【讨论】:

    • 当用户按下挂断键或移动网络断开通话时电话挂断。您可以接收这些事件。
    • 哦,我明白了,那将是 DATA_DISCONNECTED,来自电话经理,对吧?
    • DATA_DISCONNECTED 是指手机的移动数据(3G、4G 等)连接,而不是电话通话。当电话挂断时,将广播 ACTION_PHONE_STATE_CHANGED,并将 EXTRA_STATE 设置为 EXTRA_STATE_IDLE(对应于 CALL_STATE_IDLE)。
    • 电话会收到很多网络相关信息,比如电话是否接听、铃声响了多少次等,但目前还没有我们可以使用的开放 android API
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2020-11-24
    • 2021-11-04
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多