Enable Silent Mode In Android Without Triggering Do Not Disturb
Solution 1:
This indeed appears to be another all too familiar bug in Android, in that setting RINGER_MODE_SILENT
doesn't do what the documentation says it should do. I got the desired behaviour by:
- First setting
RINGER_MODE_NORMAL
- Then setting
RINGER_MODE_SILENT
- Then setting
INTERRUPTION_FILTER_ALL
to override the erroneously set Do Not Disturb state.
i.e.
audioManager.setRingerMode(AudioManager.RINGER_MODE_NORMAL);
audioManager.setRingerMode(AudioManager.RINGER_MODE_SILENT);
notificationManager.setInterruptionFilter(NotificationManager.INTERRUPTION_FILTER_ALL);
Hope this helps.
Solution 2:
... but DND is not silent. DND can be configured to to allow priority callers to ring, but silent allows no callers to ring. So users and apps should have the choice.
This code appears to successfully mute the ringer for me (on emulator running API 28) and does not set do-not-disturb mode:-
audio.adjustStreamVolume(AudioManager.STREAM_RING,
AudioManager.ADJUST_MUTE, 0);
To reinstate the ringer, do
enter audio.adjustStreamVolume(AudioManager.STREAM_RING,
AudioManager.ADJUST_UNMUTE, 0);
Solution 3:
There are two views of the world when it comes to DnD: Before Android N and after Android N. Before Android N you could use AudioMamnager.setRingerMode(RINGER_MODE_SILENT)
if you're only interested in the ringer. But since Android N, the public api AudioMamnager.setRingerMode(silent) == DND. Therefore, for complete silence, you'd have to toggle DnD.
Also if you want to proceed with toggling DnD, you would also need NotificationPolicyAccess.
UPDATE TO ADDRESS COMMENTS
Android users have a lot of latitude. Latitudes that apps do not have.
For your situation there is good news and there is bad news.
The bad news:
Unfortunately there's no workaround that I can recommend. It is a longstanding, CTS tested behavior that silence == DND. (M -> any app could set MODE_SILENT and DND would turn on) (N+ -> using MODE_SILENT first checks in the app has permission to change DND).
THE GOOD NEWS
First, thanks for sharing your use case. As it turns out, Google's camera app has a recording feature as well. And it uses DND during recording. So DND should be a viable option for your situation. You should be able to check this (I am using a Pixel device).
- Start recording a video.
- Pull down the quick settings to see the DND tile while the recording is on going.
Post a Comment for "Enable Silent Mode In Android Without Triggering Do Not Disturb"