title: Create a Android App Service which run even after app is terminated
body: <p>This is service which I wanted to run in the background</p>
  
  <pre><code>public class CustomMyService extends Service {
  
       public CustomMyService() {
  
      }
  
      @Override
      public int onStartCommand(Intent intent, int flags, int startId) {
  
          return START_STICKY;
      }
  
      @Override
      public IBinder onBind(Intent intent) {
          return null;
      }
  
      @Override
      public void onTaskRemoved(Intent rootIntent) {
          Intent intent = new Intent("com.android.ServiceStopped");
          sendBroadcast(intent);
      }
  }
  </code></pre>
  
  <p>Manifest File</p>
  
  <pre><code>&lt;service android:name=".CustomMyService"&gt;
              &lt;intent-filter android:priority="1000"&gt;
                  &lt;action android:name="android.location.PROVIDERS_CHANGED"/&gt;
                  &lt;category android:name="android.intent.category.DEFAULT"/&gt;
              &lt;/intent-filter&gt;
          &lt;/service&gt;
  </code></pre>
  
  <p>Please kindly someone let me know. I did all google and youtube search, nothing is working.</p>
  
  <p>Im using redmi note 3, in which I have a option called autostart, if I give permission to this app for autostart, service runs in background.</p>
  
  <p>But this option is not there in many of other android smart phone, so app services will be killed when app is terminated.</p>
  
  <p>Please kindly let me know how can service be running, even after app is terminated.</p>