title: Android: MVVM is it possible to display a message (toast/snackbar etc.) from the ViewModel
body: <p>I want to know what is the best approach to display some sort of message in the view from the ViewModel. My ViewModel is making a POST call and "onResult" I want to pop up a message to the user containing a certain message.</p>
  
  <p>This is my ViewModel:</p>
  
  <pre><code>public class RegisterViewModel extends ViewModel implements Observable {
  .
  .   
  .
  public void registerUser(PostUserRegDao postUserRegDao) {
  
      repository.executeRegistration(postUserRegDao).enqueue(new Callback&lt;RegistratedUserDTO&gt;() {
          @Override
          public void onResponse(Call&lt;RegistratedUserDTO&gt; call, Response&lt;RegistratedUserDTO&gt; response) {
              RegistratedUserDTO registratedUserDTO = response.body();
              /// here I want to set the message and send it to the Activity
  
              if (registratedUserDTO.getRegisterUserResultDTO().getError() != null) {
  
              }
          }
  
      });
  }
  </code></pre>
  
  <p>And my Activity:</p>
  
  <pre><code>public class RegisterActivity extends BaseActivity {   
  
  @Override
  protected int layoutRes() {
      return R.layout.activity_register;
  }
  
  @Override
  protected void onCreate(Bundle savedInstanceState) {
      AndroidInjection.inject(this);
      super.onCreate(savedInstanceState);
  
      ActivityRegisterBinding binding = DataBindingUtil.setContentView(this, layoutRes());
      binding.setViewModel(mRegisterViewModel);       
  }
  </code></pre>
  
  <p>What would the best approach be in this case? </p>