Return the volume for the ringer. - Android Media

Android examples for Media:Audio

Description

Return the volume for the ringer.

Demo Code


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

public class Main {
    /** Return the volume for the ringer. */
    public static int getRingerVolume(@NonNull Context context) {
        return getAudioManager(context).getStreamVolume(
                AudioManager.STREAM_RING);
    }//from  ww  w  .  ja va 2 s  .  com

    private static AudioManager getAudioManager(@NonNull Context context) {
        return (AudioManager) context.getApplicationContext()
                .getSystemService(Context.AUDIO_SERVICE);
    }
}

Related Tutorials