Android examples for Media:Media Volume
Reduce Music Volume
import android.content.Context; import android.media.AudioManager; public class VolumeUtil { private static VolumeUtil staticInstance; private AudioManager audioManager; private VolumeUtil(Context context) { audioManager = (AudioManager) context .getSystemService(Context.AUDIO_SERVICE); }//w ww . j a v a2 s . c o m public static VolumeUtil getStaticInstance(Context context) { if (staticInstance == null) staticInstance = new VolumeUtil(context); return staticInstance; } public void raiseVolume() { audioManager.adjustStreamVolume(AudioManager.STREAM_MUSIC, AudioManager.ADJUST_RAISE, 0); } public void reduceVolume() { audioManager.adjustStreamVolume(AudioManager.STREAM_MUSIC, AudioManager.ADJUST_LOWER, 0); } }