Android: how to play music at maximum possible volume?

后端 未结 5 1535
-上瘾入骨i
-上瘾入骨i 2020-12-03 04:52

I know the question can be regarded as \"politically incorrect\", but I\'m designing an app which \"by design\" must get the attention of people within the maximum possible

5条回答
  •  被撕碎了的回忆
    2020-12-03 05:34

    Both of these codes worked for me but I prefer the one from MediaPlayer

    AudioManager  audioManager=(AudioManager)getSystemService(Context.AUDIO_SERVICE);
    audioManager.adjustVolume(AudioManager.ADJUST_RAISE, AudioManager.FLAG_PLAY_SOUND);
    
    Uri notification = RingtoneManager.getDefaultUri(RingtoneManager.TYPE_NOTIFICATION);
    MediaPlayer mp=new MediaPlayer();
    mp.setLooping(false);
    mp = MediaPlayer.create(HomeActivity.this, notification);
    mp.setVolume(count,count);
    mp.start();
    });
    

提交回复
热议问题