I'd like to use the volume buttons for something else in my Android application. The Dolphin browser does this I am told. Anyone know how?
Use Virtual volume slider Open Settings on your Android phone by clicking the gear icon. Then, head over to the sound and vibrations option. You will see a few volume sliders adjusting the volume of media, ringtone, notifications, and alarms, now you just need to adjust the volume and that's it.
Set the volume of your phone to where you would like it to stay. Once that is set, open the app and tap the box that says “Lock Volume at Current Level.” There you will also see the “Lock Voice Call Volume” and “Lock Media Volume.”
I imagine it looks something like this:
public boolean onKeyDown(int keyCode, KeyEvent event) { if (keyCode == KeyEvent.KEYCODE_VOLUME_DOWN || keyCode == KeyEvent.KEYCODE_VOLUME_UP) { // Do your thing return true; } else { return super.onKeyDown(keyCode, event); } }
in your activity,
@Override public boolean dispatchKeyEvent(KeyEvent event) { int keyCode = event.getKeyCode(); switch (keyCode) { case KeyEvent.KEYCODE_VOLUME_UP: case KeyEvent.KEYCODE_VOLUME_DOWN: return true; default: return super.dispatchKeyEvent(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