Possible Duplicate:
Android - Volume Buttons used in my application
how to know when the user presses the decrease and increase volume buttons on the android device hardware. Thanks
Possible Duplicate:
Android - Volume Buttons used in my application
how to know when the user presses the decrease and increase volume buttons on the android device hardware. Thanks
Good Answer from Luke, Refer https://stackoverflow.com/a/674207/603233
Don't handle the volume keys yourself - it is almost impossible to guarantee that you won't break the behavior of the volume keys.
Call this API in your onCreate():
setVolumeControlStream(AudioManager.STREAM_MUSIC);
This tells the AudioManager that when your application has focus, the volume keys should adjust music volume.