3

How can i know if the keyboard is open or not?

Bakih
  • 286
  • 1
  • 6
  • 13

2 Answers2

5

This is available on the Configuration class. You can get the current Configuration via getResources().getConfiguration() from your Activity or other Context.

CommonsWare
  • 954,112
  • 185
  • 2,315
  • 2,367
  • i have checked this on 4.0 and higher version api 16 but it always show me value 1 means keyboard opened i have added int hard= config.keyboardHidden; on button click event but always get 1 value why any idea – Khan Aug 27 '12 at 06:45
0

That way =)

public boolean isKeyboardVisible(){
 // Checks whether a hardware keyboard is visible
 if (getResources().getConfiguration().hardKeyboardHidden == Configuration.HARDKEYBOARDHIDDEN_NO) {
     return true;
 } else if (getResources().getConfiguration()..hardKeyboardHidden == Configuration.HARDKEYBOARDHIDDEN_YES) {
     return false;
 }
}
Natan Lotério
  • 690
  • 1
  • 10
  • 20