title: Android ViewModel object recreate with kotlin but not with java
body: <p>Im new to kotlin, and mvvm, but i was able to make it work in java, but when i made a new example mvvm-retrofit-corutines in kotlin, the view model gets called all the time on the OnCreate function is called, (which shouldn't happen according to docs and works fine in java).</p>
  <p>MainActivity:</p>
  <pre><code>lateinit var viewModel : MyViewModel
  
  override fun onCreate(savedInstanceState: Bundle?) {
      super.onCreate(savedInstanceState)
      setContentView(R.layout.activity_main)
  
      //Here we can see the logs in every orientation changed in the emulator.
      viewModel = ViewModelProvider(this).get(MyViewModel::class.java)
      viewModel.getMutableLiveDataModel().observe(this, Observer {
          Log.d(&quot;zzzz&quot;,&quot;lamda executes onChanged method -&gt; &quot;+ it.otherValues). //element from model
      })
  }
  </code></pre>
  <p>MyViewModel:</p>
  <pre><code> class MyViewModel : ViewModel() {
  
  private lateinit var objectTypeModel: MutableLiveData&lt;MyTestModel&gt;
  
  fun getMutableLiveDataModel():MutableLiveData&lt;MyTestModel&gt;{
  
      //Gets the model from a retrofit service call
      objectTypeModel = MyRepository.getModelFromService()
  
      return objectTypeModel
  }
  }
  </code></pre>
  <p>Am i doing something wrong?  already tried convert 'viewModel' into local variable as suggested in other post.</p>
  <blockquote>
  <p>Java Code, MainActivity</p>
  </blockquote>
  <pre><code>MyViewModel model;
  
  @Override
  protected void onCreate(Bundle savedInstanceState) {
      super.onCreate(savedInstanceState);
      setContentView(R.layout.activity_main);
  
      model =  new ViewModelProvider(this).get(MyViewModel.class);
      model.getUsers().observe(this, new Observer&lt;Integer&gt;() {
          @Override
          public void onChanged(Integer users) {
              Log.d(&quot;zzzz&quot;,&quot;updated value..&quot;)
          }
      });
  }
  </code></pre>
  <blockquote>
  <p>Model</p>
  </blockquote>
  <pre><code> public class MyViewModel extends ViewModel {
  
  private MutableLiveData&lt;Integer&gt; users;
  public LiveData&lt;Integer&gt; getUsers() {
      if (users == null) {
          users = new MutableLiveData&lt;Integer&gt;();
          users.setValue(10);
      }
      return users;
  }
  }
  </code></pre>