title: App crashes when navigating if input is focused
body: <p>I have strange issue with an application I am building. I have a fragment with a login form, when fragment is opened first field is focused by default, then if I click on another field and afterwards navigate to other fragment I get following crash.</p>
  
  <pre><code>java.lang.NullPointerException: Attempt to invoke interface method 'void android.view.inputmethod.InputConnection.closeConnection()' on a null object reference
      at android.view.inputmethod.InputConnectionWrapper.closeConnection(InputConnectionWrapper.java:270)
      at com.android.internal.view.IInputConnectionWrapper.executeMessage(IInputConnectionWrapper.java:541)
      at com.android.internal.view.IInputConnectionWrapper$MyHandler.handleMessage(IInputConnectionWrapper.java:85)
      at android.os.Handler.dispatchMessage(Handler.java:105)
      at android.os.Looper.loop(Looper.java:164)
      at android.app.ActivityThread.main(ActivityThread.java:6938)
      at java.lang.reflect.Method.invoke(Native Method)
      at com.android.internal.os.Zygote$MethodAndArgsCaller.run(Zygote.java:327)
      at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1374)
  </code></pre>
  
  <p>Heres a login form layout, to point out that I am using databinding, although I am not sure if that can be related
      </p>
  
  <pre><code>&lt;android.support.design.widget.TextInputEditText
      android:id="@+id/edit_login_form_email"
      style="@style/AppEditTextTheme"
      android:layout_width="match_parent"
      android:layout_height="wrap_content"
      android:hint="@string/login_form_edit_email"
      android:inputType="textEmailAddress"
      android:maxLines="1"
      android:text="@={loginModel.username}" /&gt;
  &lt;/android.support.design.widget.TextInputLayout&gt;
  
  &lt;android.support.design.widget.TextInputLayout
      android:id="@+id/input_login_form_edit_password"
      android:layout_width="300dp"
      android:layout_height="wrap_content"
      app:passwordToggleEnabled="true"&gt;
  
  &lt;android.support.design.widget.TextInputEditText
      style="@style/AppEditTextTheme"
      android:layout_width="match_parent"
      android:layout_height="wrap_content"
      android:hint="@string/login_form_edit_password"
      android:inputType="textPassword"
      android:maxLines="1"
      android:text="@={loginModel.password}" /&gt;
  &lt;/android.support.design.widget.TextInputLayout&gt;
  
  &lt;Button
      android:id="@+id/button_login_form_register"
      style="@style/Base.Widget.AppCompat.Button.Borderless"
      android:layout_width="wrap_content"
      android:layout_height="wrap_content"
      android:layout_marginTop="16dp"
      android:onClick="@{() -&gt; interaction.onRegisterClick()}"
      android:text="@string/login_form_button_register"
      android:textColor="@color/regularGrey" /&gt;
  </code></pre>
  
  <p>Navigation to other fragment:</p>
  
  <pre><code>override fun onRegisterClick() {
      fragmentManager!!.beginTransaction()
              .replace(R.id.fragment_container, RegisterFragment())
              .addToBackStack(null)
              .commit()
  }
  </code></pre>
  
  <p>At first I though that this issue has something to so with the fact that fragment which is being navigated to has inputs as well. I tried navigating to other fragment with no input's and it resulted in the same thing.</p>