diff --git a/src/com/archos/mediaprovider/video/VideoProvider.java b/src/com/archos/mediaprovider/video/VideoProvider.java index 4f293f30..d4c67679 100644 --- a/src/com/archos/mediaprovider/video/VideoProvider.java +++ b/src/com/archos/mediaprovider/video/VideoProvider.java @@ -42,6 +42,7 @@ import android.os.RemoteException; import androidx.lifecycle.DefaultLifecycleObserver; +import androidx.lifecycle.Lifecycle; import androidx.lifecycle.LifecycleOwner; import androidx.lifecycle.ProcessLifecycleOwner; import androidx.preference.PreferenceManager; @@ -1389,9 +1390,10 @@ public void run(){ } protected void handleForeGround(boolean foreground) { + log.debug("handleForeGround: foreground=" + foreground); final Context context = getContext(); - if (context == null) { - log.error("handleForeGround: context is null"); + if (context == null || ! ProcessLifecycleOwner.get().getLifecycle().getCurrentState().isAtLeast(Lifecycle.State.STARTED)) { + log.error("handleForeGround: context is null or not foreground, return"); return; } if (foreground) {