Returns current media volume - Android Media

Android examples for Media:Media Volume

Description

Returns current media volume

Demo Code


//package com.java2s;
import android.content.Context;
import android.media.AudioManager;

public class Main {
    /**//from ww  w  . j a va  2 s  .  c  o  m
     * Returns current media volume
     * @param context
     * @return current volume
     */
    public static int getCurrentVolume(Context context) {
        AudioManager mAudioManager = (AudioManager) context
                .getSystemService(Context.AUDIO_SERVICE);
        return mAudioManager.getStreamVolume(AudioManager.STREAM_MUSIC);
    }
}

Related Tutorials