1

In my case I hide softkeys in the app but at sometimes softkeys show and hide when displaying notifications. In my code I used,

    View decorView = getWindow().getDecorView();

    int uiOptions = View.SYSTEM_UI_FLAG_HIDE_NAVIGATION
            | View.SYSTEM_UI_FLAG_FULLSCREEN
            | View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION
            | View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY;

    decorView.setSystemUiVisibility(uiOptions);

Is there any listener or callback to detect when softkeys show/hide event.

Thanks...

Trilok
  • 53
  • 1
  • 6

2 Answers2

0

Try Using OnFocusChangeListener() on the Edit Text:

myEditText.setOnFocusChangeListener(new OnFocusChangeListener() {

    @Override
    public void onFocusChange(View v, boolean hasFocus) {
        if(!hasFocus){
            InputMethodManager imm = 
(InputMethodManager)context.getSystemService(Context.INPUT_METHOD_SERVICE);
    imm.hideSoftInputFromWindow(yourEditText.getWindowToken(), 0);
        }               
    }
});
0

Try to add

OnGlobalLayoutListener

to catch the event

contentView.getViewTreeObserver().addOnGlobalLayoutListener(new ViewTreeObserver.OnGlobalLayoutListener() {
    @Override
    public void onGlobalLayout() {

      //try catching soft keys here
    }
    });
Rai
  • 187
  • 2
  • 15