I want to fire KEYCODE_SEARCH
event using ADB
in my code. When i execute this command i am unable to see any action in keyboard. But If i give "adb shell input keyevent KEYCODE_1"
it is working perfectly. Please give me any solution to fire search event using ADB
.
And My current code is like.
editText.setOnEditorActionListener(new TextView.OnEditorActionListener() {
@Override
public boolean onEditorAction(TextView v, int actionId, KeyEvent event) {
if (actionId == EditorInfo.IME_ACTION_SEARCH) {
performSearch();
return true;
}
return false;
}
});
<EditText android:imeOptions="actionSearch"
android:inputType="text"/>
Thanks.
The setting android:imeOptions="actionSearch"
doesn't enables your edit text to receive KEYCODE_SEARCH
event.
As described on Android reference:
android:imeOptions
Additional features you can enable in an IME associated with an editor to improve the integration with your application. The constants here correspond to those defined by imeOptions.
If you want to receive KEYCODE_SEARCH
sent from ADB you need to override onKeyDown
in your Activity
and manually call onEditorAction
@Override
public boolean onKeyDown(int keyCode, KeyEvent event) {
if(keyCode == KeyEvent.KEYCODE_SEARCH){
editText.onEditorAction(EditorInfo.IME_ACTION_SEARCH);
return true;
}else{
return super.onKeyDown(keyCode, event);
}
}
Please note that the other apps don't fire the search when KEYCODE_SEARCH
event is sent, they simply give focus to the search box
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With