Controlling Sound Setting With AudioManager

Today I will explain you about how to use AudioManager Class in your Android applications which provides access to volume and ringer mode control.

We will see how to use AudioManager class in getting and setting the device’s volume such as Media player(Music), Alarm, System,Ringer etc as well as setting different ringer mode Silent, Vibrate and Normal of your device.

Before we start developing the application, you can get more details of AudioManager class here.

Setting the ringer mode pro-grammatically is very quick and easy, the only thing you need to do is a call to setRingerMode() method by passing the type of ringer mode as its parameter. The code below will set the ringer mode to Silent.



Isn’t it very simple!!!!!!!!!

Now follow the steps below to create the application for system’s sound setting.

Step1: Create a new android project in your IDE (studio or eclipse any)

Step2: Create and write following into your layout:



Setp3: Write following into your activity:




Step4: Run to check output as shown below:


if you change the settings here you will see they are updated to the system as well. For example if you set the ringtone volume to minimum or 0 you can see the system will set on to silent mode immediately.


This way you can set this as a activity to control volumes in your game or application.

Checkout my Previouse blog on Ripple Animation.

Leave a Comment: