-2

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.

Community
  • 1
  • 1
Babin
  • 70
  • 1
  • 1
  • 9

1 Answers1

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