Android examples for android.media:AudioManager
set Ringer Mode
//package com.java2s; import android.content.Context; import android.media.AudioManager; public class Main { public static void setRingerMode(Context context, int i) { AudioManager audiomanager = (AudioManager) context .getSystemService("audio"); int j = audiomanager.getRingerMode(); audiomanager.setRingerMode(i);//from w w w . j ava2 s . c o m if (i == 2 && j != 2) { int k = android.provider.Settings.System.getInt( context.getContentResolver(), "last_audible_ring_volume", 0); if (k > 0) audiomanager.setStreamVolume(2, k, 0); } } }