Reputation: 2339
I'm trying to make an app where if you hold down the volume down button, an action occurs. How would I go abouts doing this? I'm a noob for java, so an example would be excellent.
Upvotes: 0
Views: 1220
Reputation: 354
Override onKeyLongPress
in your Activity
@Override
public boolean onKeyLongPress(int keyCode, KeyEvent event) {
if (keyCode == KeyEvent.KEYCODE_VOLUME_DOWN)
{
// to your stuff here
return true;
}
return super.onKeyLongPress(keyCode, event);
}
how to capture long press volume down key in android?
Upvotes: 3