Is there any way to listen for volume changes with an Android service and react to that?
Btw: How does the Google music app allow the user to control the media volume even when the music is playing in the background?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Check out
registerMediaButtonEventReceiver(ComponentName broadcastReceiver);Define a
BroadcastReceiverthat handlesACTION_MEDIA_BUTTON. The recievedintentincludes a single extra field,EXTRA_KEY_EVENT, containing the key event that caused the broadcast. You can use this key event to get which key was pressed.EDIT:
This is just a sample code. syntax errors may be there.
Unregister the receiver in
onPause()oronStop()