Just wondering whether anyone could tell me how to capture the long keypress of the volume down key in android.
Elaborated question:
I wanted to create a BroadcastReceiver which will receive volume long keypress event. (without any UI interaction). I know it's possible for the search button. is it available for the Volume Keys?
Thanks
To turn off the volume buttons on your phone, go to Settings > Sounds and vibrations > Volume and select the "Media only" option. This will ensure the volume buttons only control media volume and not others like ringtone volume or alarm volume.
Press and hold the Volume Down and Power buttons simultaneously until the device turns on. You can use Volume Down to highlight Recovery Mode and the Power button to select it. Depending on your model, you may then have to enter your password and choose a language to enter recovery mode.
Go to Settings >> Accessibility >> Accessibility menu. There are some apps that have been created to virtually replace your volume button. You can download a virtual volume button application from Play store. Just go to Play store and search for volume button, download and install an app that meets your needs.
may be below code will help you:
@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);
}
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