1

我有一个广播接收器,我试图检测系统启动何时完成,但接收器没有被触发,或者 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"); 
          }
}
4

1 回答 1

11

只需在您的清单中声明

 <uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" />
于 2013-05-22T09:52:13.410 回答