I've managed to use both setStreamVolume and adjustStreamVolume with AudioManager to reduce the alarm volume but it stops at 1. For other audio streams like music and ringtone, they go to zero.
Is there a way to override the alarm and set it to zero?
Edit: here's my code.
AudioManager audio = (AudioManager) getSystemService(Context.AUDIO_SERVICE);
int currentVolume = audio.getStreamVolume(AudioManager.STREAM_ALARM);
audio.setStreamVolume(AudioManager.STREAM_ALARM, 0, 0);
int amendedVolume = audio.getStreamVolume(AudioManager.STREAM_ALARM);
For STREAM_ALARM, I get 7 for maxVolume and 1 for amendedVolume. If I using STREAM_MUSIC, I get 15 for maxVolume and 0 for amendedVolume.
Using the adjustStreamVolume method
audio.adjustStreamVolume(AudioManager.STREAM_ALARM, audio.ADJUST_LOWER, 0);
The volume goes down by 1 every time it's run. For STREAM_RING it goes down to 0 but for STREAM_ALARM it goes down to only 1.
I can't use setStreamMute as it was deprecated in version 23.
#2 edit: I tried to use AudioManager.ADJUST_MUTE, it appears to set the volume to nothing if you go to the volume control screen but when the alarm goes off there's still sound and checking its current volume shows it's actually set to 1.
audio.setStreamVolume(AudioManager.STREAM_ALARM, AudioManager.ADJUST_MUTE, 0);