Android开发片段–设置系统声音

public static void setMaxVolumn(Context context){
		AudioManager audioManager = (AudioManager)context.getSystemService(Context.AUDIO_SERVICE);
	    //audioManager.setStreamVolume(AudioManager.STREAM_SYSTEM , 12, 0);
		audioManager.setRingerMode(AudioManager.RINGER_MODE_NORMAL);
	    Log.d("MUSIC", "max : " + 15 + " current : " + 15); 
	}
	public static void setHalfVolumn(Context context){
		AudioManager audioManager = (AudioManager)context.getSystemService(Context.AUDIO_SERVICE);
		audioManager.setStreamVolume(AudioManager.STREAM_SYSTEM , 7, 0);
	    Log.d("MUSIC", "max : " + 15 + " current : " + 7); 
	}
	public static void setSilentVolumn(Context context){
		AudioManager audioManager = (AudioManager)context.getSystemService(Context.AUDIO_SERVICE);
		//audioManager.setStreamVolume(AudioManager.STREAM_SYSTEM , 2, 0);
		audioManager.setRingerMode(AudioManager.RINGER_MODE_SILENT);
	    Log.d("MUSIC", "max : " + 15 + " current : " + 0); 
	}
 

你可能感兴趣的:(android)