You can use the setRingerMode() method of AudioManager class.
AudioManager audiomanage = (AudioManager)getSystemService(Context.AUDIO_SERVICE);
The value that you pass to the method should be one of RINGER_MODE_NORMAL, RINGER_MODE_SILENT, or RINGER_MODE_VIBRATE
Also note that you have to add following permission to the manifest file
Your email address will not be published. Required fields are marked *
Save my name, email, and website in this browser for the next time I comment.