I'm building up a small app that should mute and unmute the music stream
using the class AudioManager.
When I run the app, it works: clicking on the toggle button I can do the
stuff. The problem is when I mute the stream and close the app.
(the stream is muted now) I start the app and it displays the stream is
muted (fine! ), I click the button to unmute it but it doesn't work.
I've attached the code I used for better understanding)
--
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
public void onToggleClicked(View view) {
switch(view.getId()){
case R.id.tb_music:
if (!isMuted(AudioManager.STREAM_MUSIC)){
audioMgr.setStreamVolume(AudioManager.STREAM_MUSIC, 0, 0);
audioMgr.setStreamMute(AudioManager.STREAM_MUSIC,true);
}else{
audioMgr.setStreamMute(AudioManager.STREAM_MUSIC,false);
audioMgr.setStreamVolume(AudioManager.STREAM_MUSIC,
(audioMgr.getStreamMaxVolume(AudioManager.STREAM_MUSIC))/2,
AudioManager.FLAG_PLAY_SOUND);
}
//other cases
}
public boolean isMuted(int stream){
boolean value;
if (audioMgr.getStreamVolume(stream)== 0){
value = true;
}else{
value = false;
}
return value;
}