From 1aa476b252bfbf447b000c003af0c2b11b277d53 Mon Sep 17 00:00:00 2001 From: Dmitry Donskoy Date: Tue, 2 Oct 2018 18:55:26 +0300 Subject: [PATCH] [android] Fixed https://fabric.io/mapsme/android/apps/com.mapswithme.maps.pro/issues/5bb2d883f8b88c29632a610b - cancelling already added job --- .../maps/location/TrackRecorderWakeService.java | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/android/src/com/mapswithme/maps/location/TrackRecorderWakeService.java b/android/src/com/mapswithme/maps/location/TrackRecorderWakeService.java index 9f98bc5243..51be1461f5 100644 --- a/android/src/com/mapswithme/maps/location/TrackRecorderWakeService.java +++ b/android/src/com/mapswithme/maps/location/TrackRecorderWakeService.java @@ -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); }