如何获得呼出的Andr​​oid正在回答 [英] How to get outgoing call is answered in Android

查看:110
本文介绍了如何获得呼出的Andr​​oid正在回答的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要一种方法时,呼出的awnsered获得的状态。然而,在国家OFFHOOK我也使用呼吁呼出(ACTION_CALL)。我怎么能不重写呼出活动添加awnsered状态?

I need a way to get the the status when a outgoing call is awnsered. However, in the OFFHOOK state I am also using to call for the outgoing call(ACTION_CALL). How can I add the awnsered state without overriding the outgoing call activity?

public class OutgoingBroadcastReceiver extends BroadcastReceiver {

private Intent mIntent;
private String phonenumber = null;
public static boolean wasRinging;

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

    MyPhoneStateListener phoneListener = new MyPhoneStateListener(context);
    TelephonyManager telephony = (TelephonyManager) context
            .getSystemService(Context.TELEPHONY_SERVICE);
    telephony.listen(phoneListener, PhoneStateListener.LISTEN_CALL_STATE);

    phonenumber = intent.getStringExtra(Intent.EXTRA_PHONE_NUMBER);

}

public class MyPhoneStateListener extends PhoneStateListener {
    private final Context context;

    public MyPhoneStateListener(Context context) {
        this.context = context;

    }

    @Override
    public void onCallStateChanged(int state, String incomingNumber) {


        switch (state) {

        case TelephonyManager.CALL_STATE_IDLE: 

            wasRinging = true;
            break;

        case TelephonyManager.CALL_STATE_OFFHOOK:

                Log.e("%%%%%%%%%%%%%%%%%%%%%%%%%%%t", "OFFHOOK");
            if (UIUDialer.isOutgoingCall() == true) {

                //Do my work when outgoing call is detected
            } 

            else if (!wasRinging)
            {

                    Log.e("%%%%%%%%%%%%%%%%%%%%%%%%%%%t", "WASRINGING");
                //Do my work when outgoing call is awnsered

            }



            context.sendBroadcast(new Intent("finish_incoming"));
            wasRinging = true;
            break;

        case TelephonyManager.CALL_STATE_RINGING:

            wasRinging = true;
            break;
        }
    }

}

}

推荐答案

有可对此没有公开的API。

There is no public API available for this.

这篇关于如何获得呼出的Andr​​oid正在回答的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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