diff --git a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/util/BackgroundDetectionObserver.kt b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/util/BackgroundDetectionObserver.kt index 2dd16d8375..901d0eca8f 100644 --- a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/util/BackgroundDetectionObserver.kt +++ b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/util/BackgroundDetectionObserver.kt @@ -19,6 +19,7 @@ package org.matrix.android.sdk.internal.util import androidx.lifecycle.DefaultLifecycleObserver import androidx.lifecycle.LifecycleOwner import timber.log.Timber +import java.util.concurrent.CopyOnWriteArraySet internal interface BackgroundDetectionObserver : DefaultLifecycleObserver { val isInBackground: Boolean @@ -37,7 +38,7 @@ internal class DefaultBackgroundDetectionObserver : BackgroundDetectionObserver override var isInBackground: Boolean = true private set - private val listeners = LinkedHashSet() + private val listeners = CopyOnWriteArraySet() override fun register(listener: BackgroundDetectionObserver.Listener) { listeners.add(listener)