0

I'm developing a game. I need a button to turn on and off game sounds. In my app, I play background music which I want to be muted upon clicking a button. Here's my code:

AudioManager aManager = (AudioManager)getSystemService(AUDIO_SERVICE);

if (aManager.getRingerMode() == AudioManager.RINGER_MODE_NORMAL) {
   aManager.setRingerMode(AudioManager.RINGER_MODE_SILENT);
} else {
   aManager.setRingerMode(AudioManager.RINGER_MODE_NORMAL);
}

When I debug, the conditions are right but nothing happens! The sound is never turned off!

Alex Crist
  • 1,059
  • 2
  • 12
  • 22
user3240604
  • 407
  • 1
  • 8
  • 22

1 Answers1

0

Check for method "isVolumeFixed()". If true, your device can't have it's sound changed. Some devices have a policy about that.

NOlivNeto
  • 703
  • 1
  • 5
  • 10