title: How to launch activity on BroadcastReceiver when boot complete on Android
body: <p>I use below code to let my app can be auto-launch after boot complete 10 seconds:  </p>
  
  <pre><code>public class BootActivity extends BroadcastReceiver {
      static final String ACTION = "android.intent.action.BOOT_COMPLETED";   
  
      public void onReceive(Context context, Intent intent) {   
          if(intent.getAction().equals(ACTION)) {
              context.startService(new Intent(context,    
                      BootActivity.class));
              try {
                  Thread.sleep(10000);
                  Intent newAct = new Intent();
                  newAct.setClass(BootActivity.this, NewActivity.class);
                  startActivity( newAct );
              }
              catch(Exception e) {
                  e.printStackTrace();
              }
          }   
      }   
  }  
  </code></pre>
  
  <p>But the <code>setClass</code> and <code>startActivity</code> cannot use here.<br>
  How can I modify to set it to launch activity?  </p>