Return the volume for notifications. - Android Android OS

Android examples for Android OS:Notification

Description

Return the volume for notifications.

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 notifications. */
    public static int getNotificationVolume(@NonNull Context context) {
        return getAudioManager(context).getStreamVolume(
                AudioManager.STREAM_NOTIFICATION);
    }/*from ww w .java2 s  .  c  om*/

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

Related Tutorials