Android examples for Media:Audio
Return true if device ringer is silent or vibrate, otherwise false.
//package com.java2s; import android.content.Context; import android.media.AudioManager; import android.support.annotation.NonNull; public class Main { /** Return true if device ringer is silent or vibrate, otherwise false. */ public static boolean isRingerSilent(@NonNull Context context) { AudioManager am = getAudioManager(context); int ringerMode = am.getRingerMode(); if ((ringerMode == AudioManager.RINGER_MODE_SILENT) || (ringerMode == AudioManager.RINGER_MODE_VIBRATE)) { return true; }//from ww w . j a va2 s. com return false; } private static AudioManager getAudioManager(@NonNull Context context) { return (AudioManager) context.getApplicationContext() .getSystemService(Context.AUDIO_SERVICE); } }