Prevent MediatorLiveData event emit on config change

280 Views Asked by At

In architecture samples , There is an extension of MutableLiveData named SingleLiveEvent which helps us prevent a LiveData from firing on phone rotation or config change.

This (SingleLiveEvent) avoids a common problem with events: on configuration change (like rotation) an update can be emitted if the observer is active.

But we can't cast MediatorLiveData to SingleLiveEvent. How can we avoid MediatorLiveData emitting on config change?

1

There are 1 best solutions below

2
On
   <activity android:name=".appActivity.video.playVideo.PlayVideoFromUri"
        android:configChanges="keyboardHidden|orientation|screenSize"></activity>

issue is Activity recrate on orientation change just add above lines in mainfest file.