Control Search Button In Android

Add Override Function:

    onKeyDown(....)

Back Button Key Code:

    KeyEvent. KEYCODE_SEARCH

Example Code:

public boolean onKeyDown(int keyCode, KeyEvent event) {         if (keyCode == KeyEvent.KEYCODE_SEARCH) { Toast.makeText(this, "Search", Toast.LENGTH_LONG).show(); return true; } return super.onKeyDown(keyCode, event); }

Android Articles