You need @Override onConfigurationChanged to be able to handle changes at runtime:
@Override public void onConfigurationChanged(Configuration newConfig) { super.onConfigurationChanged(newConfig); // Checks whether a hardware or on-screen keyboard is available if (newConfig.keyboardHidden == Configuration.KEYBOARDHIDDEN_NO) { Toast.makeText(this, "Keyboard visible", Toast.LENGTH_SHORT).show(); } else if (newConfig.keyboardHidden == Configuration.KEYBOARDHIDDEN_YES) { Toast.makeText(this, "Keyboard hidden", Toast.LENGTH_SHORT).show(); } }
An example from here . Look here for keyboard-related fields (among other things) that you might want to use.
Change (RivieraKid): Changed to reflect a hard or on-screen keyboard.
Joao
source share