android.intent.action.BOOT_COMPLETED在启动时不会被触发

dyt*_*the 1 android broadcast

我有一个BroadcastReceiver,我试图检测系统启动何时完成,但接收器没有被解雇,或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>
Run Code Online (Sandbox Code Playgroud)

广播接收器

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"); 
          }
}
Run Code Online (Sandbox Code Playgroud)

Smi*_*tel 11

只需在你的清单中声明

 <uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" />
Run Code Online (Sandbox Code Playgroud)