Getting notified when virtual keyboard shown / dismissed for an EditText?
<p>I'd like to get notified when the virtual keyboard is shown / dismissed. This does not seem to be possible, other than by using some layout resizing listener tricks:</p>

<p><a href="http://stackoverflow.com/questions/2150078/android-is-software-keyboard-shown">Android: Is software keyboard shown?</a></p>

<p>My activity has a single EditText. I could make it <em>not</em> have focus at activity startup, then add a focuschangelistener to it. When it gains focus, I can do my onVirtualKeyboardShown() stuff. If I could just listen for the back key being pressed in the EditText, I could then interpret that as the virtual keyboard being hidden. Something like:</p>

<pre><code>EditText et = ...;
et.setOnFocusChangedListener(new OnFocusChangedListener() {
    public void onFocusChanged(boolean focused) {
        if (focused) {
           // virtual keyboard probably showing.
        }
    }
});
et.setKeyListener(new KeyListener() {
    public void onKeyPressed(int code) {
        if (code == BACK_KEY) [ 
            if (et.isFocused()) {
                // virtual keyboard probably hiding.
                // lose focus to set up for next time.
                et.setFocused(false);
            }
        }
    }
});
</code></pre>

<p>Seems like any approach is fraught with problems given all the differences between virtual keyboards, then we also have to deal with physical keyboards too,</p>

<p>Thanks</p>
