diff --git a/goa/proj.android-studio/goa/src/main/java/org/cocos2dx/cpp/AppActivity.java b/goa/proj.android-studio/goa/src/main/java/org/cocos2dx/cpp/AppActivity.java index a7ff2cde0c..1ae04b9d5a 100644 --- a/goa/proj.android-studio/goa/src/main/java/org/cocos2dx/cpp/AppActivity.java +++ b/goa/proj.android-studio/goa/src/main/java/org/cocos2dx/cpp/AppActivity.java @@ -43,6 +43,7 @@ of this software and associated documentation files (the "Software"), to deal import android.speech.tts.TextToSpeech; import android.util.Log; import android.widget.Toast; +import android.media.AudioManager; import com.maq.xprize.bali.db.entity.User; import com.maq.xprize.bali.repo.UserRepo; @@ -89,6 +90,7 @@ public class AppActivity extends Cocos2dxActivity { private static Context _context; private static String currentGameName; private static boolean supportForTTSEnabled = false; + AudioManager audioManager; static { System.out.println("Loaded library"); @@ -390,6 +392,11 @@ public void onInit(int status) { } } }); + audioManager = (AudioManager) getSystemService(Context.AUDIO_SERVICE); + int maxVolume = audioManager.getStreamMaxVolume(AudioManager.STREAM_MUSIC); //maximum value of stream media. + if (audioManager.getStreamVolume(AudioManager.STREAM_MUSIC) < maxVolume / 2) { //check if the audio is less than 50% + audioManager.setStreamVolume(AudioManager.STREAM_MUSIC, maxVolume / 2, 0); //set the audio to 50% when app start. + } } private void needExtraction() {