Can anyone provide sample code for adjusting media volume using volume keys, and also it should display a volume alert progress while pressing the keys.
Asked
Active
Viewed 384 times
1 Answers
0
I think you want 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);
}
}

Arshad Ali
- 3,082
- 12
- 56
- 99

Yogendra
- 4,817
- 1
- 28
- 21