Android live data - observe always fires after config change : <p>I'm currently refactoring my code to include ViewModel with LiveData provided by android.arch library. I have a simple activity that sends request for a password change to server and acts according to HTTP response code. </p>

<p>For that purpose I have created class that extends ViewModel for data and a repository class to call server. My ViewModel class has one MutableLiveData field which I'm subscribing to from my activity using .observe(...) method. The issue is that code inside .observe(...) fires all the time after configuration changes (i.e. screen rotation) and I have no idea why.</p>

<p>Here is the code of ViewModel, Repository and Activity classes accordingly:</p>

<p>ChangePasswordViewModel</p>

<pre><code>public class ChangePasswordViewModel extends ViewModel{

    private MutableLiveData&lt;Integer&gt; responseCode;
    private PasswordChangeRepository passwordChangeRepository;

    public ChangePasswordViewModel() {
        responseCode = new MutableLiveData&lt;&gt;();
        passwordChangeRepository = new PasswordChangeRepositoryImpl();
    }

    public MutableLiveData&lt;Integer&gt; responseCodeLiveData() {
        return responseCode;
    }

    public void sendChangePasswordRequest(String newPassword){
        passwordChangeRepository.changePassword(newPassword,     passChangeCallback());
    }

    // Callback that fires after server sends a response
    private Callback passChangeCallback(){
        ...
        responseCode.postValue(serverResponse)
        ...
}
</code></pre>

<p>PasswordChangeRepository</p>

<pre><code>public class PasswordChangeRepositoryImpl {

    public void changePassword(String newPassword, Callback&lt;Void&gt; callback){
        //Sending new password to server and processing response in callback
        ServerCalls.changePassword(newPassword, callback);
    }
}
</code></pre>

<p>Activity</p>

<pre><code>public class ChangePasswordActivity extends AppCompatActivity{
...
    private void init(){
        //Getting appropriate view model
        passwordViewModel = ViewModelProviders.of(this).get(ChangePasswordViewModel.class);

        // Starting to observe LiveData
        passwordViewModel.getResponseCode().observe(this, responseCode -&gt; {
           Log.info("Server response is " + responseCode);
        });

        //Sending new password to server
        buttonPassChange.setOnClickListener(view -&gt;
            passwordViewModel.sendChangePasswordRequest("newPass")
        );
    }
...
}
</code></pre>

<p>Problem is that after the first time I send request to server using sendChangePasswordRequest(...) observe code in activity</p>

<pre><code>passwordViewModel.getResponseCode().observe(this, responseCode -&gt; {
           Log.info("Server response is " + responseCode);
        });
</code></pre>

<p>fires every time after I rotate the screen. Why is that happening? Value of MutableLiveData responseCode hasn't been updated since the last server call, so why does .observe() fires if there were no changes to live data?</p>
