Tip: How to control the media volume with keys on Android

Tip: How to control the media volume with keys on Android
0.0 0


If the sound volume is too low and the volume buttons control the phone volume not the media volume add this to your activity onCreate and you will be OK: this.setVolumeControlStream(AudioManager.STREAM_MUSIC);
Maybe the MODIFY_AUDIO_SETTINGS permission is needed too.


Thanks for the tip man. Will try and see if it works for me.


Thanks! It works for me!


Thanks man!

And for all that came from C++ and are new to Java here is the complete solution.
The file (in cocos2d-x v3.6) is located here:


And I think that after the necessary changes it should look like this.
Please Java experts correct me if I am wrong…

package org.cocos2dx.cpp;

import org.cocos2dx.lib.Cocos2dxActivity;
import android.os.Bundle;
import android.media.AudioManager;

public class AppActivity extends Cocos2dxActivity {
   public void onCreate(Bundle savedInstanceState) {