Many times in Android development, we need to check the current sound profile. Like it is in normal mode, vibrate mode or silent mode. So for that in Android, they provide AudioManager class which have method that return the current sound profile. Below is the example of it.
AudioManager profileCheck = (AudioManager)getSystemService(Context.AUDIO_SERVICE); if (profileCheck.getRingerMode() == AudioManager.RINGER_MODE_NORMAL) Toast.makeText(getApplicationContext(), "Normal", Toast.LENGTH_LONG).show(); else if (profileCheck.getRingerMode() == AudioManager.RINGER_MODE_VIBRATE) Toast.makeText(getApplicationContext(), "Vibrate", Toast.LENGTH_LONG).show(); else if (profileCheck.getRingerMode() == AudioManager.RINGER_MODE_SILENT) Toast.makeText(getApplicationContext(), "Silent", Toast.LENGTH_LONG).show();
According to the sound profile you can manage your further actions.