From 7a5d4775338a78dbf7ad0c87cda3fcd56ee83a1b Mon Sep 17 00:00:00 2001 From: Courville Software Date: Thu, 19 Dec 2024 21:57:31 +0100 Subject: [PATCH] try to get more accurate foreground state See https://github.com/nova-video-player/aos-AVP/issues/1346 --- .../archos/mediaprovider/video/VideoStoreImportService.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/com/archos/mediaprovider/video/VideoStoreImportService.java b/src/com/archos/mediaprovider/video/VideoStoreImportService.java index 0268ee29..da13eeab 100644 --- a/src/com/archos/mediaprovider/video/VideoStoreImportService.java +++ b/src/com/archos/mediaprovider/video/VideoStoreImportService.java @@ -42,6 +42,7 @@ import androidx.core.app.NotificationCompat; import androidx.lifecycle.DefaultLifecycleObserver; +import androidx.lifecycle.Lifecycle; import androidx.lifecycle.LifecycleOwner; import androidx.lifecycle.ProcessLifecycleOwner; @@ -114,7 +115,7 @@ protected void finalize() throws Throwable { public static boolean startIfHandles(Context context, Intent broadcast) { log.debug("startIfHandles"); - if (! isForeground) { + if (! ProcessLifecycleOwner.get().getLifecycle().getCurrentState().isAtLeast(Lifecycle.State.STARTED)) { log.debug("startIfHandles: not in foreground, do nothing"); return false; }