android - Change volume of an alarm -
i want set volume alarm. use code nothing seems happen volume, logs show value of volume i'd set. should change volume?
my code:
final mediaplayer mediaplayer = mediaplayer.create(this, ringtonemanager.getactualdefaultringtoneuri(this,ringtonemanager.type_alarm)); final audiomanager audio = (audiomanager) getsystemservice(context.audio_service); final int currentvolume = audio.getstreamvolume(audiomanager.stream_alarm); log.e("point_1", "volume " + currentvolume); audio.setstreamvolume(audiomanager.stream_alarm,0,0); mediaplayer.start(); new timer().schedule(new timertask() { @override public void run() { mediaplayer.stop(); log.e("point_1", "volume_after " + audio.getstreamvolume(audiomanager.stream_alarm)); } }, 5000);
thanks.
use code
audiomanager audiomanager = (audiomanager)getsystemservice(context.audio_service); audiomanager.setstreamvolume(audiomanager.stream_music, [int value], [if desired flag]);
you should use audiomanager.stream_music
instead of audiomanager.stream_alarm
and see how correctly set mediaplayer audio stream type too
Comments
Post a Comment