Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/220.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Android 拦截传出呼叫-我错过了什么?_Android - Fatal编程技术网

Android 拦截传出呼叫-我错过了什么?

Android 拦截传出呼叫-我错过了什么?,android,Android,我正在尝试编写一个简单的应用程序来捕获操作\u新的\u传出的\u呼叫意图,并编写一些调试信息 这是我的舱单: <?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" a

我正在尝试编写一个简单的应用程序来捕获
操作\u新的\u传出的\u呼叫
意图,并编写一些调试信息

这是我的舱单:

<?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> 
出于我不理解的原因,当我安装此设备并启动传出呼叫时,我收到以下错误:

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
有什么好处?似乎处理呼出的电话就足够了

FWIW,如果我在没有权限的情况下更改为通知(例如时区更改),这就像一个符咒


提前谢谢。

我也在拦截呼出的电话以采取行动。我也只有添加的权限,即处理_传出_文件,但我确实注意到,在我的DialerReceiver声明中,我设置了一个优先级:

<receiver 
   android:name="DialerReceiver"
   android:enabled="true">
   <intent-filter android:priority="2147483647">
      <action android:name="android.intent.action.NEW_OUTGOING_CALL"/>
   </intent-filter>
</receiver>

这个设置对我来说很好。如果您需要,我可以从DialerReceiver类发布一些代码。你是用模拟器还是手机来测试这个?我只测试了一部真正的手机。我没有使用模拟器。
希望这有帮助。

回答我自己的问题

在查看我的清单之后,似乎
android:exported=“false”
不正确,因为android本身需要调用
DialerReceiver

当我将其更改为android:export=“true”时,一切都正常


FWIW,我是针对emulator(API版本8和版本10设备)这样做的。

非常感谢您的回复。优先级是不必要的,但你的回答确实让我重新审视了我的清单。问题是android:exported=“false”。除去这些,一切都正常了。
<receiver 
   android:name="DialerReceiver"
   android:enabled="true">
   <intent-filter android:priority="2147483647">
      <action android:name="android.intent.action.NEW_OUTGOING_CALL"/>
   </intent-filter>
</receiver>