title: LiveData deactivates observer in Fragment after popping it up from backstack
body: <p>There is a task I need to perform every time user comes to<code>HomeFragment</code>. It doesn't matter if it was newly created or user comes back to this <code>Fragment</code>.</p>
  
  <p>It works fine when newly created, but when coming back from back stack the observer is not called. What I found using debugger is that <code>LiveData</code> has Observers, <strong>but <code>hasActiveObservers()</code> returns false</strong>. I tried to manipulate and observe/removeObserver from different lifecycle callbacks with no success. Couldn't find clear explanation in Google as well.</p>
  
  <p>Here is my <code>HomeFragment.java</code>:</p>
  
  <pre><code>public class HomeFragment extends BaseFragment {
      //.......
      private ImportViewModel viewModel;
  
      private Observer&lt;State&gt; observer = state -&gt; {
          //update UI depending on a state
      };
  
      @Override
      public void onCreate(@Nullable Bundle savedInstanceState) {
          super.onCreate(savedInstanceState);
          viewModel = ViewModelProviders.of(this, viewModelFactory).get(ImportViewModel.class);
          observeViewModel();
      }
  
      @Override
      public View onCreateView(@NonNull LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
          View v = inflater.inflate(R.layout.fragment_home, container, false);
  
          //execute here since onCreate() is not called when coming from backstack
          viewModel.importFile();
  
          return v;
      }
  
      @Override
      public void onDestroy() {
          super.onDestroy();
          viewModel.liveDataState.removeObserver(observer);
      }
  
      private void observeViewModel() {
          viewModel.liveDataState.observe(this, observer);
      }
  
      //.......
  }
  </code></pre>
  
  <p>And <code>ImportViewModel.java</code></p>
  
  <pre><code>public class ImportViewModel extends ViewModel {
  
      //......
      public MutableLiveData&lt;State&gt; liveDataState = new MutableLiveData&lt;&gt;();
      //......
      public void importFile(){
          disposables.add(repository.importFile()
                  .subscribeOn(subscribeOnScheduler)
                  .observeOn(observeOnScheduler)
                  .subscribe(this::onNext, this::onError, this::onComplete));
      }
  
       private void onNext(SomeResponse resp){
          liveDataState.setValue(new State(resp));
      }
  
      private void onError(Throwable t){
          liveDataState.setValue(new ErrorState(t.getMessage()));
      }
  
      private void onComplete(){
          liveDataState.setValue(new CompleteState());
      }
  }
  </code></pre>
  
  <p>Why is Observer becomes inactive?</p>