Changing Ringing Mode

  • Sound profiles or ringing modes are the audio settings of the phone. There are several ringing modes available in devices. The most common profiles are 'Normal Mode', 'Silent Mode' and 'Vibration Mode'. When you are dealing with audio in your app, you may need to access the ringing mode. There may be a need of knowing the current ringing mode and sometimes you may also want to change the mode. So here are few steps to do the same.

    Step 1- To handle all kind of audios, 'AudioManager' class is used and ringing mode is not an exception. Create an object of this class.
  • AudioManager audiomanager = (AudioManager) getSystemService(AUDIO_SERVICE);

  • By using the method 'getSystemService()' of class 'Activity' we can get access of several system settings. We are dealing here with audio, that's why we have got the 'Audio_Service' of the system. This method returns a value of type 'Object'. So we have to cast it to 'AudioManager'.
  • Now using this audiomanager, we can access the ringing mode of the device.
  • Step 2- To get the current ringing mode, the method 'getRiningMode()' is used. It returns an integer type value.

    int currentmode=audiomanager.getRingerMode();

    Step 3- The integer 'currentmode' now has the current ringing mode. This can be compared with the available ringing modes to know what mode the device is currently on.

    The three common ringing modes are-

    • AudioManager.RINGER_MODE_NORMAL
    • AudioManager.RINGER_MODE_SILENT
    • AudioManager.RINGER_MODE_VIBRATE



    Log.d("RingingMode", "Device is on silent mode");


    Step 4- To change the ringing mode, use the method setRingerMode(). It takes the required ringing mode as its parameter.

    For example, to set the Silent Mode, use-