tags:

views:

58

answers:

2

I want to pop up the software keyboard when the user presses the search hardware search key.

At the moment I use the following function with doesn't seem to work for the search key but which does work for the back key: The logging doesn't get even tiggered through the search key.

@Override

public boolean onKeyDown(int keyCode, KeyEvent event) { if(keyCode == KeyEvent.KEYCODE_BACK){ Log.v(TAG, "On back key press"); renderPrevious();

    return false;
    }
    if(keyCode == KeyEvent.KEYCODE_SEARCH){
        Log.v(TAG, "On search key press");
        this.getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_VISIBLE);

    return false;
    }

    return true;
}

I have no text field but want to handle the input directly myself if that matters.

A: 

this method setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_VISIBLE) doesnt wakeup the keyboard. Check this link. More to know about it check this example. hope it helps

Edit:

try this showSoftInput method

Praveen Chandrasekaran
The example link goes to software that implements a whole keyboard to replace the default keyboard, it's not about simply using a soft keyboard in a app.
Christian
A: 

Maybe this would be helpful:

 InputMethodManager inputMgr = (InputMethodManager)getSystemService Context.INPUT_METHOD_SERVICE); 
inputMgr.toggleSoftInput(0, 0);
davs