title: Android JobIntentService stops In between loop
body: <p>I have Service extends <code>JobIntentService</code> which I used to run in the background to get the location of the user even when the app is closed. But the service gets destroyed inbetween without any errors. How to run it full time?</p>
  
  <p><strong>My Code below:</strong></p>
  
  <pre><code>public class MyLocationService extends JobIntentService implements LocationListener {
  
  public static void enqueueWork(Context context, Intent work) {
      enqueueWork(context, MyLocationService.class, JOB_ID, work);
  }
  
  @Override
  protected void onHandleWork(@NonNull Intent intent) {
      int maxCount = intent.getIntExtra("maxCountValue", 10000);
      for (i = 0; i &lt; maxCount; i++) {
          fn_getlocation();
          Thread.sleep(300000);
      }
  }
  </code></pre>
  
  <p>}</p>
  
  <p>Is my Thread sleep exceed the limit ?</p>