diff --git a/library/src/main/java/com/github/pwittchen/reactivenetwork/library/rx2/network/observing/strategy/MarshmallowNetworkObservingStrategy.java b/library/src/main/java/com/github/pwittchen/reactivenetwork/library/rx2/network/observing/strategy/MarshmallowNetworkObservingStrategy.java index 5760eea6..bfc67718 100644 --- a/library/src/main/java/com/github/pwittchen/reactivenetwork/library/rx2/network/observing/strategy/MarshmallowNetworkObservingStrategy.java +++ b/library/src/main/java/com/github/pwittchen/reactivenetwork/library/rx2/network/observing/strategy/MarshmallowNetworkObservingStrategy.java @@ -33,6 +33,7 @@ import io.reactivex.Observable; import io.reactivex.functions.Action; import io.reactivex.subjects.PublishSubject; +import io.reactivex.subjects.Subject; import static com.github.pwittchen.reactivenetwork.library.rx2.ReactiveNetwork.LOG_TAG; @@ -48,12 +49,13 @@ @SuppressWarnings("NullAway") // it has to be initialized in the Observable due to Context private ConnectivityManager.NetworkCallback networkCallback; - private PublishSubject connectivitySubject = PublishSubject.create(); - private BroadcastReceiver idleReceiver; + private final Subject connectivitySubject; + private final BroadcastReceiver idleReceiver; @SuppressWarnings("NullAway") // networkCallback cannot be initialized here public MarshmallowNetworkObservingStrategy() { this.idleReceiver = createIdleBroadcastReceiver(); + this.connectivitySubject = PublishSubject.create().toSerialized(); } @Override public Observable observeNetworkConnectivity(final Context context) {