如何在电话管理器中查找传出号码 [英] how to find outgoing number in Telephony manager

查看:110
本文介绍了如何在电话管理器中查找传出号码的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用它:

public void onCallStateChanged(int state, String incomingNumber)

正在收听:

telephonyManager.listen(listener,PhoneStateListener.LISTEN_CALL_STATE);

我想知道呼出和呼入电话,但现在我只接到呼入电话(状态更改时响了)。谁能告诉我何时可以检测到呼出电话及其结束

I want to know both outgoing and incoming calls but for now I only get incoming calls (when state changes is ringing). Can anyone tell me when can I detect outgoing call and its end

还有一种方法可以在Eclipse仿真器中模拟呼出电话。能够通过eclipse中的仿真器控制来处理来电。

Also is there a way to simulate outgoing calls in Eclipse emulator. was able to do that for incoming calls via emulator control in eclipse.

推荐答案

使用意图为 android.intent.action.NEW_OUTGOING_CALL IntentFilter 的字符串参数,别忘了在AndroidMenifest中授予 PROCESS_OUTGOING_CALLS 的权限。这将起作用。每当有去电时,都会显示敬酒信息。代码如下。

Use a broadcast listener with an intent android.intent.action.NEW_OUTGOING_CALL string parametrer for the IntentFilter and don't forget to give permission in AndroidMenifest to PROCESS_OUTGOING_CALLS. This will work. Whenever there is an outgoing call a toast message will be shown. Code is below.

public static final String outgoing = "android.intent.action.NEW_OUTGOING_CALL" ;
IntentFilter intentFilter = new IntentFilter(outgoing);
BroadcastReceiver OutGoingCallReceiver = new BroadcastReceiver()
{
    @Override
    public void onReceive(Context context, Intent intent) 
    {
        // TODO Auto-generated method stub
        String outgoingno = intent.getStringExtra(Intent.EXTRA_PHONE_NUMBER);
        Toast.makeText(context, "outgoingnum =" + outgoingno,Toast.LENGTH_LONG).show();
    }
};
registerReceiver(brForOutgoingCall, intentFilter);

这篇关于如何在电话管理器中查找传出号码的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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