How to get the action on using onKeyDown()
in Accessibility Service class when a home or menu button clicked? I need to perform some action when home or menu button is clicked. Can anyone help me?
The code below will get the action of home and menu button in normal activity, but how to do it in Accessibility Service class. It does not get triggered in Accessibility service class:
public boolean onKeyDown(int keyCode, KeyEvent event) {
if ((keyCode == KeyEvent.KEYCODE_HOME)) {
System.out.println("KEYCODE_HOME");
return true;
}
if ((keyCode == KeyEvent.KEYCODE_BACK)) {
System.out.println("KEYCODE_BACK");
return true;
}
if ((keyCode == KeyEvent.KEYCODE_MENU)) {
System.out.println("KEYCODE_MENU");
return true;
}
return false;
}