0

Is it possible to detect if the keyboard is shown in Android? I tried this answer: How to check visibility of software keyboard in Android? but nothing happens. I need to know when the keyboard is shown for moving some EditText to the front of the screen. Or,..can I do this otherwise?

Cœur
  • 37,241
  • 25
  • 195
  • 267
Gabrielle
  • 4,933
  • 13
  • 62
  • 122

2 Answers2

0

Its possible, but there is no direct API call to detect this. For workaround see: How to check visibility of software keyboard in Android?

Community
  • 1
  • 1
inazaruk
  • 74,247
  • 24
  • 188
  • 156
  • now I realize that it works but it is not really ok...when the activity starts the first thing that happens is that the keybourd appears...why? the keybourd should appear only when the user select an EditText... – Gabrielle Aug 05 '11 at 07:41
0

Check this out:

public class myTextEdit extends TextEdit{

public InputConnection onCreateInputConnection (EditorInfo outAttrs){
    InputConnection ic = super.onCreateInputConnection(outAttrs);
    //Do here whatever you want like notifying parent or Activity

    //To notify activity Give handle
//EXAMPLE:
public myActivity parent;
public setActivity(Activity a){
parent = a;
}  //in this way you can tell activity : parent.keyboardShown();

}

}
Sherif elKhatib
  • 45,786
  • 16
  • 89
  • 106