title: How to create an application that starts the service after boot up sequences are finished?
body: <p>I want to create an app that starts the service after rebooted, but I do not want to show the UI–just like the service run in the background silently. I can create it,but after rebooted the application crashes. Because, MainActivity had not launched and I don't want to launch any activity. How do I solve this problem?</p>
  
  <p>My manifest.xml:</p>
  
  <pre><code>&lt;manifest xmlns:android="http://schemas.android.com/apk/res/android"
  package="com.galleryapp"&gt;
  
  &lt;uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" /&gt;
  &lt;uses-permission android:name="android.permission.CAMERA" /&gt;
  
  &lt;application
      android:name=".App"
      android:allowBackup="true"
      android:icon="@mipmap/ic_launcher"
      android:label="@string/app_name"
      android:roundIcon="@mipmap/ic_launcher_round"
      android:supportsRtl="true"
      android:theme="@style/AppTheme"&gt;
  
      &lt;activity android:name=".MainActivity"&gt;
          &lt;intent-filter&gt;
              &lt;action android:name="android.intent.action.MAIN" /&gt;
              &lt;category android:name="android.intent.category.LAUNCHER" /&gt;
          &lt;/intent-filter&gt;
      &lt;/activity&gt;
  
      &lt;receiver
          android:name=".CameraEventReceiver"
          android:enabled="false"&gt;
          &lt;intent-filter&gt;
              &lt;action android:name="com.android.camera.NEW_PICTURE" /&gt;
          &lt;/intent-filter&gt;
      &lt;/receiver&gt;
  
       &lt;receiver android:name="com.galleryapp.RebootDeviceReceiver"&gt;
          &lt;intent-filter&gt;
              &lt;action android:name="android.intent.action.BOOT_COMPLETED" /&gt;
          &lt;/intent-filter&gt;
       &lt;/receiver&gt;
  
      &lt;service
          android:name=".BackgroundService"
          android:exported="true" /&gt;
  
  &lt;/application&gt;
  </code></pre>
  
  <p></p>
  
  <p>And my receiver class:</p>
  
  <pre><code>public class RebootDeviceReceiver extends BroadcastReceiver {
     @Override
     public void onReceive(Context context, Intent intent) {
  
         Intent serviceIntent = new Intent(context, BackgroundService.class);
         context.startService(serviceIntent);
  
     }
  }
  </code></pre>