Skip to content

Commit

Permalink
try to get more accurate foreground state
Browse files Browse the repository at this point in the history
  • Loading branch information
courville committed Dec 19, 2024
1 parent 8d3c071 commit 7a5d477
Showing 1 changed file with 2 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -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;
}
Expand Down

0 comments on commit 7a5d477

Please sign in to comment.