我有一个BroadcastReceiver,我试图检测系统启动何时完成但是Receiver没有被解雇,或者LogCat中没有任何想法?
AndroidManifest
<!-- SIM Card Receiver -->
<receiver android:name=".SIMChangeNotifierActivity" android:enabled="true" android:exported="false">
<intent-filter android:priority="1001">
<action android:name="android.intent.action.BOOT_COMPLETED"/>
</intent-filter>
</receiver>
广播接收器
public class SIMChangeNotifierActivity extends BroadcastReceiver {
public void onReceive(Context context, Intent intent)
{
if("android.intent.action.BOOT_COMPLETED".equals(intent.getAction()))
{
Log.e("TAG", "Boot completed");
}
}
答案 0 :(得分:11)
只需在清单中声明
即可 <uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" />