拦截呼出 - 我缺少什么? [英] Intercepting outgoing call - what am I missing?

查看:108
本文介绍了拦截呼出 - 我缺少什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试着写一个简单的应用程序来捕捉 ACTION_NEW_OUTGOING_CALL 意图,并写一些调试信息。

I'm trying to write a simple app to capture the ACTION_NEW_OUTGOING_CALL intent and write some debugging information.

下面是我的清单:

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
      package="com.example.android.apis"
      android:versionCode="1"
      android:versionName="1.0">
    <application android:icon="@drawable/icon" android:label="@string/app_name">
    <receiver android:name="DialerReceiver" android:exported="false" android:enabled="true">
        <intent-filter>
            <action android:name="android.intent.action.NEW_OUTGOING_CALL" />
        </intent-filter>
    </receiver>
</application>
<uses-permission android:name="android.permission.PROCESS_OUTGOING_CALLS"></uses-permission>
</manifest> 

这里是$ C $下DialerReceiver:

And here is the code for DialerReceiver:

package com.example.android.apis;

import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.util.Log;

public class DialerReceiver extends BroadcastReceiver {

    @Override
    public void onReceive(Context arg0, Intent arg1) {
        // TODO Auto-generated method stub
        debugOut("arg0: " + arg0.toString());
        debugOut("arg1: " + arg1.toString());
        debugOut("isOrderedBroadcast = " + isOrderedBroadcast());
    }

    private static void debugOut(String str) {
        Log.i("DialerReceiver", str);
    }
}

有关原因,我不明白,当我安装这个和拨出电话,我得到以下错误:

For reasons that I do not understand, when I install this and initiate an outgoing call, I get the following error:

WARN/ActivityManager(59): Permission Denial:
broadcasting Intent { act=android.intent.action.NEW_OUTGOING_CALL (has extras) } 
from com.android.phone (pid=123, uid=1001) requires null
due to receiver com.example.android.apis/com.example.android.apis.DialerReceiver

怎么办?好像PROCESS_OUTGOING_CALLS应该足够了。

What gives? It seems like PROCESS_OUTGOING_CALLS should be sufficient.

FWIW,如果我更改了通知,无权限(TIMEZONE_CHANGED为例),这就像一个魅力。

FWIW, if I change to a notification without permissions (TIMEZONE_CHANGED, for example), this works like a charm.

在此先感谢。

推荐答案

回答我的问题。

回顾我的清单后,它似乎像安卓出口=假是不正确的,由于Android本身就需要调用 DialerReceiver

After reviewing my manifest, it seemed like android:exported="false" was incorrect, since Android itself would need to invoke DialerReceiver.

当我改变这机器人:出口=真正的,一切工作就好了

When I changed this to android:export="true", everything worked just fine.

FWIW,我这样做是对的模拟器(API第8版和10版的设备)。

FWIW, I did this against the emulator (API version 8 and version 10 devices).

这篇关于拦截呼出 - 我缺少什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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