get Music Volume - Android android.media

Android examples for android.media:Volume

Description

get Music Volume

Demo Code

import android.content.Context;
import android.media.AudioManager;
import android.support.annotation.NonNull;

public class Main{

    /** Return the volume for music. */
    public static int getMusicVolume(@NonNull Context context) {
        return getAudioManager(context).getStreamVolume(
                AudioManager.STREAM_MUSIC);
    }//from  w  w  w .j  a  v a  2 s.  c  o m
    private static AudioManager getAudioManager(@NonNull Context context) {
        return (AudioManager) context.getApplicationContext()
                .getSystemService(Context.AUDIO_SERVICE);
    }

}

Related Tutorials