diff --git a/lib/src/main/java/org/altbeacon/beacon/powersave/BackgroundPowerSaverInternal.java b/lib/src/main/java/org/altbeacon/beacon/powersave/BackgroundPowerSaverInternal.java index 01069acd..05cead78 100644 --- a/lib/src/main/java/org/altbeacon/beacon/powersave/BackgroundPowerSaverInternal.java +++ b/lib/src/main/java/org/altbeacon/beacon/powersave/BackgroundPowerSaverInternal.java @@ -6,6 +6,8 @@ import android.content.Context; import android.content.Intent; import android.content.IntentFilter; +import android.os.Handler; +import android.os.Looper; import android.os.PowerManager; import androidx.annotation.NonNull; @@ -41,7 +43,9 @@ public BackgroundPowerSaverInternal(Context context) { beaconManager = BeaconManager.getInstanceForApplication(applicationContext); - ProcessLifecycleOwner.get().getLifecycle().addObserver(this); + Handler mainHandler = new Handler(Looper.getMainLooper()); + + mainHandler.post(() -> ProcessLifecycleOwner.get().getLifecycle().addObserver(this)); } @Override