get Audio Silent Mode - Android Media

Android examples for Media:Audio Mode

Description

get Audio Silent Mode

Demo Code


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

public class Main {
    public static final String MODE_SILENT = "silent";
    public static final String MODE_VIBRATE = "vibrate";
    public static final String MODE_NORMAL = "normal";

    public static String getSilentMode(final Context context) {
        final AudioManager am = (AudioManager) context
                .getSystemService(Context.AUDIO_SERVICE);
        final int mode = am.getRingerMode();
        switch (mode) {
        case AudioManager.RINGER_MODE_SILENT:
            return MODE_SILENT;
        case AudioManager.RINGER_MODE_VIBRATE:
            return MODE_VIBRATE;
        case AudioManager.RINGER_MODE_NORMAL:
        default:// ww  w .  j  a va 2s .  com
            return MODE_NORMAL;
        }
    }
}

Related Tutorials