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 ?