title: Android device background service issue
body: <p>I am using Background service in our application:</p>
  
  <pre><code>public class BackgroundService extends Service {
  @Nullable
  @Override
  public IBinder onBind(Intent intent) {
      return null;
  }
  
  @Override
  public int onStartCommand(Intent intent, int flags, int startId) {
  
      handler.postDelayed(r, 5000);
      return START_STICKY;
  }
  
  Handler handler = new Handler();
  Runnable r = new Runnable() {
      @Override
      public void run() {
          handler.postDelayed(r, 5000);
          Log.d("arpit", "connected");
      }
  };
  
  @Override
  public void onDestroy() {
      super.onDestroy();
  
  }
  
  @Override
  public void onTaskRemoved(Intent rootIntent) {
      super.onTaskRemoved(rootIntent);
      Intent restartServiceIntent = new Intent(Appclass.getInstance().getApplicationContext(), this.getClass());
      restartServiceIntent.setPackage(getPackageName());
      PendingIntent restartServicePendingIntent = PendingIntent.getService(Appclass.getInstance()
              .getApplicationContext(), 1, restartServiceIntent, PendingIntent.FLAG_ONE_SHOT);
      AlarmManager alarmService = (AlarmManager) getApplicationContext().getSystemService(Context.ALARM_SERVICE);
      alarmService.set(AlarmManager.ELAPSED_REALTIME, SystemClock.elapsedRealtime() + 1000, restartServicePendingIntent);
  }
  }
  </code></pre>
  
  <p>It's working fine, and also works if I close or kill the application.
  but on some devices like <code>oppo A33F</code> , <code>Lenovo Vibe K5</code> etc push notification is not getting through, and also the service class is destroyed after killing the application. I checked in <code>running application</code> section of device but my application is not showing by which means service class is destroyed, after killed the application. How can I resolved this and keep my service continuously running even after the app is killed.</p>