-1

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

Community
  • 1
  • 1
Santosh Reddy
  • 57
  • 1
  • 9
  • Hi Guys, I dont even know that there is a api to know when the user pressed the decrease and increase volume buttons on the android device.When i did the research on the google and stackoverflow.When you mentioned there is a duplicate i used that api and it worked for me.Im very new to android so it feel difficult for me to find the api.Please dont think i did not research.I spent almost 6 days before asking this question.please remove some of my negative votes otherwise i can not able ask the question again please. – Santosh Reddy Feb 08 '13 at 08:53

1 Answers1

1

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.

Community
  • 1
  • 1
kumar_android
  • 2,273
  • 1
  • 21
  • 30
  • http://stackoverflow.com/questions/2874743/android-volume-buttons-used-in-my-application this url got my answer.Answered by yanchenko,Andrew – Santosh Reddy Jan 25 '13 at 13:59