How to track a mobile phone button (not a widget button)

In an Android application, is it possible that when I press the mobile phone button * (asterisk) (and not the widget button), can I execute any events in my application? If this is possible, then how can I achieve it?

+4
source share
2 answers

If you mean the key * from your hardware keyboard (on devices that it has), you can capture it using KeyCode.

Here you can find an extensive list of all the keys that you can intercept.

For this:

@Override public boolean onKeyDown(int keyCode, KeyEvent event) { switch (keyCode) { case KeyEvent.KEYCODE_STAR: //here you check any key you want { //your code here return true; } } return super.onKeyDown(keyCode, event); } 

EDIT

Responding to your comment, I do not think this is possible. KeyDown / Up events are handled in action. And you will not be active. Check this!

EDIT

Yes, according to this guy you cannot.

+1
source

If the button is in your own application, then yes.

If you mean the button in any other application (I think you mean the * key on the dial pad), then no.

0
source

All Articles