0

I noticed that under Android 4.x setting ring volume to 0 is not possible. If I execute this code and then I go to Settings--> Sound --> Volumes I can see it is set to 1. I

audiomanager.setStreamVolume(AudioManager.STREAM_RING, 0, 0);

Do you know why? I know I could use audiomanager.setRingerMode(RINGER_MODE_SILENT) but annoys me!! because in this case I would have to "remember" if vibration is on or off for activating again sound.

Of course, all this works in other Android versions.

Ton
  • 9,235
  • 15
  • 59
  • 103

2 Answers2

1

Don't use setStreamMute() as it has weird side-effects with the lifecycle of your process. See the docs:

The mute command is protected against client process death: if a process with an active mute request on a stream dies, this stream will be unmuted automatically.

I'm afraid setRingerMode() with either RINGER_SILENT or RINGER_VIBRATE is the way to go, which will have the effect of zero-ing out the stream volume

Andrew Flynn
  • 1,501
  • 12
  • 17
0

try setStreamMute instead which is equivalent to setting volume to 0.

Mouna Cheikhna
  • 38,870
  • 10
  • 48
  • 69