From ff2270d53e97af14f11c31ea54d450f630eedc05 Mon Sep 17 00:00:00 2001 From: Kai Sommerfeld Date: Sun, 6 Mar 2022 19:59:46 +0100 Subject: [Android] Main activity: onDestroy: Cancel all scheduled jobs. --- tools/android/packaging/xbmc/src/Main.java.in | 2 ++ .../android/packaging/xbmc/src/channels/util/TvUtil.java.in | 12 ++++++++++++ 2 files changed, 14 insertions(+) (limited to 'tools') diff --git a/tools/android/packaging/xbmc/src/Main.java.in b/tools/android/packaging/xbmc/src/Main.java.in index 3080bef78b..a769488256 100644 --- a/tools/android/packaging/xbmc/src/Main.java.in +++ b/tools/android/packaging/xbmc/src/Main.java.in @@ -290,6 +290,8 @@ public class Main extends NativeActivity implements Choreographer.FrameCallback @Override public void onDestroy() { + TvUtil.cancelAllScheduledJobs(this); + // unregister the InputDeviceListener implementation InputManager manager = (InputManager) getSystemService(INPUT_SERVICE); manager.unregisterInputDeviceListener(mInputDeviceListener); diff --git a/tools/android/packaging/xbmc/src/channels/util/TvUtil.java.in b/tools/android/packaging/xbmc/src/channels/util/TvUtil.java.in index 0286b8dc13..ff7ccd0dc0 100644 --- a/tools/android/packaging/xbmc/src/channels/util/TvUtil.java.in +++ b/tools/android/packaging/xbmc/src/channels/util/TvUtil.java.in @@ -180,6 +180,18 @@ public class TvUtil return BitmapFactory.decodeResource(context.getResources(), resourceId); } + /** + * Cancel all jobs scheduled by this app via a {@link JobScheduler}. + * + * @param context for accessing the {@link JobScheduler}. + */ + public static void cancelAllScheduledJobs(Context context) + { + JobScheduler scheduler = + (JobScheduler) context.getSystemService(Context.JOB_SCHEDULER_SERVICE); + scheduler.cancelAll(); + } + /** * Schedules syncing channels via a {@link JobScheduler}. * -- cgit v1.2.3