6

I'd like to hook to an event that fires when android's on screen keyboard appears. For example when user taps EditText to bring up the keyboard. Anyone know which event (or listener) to use?

Timo

Pompair
  • 7,083
  • 11
  • 60
  • 69
  • Android documentation refers to InputMethodService's onEvaluateInputViewShown() method, that might do what I wanted, but I don't seem to be able to grab a hold of an instance of it. I tried with InputMethodManager imm = (InputMethodManager)getSystemService(INPUT_METHOD_SERVICE); but that instance doesn't help me to get to InputMethodService. – Pompair Nov 24 '10 at 16:59

2 Answers2

1

According to following discussion thread in Android Developers Google Group the only way to solve this is to listen to size changed events of the main view. The thread is pretty old though. I wonder if any of the newer APIs have provided better way.

http://groups.google.com/group/android-developers/browse_thread/thread/9d1681a01f05e782

The last post explains a logic behind a working solution.

Juhani
  • 5,076
  • 5
  • 33
  • 35
0

There won't be a way to determine when the keyboard comes up, but if you want to check when the user taps on an edittext you can register a click listener or an onfocuschangedlistener to that view.

Falmarri
  • 47,727
  • 41
  • 151
  • 191
  • 1
    Hi, thanks for the answer. However, I refuse accept this to be final truth yet. =) – Pompair Nov 24 '10 at 16:58
  • Soft keyboards are part of the IME, and some may not "pop up" (or even exist) at all, especially on devices with an always-exposed hard keyboard. – Blrfl Nov 24 '10 at 17:52
  • In case of Droid / Milestone you cannot know if the OSK is going to appear simply listening to EditText events because you won't know if the HW keyboard is out or not. – Juhani Nov 24 '10 at 21:35