Android examples for Media:Media Volume
Set media volume
//package com.java2s; import android.content.Context; import android.media.AudioManager; public class Main { private static AudioManager audio; /**//w w w . j av a 2s . c om * Set media volume * @param c Context * @param volume Volume */ public static synchronized void setMediaVolume(Context c, int volume) { init(c); audio.setStreamVolume(AudioManager.STREAM_MUSIC, volume, AudioManager.FLAG_SHOW_UI); } /** * Get the music manager * @param context */ private static void init(Context context) { if (audio == null) audio = (AudioManager) context .getSystemService(Context.AUDIO_SERVICE); } }