title: Android Exception "Cannot broadcast before boot completed"
body: <p>I got this error from the logs. </p>
  
  <p>I keep searching on the web but no answers. I just want to know what causes this error.</p>
  
  <p>Logs:</p>
  
  <pre><code>[java] java.lang.RuntimeException: An error occured while executing doInBackground() 
       [java] at android.os.AsyncTask$3.done(AsyncTask.java:300) 
       [java] at java.util.concurrent.FutureTask.finishCompletion(FutureTask.java:355) 
       [java] at java.util.concurrent.FutureTask.setException(FutureTask.java:222) 
       [java] at java.util.concurrent.FutureTask.run(FutureTask.java:242) 
       [java] at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:231) 
       [java] at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1112) 
       [java] at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:587) 
       [java] at java.lang.Thread.run(Thread.java:841) 
       [java] Caused by: java.lang.IllegalStateException: Cannot broadcast before boot completed 
       [java] at android.os.Parcel.readException(Parcel.java:1473) 
       [java] at android.os.Parcel.readException(Parcel.java:1419) 
       [java] at android.app.ActivityManagerProxy.broadcastIntent(ActivityManagerNative.java:2406) 
       [java] at android.app.ContextImpl.sendStickyBroadcast(ContextImpl.java:1407) 
       [java] at android.content.ContextWrapper.sendStickyBroadcast(ContextWrapper.java:427) 
       [java] at com.phoenix.server.utils.SwitchService.a(SourceFile:126) 
   [java] at com.phoenix.server.utils.SyncServerService$SyncHandler.a(SourceFile:79) 
   [java] at com.phoenix.server.utils.SyncServerService$SyncHandler.doInBackground(SourceFile:102) 
   [java] at android.os.AsyncTask$2.call(AsyncTask.java:288) 
   [java] at java.util.concurrent.FutureTask.run(FutureTask.java:237) 
   [java] ... 4 more 
  </code></pre>
  
  <p>I executed the AsyncTask under a class extended by an Application, and inside the onCreate() method.</p>
  
  <pre><code>new AsyncTask&lt;Context, Void, Void&gt;() {
              @Override
              protected Void doInBackground(Context... params) {
  
                   SyncServerService.isLoaded(false);
                   startService(new Intent(context, SyncServerService.class));
  
                  //wait BOOT COMPLETED broadcast.
                  mStartUpRunnable.run();
  
                  return null;
              }
          }.execute(this);
  </code></pre>
  
  <p>============</p>
  
  <p>Under SyncServerService class service, onStartCommand returns START_NOT_STICKY. Is this causes the service class in sending a broadcast intent?</p>
  
  <pre><code>@Override
      public int onStartCommand(Intent intent, int flags, int startId) {
          onStart(intent, startId);
          return START_NOT_STICKY;
      }
  </code></pre>