Saturday, 24 August 2013

Android: Set maximum volume

Android: Set maximum volume

I am creating simple alarm application which tests if user does not move
with device. If does, Service plays alarm sound.
Problem is, if user set volume to some low values (or mute it). Even if I
use this next code, my application uses this volume setting.
player = MediaPlayer.create(this, R.raw.sound);
audioManager = (AudioManager)getSystemService(AUDIO_SERVICE);
userVolume = this.audioManager.getStreamVolume(AudioManager.STREAM_ALARM);
audioManager.setStreamVolume(AudioManager.STREAM_ALARM,
this.audioManager.getStreamMaxVolume(AudioManager.STREAM_ALARM),
AudioManager.FLAG_PLAY_SOUND);
Is there a way how to set "master" volume?

No comments:

Post a Comment