This commit is contained in:
Dmitry Donskoy 2018-10-02 18:55:26 +03:00 committed by Daria Volvenkova
parent 15d3db6263
commit 1aa476b252

View file

@ -1,5 +1,6 @@
package com.mapswithme.maps.location;
import android.app.job.JobScheduler;
import android.content.Context;
import android.content.Intent;
import android.support.annotation.NonNull;
@ -8,6 +9,7 @@ import android.util.Log;
import com.mapswithme.maps.MwmApplication;
import com.mapswithme.util.CrashlyticsUtils;
import com.mapswithme.util.Utils;
import com.mapswithme.util.log.Logger;
import com.mapswithme.util.log.LoggerFactory;
@ -61,6 +63,12 @@ public class TrackRecorderWakeService extends JobIntentService
Context app = context.getApplicationContext();
Intent intent = new Intent(app, TrackRecorderWakeService.class);
final int jobId = TrackRecorderWakeService.class.hashCode();
if (Utils.isLollipopOrLater())
{
JobScheduler scheduler = (JobScheduler) context.getSystemService(Context.JOB_SCHEDULER_SERVICE);
if (scheduler != null)
scheduler.cancel(jobId);
}
JobIntentService.enqueueWork(app, TrackRecorderWakeService.class, jobId, intent);
}