我正試圖編寫一個簡單的應用程序來捕獲ACTION_NEW_OUTGOING_CALL
意圖並編寫一些調試信息。攔截撥出電話 - 我錯過了什麼?
這裏是我的清單:
<?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>
這裏是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);
}
}
對於我不明白,當我安裝這一點,並開始撥出電話的原因,我得到以下錯誤:
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應該是足夠的。
FWIW,如果我更改爲沒有權限的通知(例如TIMEZONE_CHANGED),它就像魅力一樣。
在此先感謝。
非常感謝您的回覆。優先是沒有必要的,但你的回答確實讓我重新看到了我的清單。問題是android:exported =「false」。刪除,使一切工作。 – Scot 2011-06-07 15:58:53