0

I have Service extends JobIntentService 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?

My Code below:

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 < maxCount; i++) {
        fn_getlocation();
        Thread.sleep(300000);
    }
}

}

Is my Thread sleep exceed the limit ?

GK_
  • 1,212
  • 1
  • 12
  • 26
  • Your entire `onHandleWork` should execute within 10 minutes or it will be killed, see [related question](https://stackoverflow.com/questions/48630606/how-long-is-the-jobservice-execution-time-limit-mentioned-in-androids-jobinte). – Pawel Jun 01 '20 at 14:18
  • How to run my service in every 1-hour interval like that or whenever the location changed i want to trigger it – GK_ Jun 01 '20 at 14:25
  • How does live tracking works ? – GK_ Jun 04 '20 at 11:04

0 Answers0