I have an app that plays intermittent sounds while its activity is open, and the user is always expecting it to make these noises, but unfortunately it is constrained by the music stream volume. The options I have discovered are thus:
I think the 3rd option is probably best since it cedes control of the volume to the user, but if there were some way to just override the system volume in a single mediaplayer instance that would work too.
Tap the floating plus button in the bottom right corner. Select all the apps you want to control and tap “Add.” You can control the individual volumes right from this screen, but if you want easier access, we'll need to go a little deeper. Go back to the Sound Assistant settings and select “Customize Volume Panel.”
Windows 10Right-click on the sound icon at the bottom-right corner of the desktop. Next, click on “Open Volume mixer“. On the pop-up, you will have the option to change volumes for apps individually.
Got another suggestion via Google Groups that is the platform integrated solution I was looking for and works fine:
Please 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.
It is usefull of this API: setVolumeControlStream(AudioManager.STREAM_MUSIC);
Unless this I will spend more time to fix that volume bug.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With