Question

I have not tried this on another device, but am trying to get one activity to listen for when the soft keyboard shows or hides;

in my manifest i have my application node and my activity node both containing this line:

android:configChanges="keyboard|keyboardHidden|orientation|screenLayout|uiMode|screenSize|layoutDirection"

and in my activity i simply have:

 @Override
    public void onConfigurationChanged(Configuration newConfig) {
        super.onConfigurationChanged(newConfig);
        Toast.makeText(this, "keyboard new config:"+newConfig.keyboardHidden, Toast.LENGTH_SHORT).show();

        // Checks whether a hardware keyboard is available
        if (newConfig.hardKeyboardHidden == Configuration.HARDKEYBOARDHIDDEN_NO) {
            loginView_keyboardShowing.start();
            Toast.makeText(this, "keyboard visible", Toast.LENGTH_SHORT).show();
        } else if (newConfig.hardKeyboardHidden == Configuration.HARDKEYBOARDHIDDEN_YES) {
             loginView_keyboardHiding.start();
            Toast.makeText(this, "keyboard hidden", Toast.LENGTH_SHORT).show();
        }
    }

but nothing happens when the keyboard comes in or out of view..

any ideas why?

Was it helpful?

Solution

That's because none of those have anything to do with the input method editor (a.k.a., soft keyboard). There is no configuration change when the input method editor is displayed or removed.

OTHER TIPS

Here is an addition to CommonsWare's answer. Keyboard or keyboardHidden changes are fired when keyboard type is changed. For instance, an external keyboard is attached. If a software keyboard is show (or hidden), then this change is not fired.

If you want to detect such changes, please check out this thread

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top