如何识别机器人呼出的振铃状态 [英] How to identify the ringing state of outgoing call in android

查看:195
本文介绍了如何识别机器人呼出的振铃状态的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在我的应用程序,我想找出像等待呼出状态是否,收取或对方拒绝。
 我搜索了很多,这些下面的链接结果
呼出状态 <一个href=\"http://stackoverflow.com/questions/14879603/how-to-detect-answered-or-rejected-state-in-outgoing-call\">How检测应答或拒绝状态呼出,<一个href=\"http://stackoverflow.com/questions/8227223/outgoing-call-information-through-android-broadcastreceiver\">outgoing通过调用Android的广播接收器信息,确定呼出连接事件结果
但是couldn'd找到一个妥善的answer.Plz帮助me.Thanx。

In my app i want to identify whether the outgoing call state like waiting,received or rejected by other side. I searched a lot in these below links
Outgoing call status How to detect answered or rejected state in outgoing call,outgoing call information through android BroadcastReceiver,identify outgoing call connect event
But couldn'd find a proper answer.Plz help me.Thanx.

推荐答案

T 他这个最好的解决办法,是处理广播消息,以确定手机状态。

The best solution for this, is handle broadCast message to identify phone state.

PhoneStateListener 此广播返回错误的结果,并多次致电状态的问题。

using PhoneStateListener for this broadcast returns wrong result and multiple state calling problem.

为什么我们在一个BroadcastReceiver声明监听器,而接收器接收状态改变状态?

Why we declare a listener on a broadcastReceiver while the Receiver receive states on states changing?

要prevent这个问题简单地定义这个类检测电话:

To prevent this issue simply detect call by defining this class:

public class PhoneState extends BroadcastReceiver {

    @Override
    public void onReceive(Context context, Intent intent) {

        state = intent.getStringExtra(TelephonyManager.EXTRA_STATE); 

        if(state.contains(TelephonyManager.EXTRA_STATE_RINGING))
        {
            // Phone is Ringing...  
        }   
        else if(state.contains(TelephonyManager.EXTRA_STATE_OFFHOOK)
        {
            // Call Answered
        }
        else if(state.contains(TelephonyManager.EXTRA_STATE_IDLE))
        {
            // Call is rejected or missed   
        }
    }
}

在这个清单添加到应用程序标记:

in your manifest add this to application tag:

<receiver android:name="receivers.PhoneState" >
        <intent-filter android:priority="2147483647">
            <action android:name="android.intent.action.PHONE_STATE" >
            </action>
        </intent-filter>
</receiver>

最后加入此权限:

and finally add this permission:

<uses-permission android:name="android.permission.READ_PHONE_STATE" />

希望它可以帮助别人

Hope it helps someone

这篇关于如何识别机器人呼出的振铃状态的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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