2012-07-31 118 views
1

我有一个BroadcastReceiver,我试图检测系统启动完成但Receiver没有被触发,或LogCat中没有任何想法?android.intent.action.BOOT_COMPLETED在启动时没有被触发

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"); 
      } 
} 
+1

允许添加在清单的BOOT_COMPLETED – nandeesh 2012-07-31 13:52:59

+0

你第一次运行你的活动? http://commonsware.com/blog/2011/07/05/boot-completed-regression.html – CommonsWare 2012-07-31 13:53:37

+0

BOOT_COMPLETED做到了!谢谢! – dythe 2012-07-31 13:56:49

回答

11

在刚刚宣布的清单

<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" />