I used AudioManager.setRingerMode() to handle the device volume in my application using:
AudioManager.setRingerMode(AudioManager.RINGER_MODE_SILENT)
to turn off vibration and sound.AudioManager.setRingerMode(AudioManager.RINGER_MODE_VIBRATE)
to turn off the sound and turn on the vibration.AudioManager.setRingerMode(AudioManager.RINGER_MODE_NORMAL)
to turn on the sound and turn on the vibration.
In other words, I was able to get control of the device volume and reach all "modes".
But, it's not possible to handle all modes of device volume in Android 5.0 using only the AudioManager.setRingerMode
.
As per the documentation:
Setting the device to RINGER_MODE_SILENT causes the device to enter the new priority mode. The device leaves priority mode if you set it to RINGER_MODE_NORMAL or RINGER_MODE_VIBRATE.
How can I handle all modes (none, vibration in priority, sound in priority, vibration in all, sound in all) of device volume in Android 5.0?