我想实现一个简单的广播接收器,当有来电时它会被触发。但是,似乎永远不会触发 onReceive(我非常仔细地检查了 LogCat,那里没有输出),出了什么问题?我的课:
public class MyPhoneReceiver extends BroadcastReceiver {
private static final String TAG = "DEBUG";
@Override
public void onReceive(Context context, Intent intent) {
Log.e(TAG, "Test loggiiiiiiiiiiiiiiiiiiiiiiiiing!");
}
}
我的清单文件:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="tung.le.android.receiver.phone"
android:versionCode="1"
android:versionName="1.0" >
<application
android:icon="@drawable/ic_launcher"
android:label="@string/app_name" >
<receiver android:name=".MyPhoneReceiver" >
<intent-filter>
<action android:name="android.intent.action.PHONE_STATE" >
</action>
</intent-filter>
</receiver>
</application>
<uses-sdk android:minSdkVersion="15" />
<uses-permission android:name="android.permission.READ_PHONE_STATE" >
</uses-permission>
</manifest>