2012-07-31 227 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" />