Volume Control in android application

There was another question from a long time ago that asked the same thing. Essentially the answer is: don’t override the onKeyDown and onKeyUp buttons. It’s much better to simply use this one line setVolumeControlStream(AudioManager.STREAM_MUSIC); in your onCreate() method. That tells the OS that the volume buttons should affect the “media” volume when your application is visible, and that’s the volume it uses for your application.

As for controlling the Media volume no matter what app is visible, I’m not sure that can be done – or if it could, whether that would be a good thing.

Leave a Comment