0

From android app How to identify the volume button is pressed from service.

Getting from the volume level from a service from settings provider is right way to get it ?

Is their any right API exposed by android to identify ?

Rajesh Gopu
  • 863
  • 9
  • 33

1 Answers1

-1

This type of question was already made, but the answer is quick and I have no problem to give it here:

@Override
public boolean onKeyDown(int keyCode, KeyEvent event) {
    if ((keyCode == KeyEvent.KEYCODE_VOLUME_UP)){
        // Code
    }
    else if ((keyCode == KeyEvent.KEYCODE_VOLUME_DOWN)){
        // Code
    }
    return true;
}
Sergio Carneiro
  • 3,726
  • 4
  • 35
  • 51