1
我可以使用下面的方式啓動廣播接收器嗎?有人可以讓它運行,但我不能。我不知道爲什麼。數據包管理器無法啓動廣播接收器
PackageManager pm = getApplicationContext().getPackageManager();
ComponentName componentName = new ComponentName("brd2.demo", "brd2.demo.BroadcastReceiver");
pm.setComponentEnabledSetting(componentName,
PackageManager.COMPONENT_ENABLED_STATE_ENABLED,
PackageManager.DONT_KILL_APP);
這是我的Android清單:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="brd2.demo"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk android:minSdkVersion="7" />
<application
android:icon="@drawable/ic_launcher"
android:label="@string/app_name" >
<activity
android:label="@string/app_name"
android:name="brd2.demo.BroadcastReceiverDemo2Activity" >
<intent-filter >
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<receiver android:name="brd2.demo.CallBroadcastReceiver">
<intent-filter >
<action android:name="android.intent.action.NEW_OUTGOING_CALL" />
</intent-filter>
<intent-filter >
<action android:name="android.intent.action.PHONE_STATE" />
</intent-filter>
</receiver>
</application>
</manifest>
請幫幫我。