title: InputMethodService lifecycle bug
body: <p>I am writing my own <code>InputMethodService</code> and I want to detect basically when the keyboard pops up and down in order to start and stop doing stuff. I have the simplest `MyInput' class that does very little:</p>
  
  <pre><code>public class MyInput extends InputMethodService {
      private static final String TAG = "MyInput";
  
      @Override
      public View onCreateInputView() {
          Log.d(TAG, "onCreateInputView");
          LayoutInflater inflater = (LayoutInflater) this.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
          return inflater.inflate(R.layout.my_keyboard, null);
      }
  
      @Override
      public void onStartInput(EditorInfo attribute, boolean restarting) {
          super.onStartInput(EditorInfo attribute, boolean restarting);
          Log.d(TAG, "onStartInput restarting = " + restarting);
      }
  
      @Override
      public void onFinishInput() {
          super.onFinishInput();
          Log.d(TAG, "onFinishInput");
      }
  }
  </code></pre>
  
  <p>My view pops up and down normally but in the log, I can see a very strange behavior. Every time the keyboard shows or hide, both functions are called; making it impossible for me to detect when it's actually showing or not.</p>
  
  <pre><code>/** Keyboard not showing, I press an TextView **/
  D  onFinishInput
  D  onStartInput restarting = false
  /** Keyboard showing, I press back **/
  D  onFinishInput
  D  onStartInput restarting = false
  /** Keyboard not showing **/
  </code></pre>
  
  <p>I don't understand why such a simple example doesn't work. Thanks for any help</p>