Home » Android » android – How can I detect if the volume is set to mute?

android – How can I detect if the volume is set to mute?

Posted by: admin June 15, 2020 Leave a comment


When I am developing an Android application, how can I detect if volume is set to mute?

How can my application get notified if the volume changes to mute or gets unmuted?

How to&Answers:

You can use AudioManager to check volume is mute or not mute.

AudioManager audio = (AudioManager) context.getSystemService(Context.AUDIO_SERVICE);
switch( audio.getRingerMode() ){
case AudioManager.RINGER_MODE_NORMAL:
case AudioManager.RINGER_MODE_SILENT:
case AudioManager.RINGER_MODE_VIBRATE:

and for Volume change there is BroadcastReceiver for that.

public class VolumeKeyReceiver extends BroadcastReceiver {
    public void onReceive(Context context, Intent intent) {
       //Implement Logic

Register the BroadcastReceiver

VolumeKeyReceiver keyReceiver = new VolumeKeyReceiver();
IntentFilter intentFilter = new IntentFilter();
registerReceiver(keyReceiver, intentFilter);