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.
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