android - 如何在电话管理器中查找拨出号码

标签 android android-emulator calllog telephonymanager

我正在使用这个:

public void onCallStateChanged(int state, String incomingNumber)

正在听:

telephonyManager.listen(listener,PhoneStateListener.LISTEN_CALL_STATE);

我想知道去电和来电,但现在我只接到来电(当状态更改响铃时)。谁能告诉我什么时候可以检测到拨出电话及其结束

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

最佳答案

将广播监听器与 android.intent.action.NEW_OUTGOING_CALL 字符串参数一起用于 IntentFilter 并且不要忘记在 AndroidMenifest 中授予 权限PROCESS_OUTGOING_CALLS。这会起作用。每当有呼出电话时,都会显示 toast 消息。代码如下。

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

关于android - 如何在电话管理器中查找拨出号码,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6611197/

相关文章:

Android:如何找到特定联系人的通话列表?

android - Android模拟器中的动态地理定位更新?

android - 分配跟踪器已禁用

android-studio - 为什么三星 Galaxy S10 Plus 皮肤在 Android Studio 中看起来很奇怪?

android-在webview中加载gif动画

iphone - 访问 iPhone 中的通话记录。

android - 在 android 通话记录中添加虚假通话

java - 如何摆脱 Toast 警告中的 "Argument ' context' might be null"

android - 如何以编程方式在 Android 上隐藏来电显示

Android Studio 构建失败 - 任务 ':app:dexDebug' 执行失败