4

I need to detect when the android software keyboard is hidden. My activity currently responds to when the hardware keyboard is hidden but the software keyboard looks like it can only be implied through a size changed event.

Does anyone know of a way that a view or activity can receive a notification when the software keyboard is hidden by the user cancelling out of keyboard mode?

Lucifer
  • 29,392
  • 25
  • 90
  • 143
Lee
  • 3,996
  • 3
  • 33
  • 37

3 Answers3

2

Would forcing the sof tkeyboard to always be visible help?

You can add this to your Activity's xml file to ensure the softkeyboard is always visible in that Activity:

android:windowSoftInputMode="stateAlwaysVisible"

http://developer.android.com/guide/topics/manifest/activity-element.html#wsoft

Will
  • 19,789
  • 10
  • 43
  • 45
1

Theres no real way to check, but you can check if an action on it works or not

boolean isClosing = false;
InputMethodManager imm = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
isClosing = imm.hideSoftInputFromWindow(tabHost.getApplicationWindowToken(), 0);

This will return false if the keyboard was closed and true if it was open and is now being closed.

Mark Hetherington
  • 1,612
  • 14
  • 24
0

I solved this by just searching for the back key. When the back key is received I know that the soft keyboard will be cancelled.

Lee
  • 3,996
  • 3
  • 33
  • 37