2012-03-17

Doesn't your Android app show the default volume control bar?

The above screenshot is taken with a developing version.

Are you troubled with the volume control in your Android app? You're my friends ;-)

I also faced this problem and took a lot of time to fix it. I doubt openal or GLSurfaceView causes this problem. So I try to investigate on the Android source code to know what prevents displaying the default volume control.

But I gave up researching, because the audio management logic of the Android source code is message-based and I found it would take a lot of times to identify the essential factor. In addition to that, I often face this kind of problem even in apps without NDK nor OpenGL.

Then, I found a simple way to display the default volume control. This is just to write explicitly how to handle the volume button events and adjust the volume level manually. It is important to use the flag FLAG_SHOW_UI when adjust the level with AudioManager#setStreamVolume method.

Below is the code, which worked fine for me.