Search code examples
androidandroid-keypad

onConfgurationchanged not working HTC-one android


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?


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.