Android examples for Media:Media Volume
set Current Volume
//package com.java2s; import android.content.Context; import android.media.AudioManager; public class Main { public static void setCurrentVolume(int percent, Context mc) { AudioManager am = (AudioManager) mc .getSystemService(Context.AUDIO_SERVICE); int maxvolume = am.getStreamMaxVolume(AudioManager.STREAM_MUSIC); am.setStreamVolume(AudioManager.STREAM_MUSIC, (maxvolume * percent) / 100, AudioManager.FLAG_PLAY_SOUND | AudioManager.FLAG_SHOW_UI); am.setMode(AudioManager.MODE_INVALID); }//www . j a v a2s. c om }