Example usage for android.media AudioManager RINGER_MODE_SILENT

List of usage examples for android.media AudioManager RINGER_MODE_SILENT

Introduction

In this page you can find the example usage for android.media AudioManager RINGER_MODE_SILENT.

Prototype

int RINGER_MODE_SILENT

To view the source code for android.media AudioManager RINGER_MODE_SILENT.

Click Source Link

Document

Ringer mode that will be silent and will not vibrate.

Usage

From source file:Main.java

public static void setSilent(AudioManager audiomanager) {
    audiomanager.setRingerMode(AudioManager.RINGER_MODE_SILENT);
}

From source file:Main.java

public static boolean isSilent(AudioManager mAudioManager) {
    int ringerMode = mAudioManager.getRingerMode();
    return ringerMode == AudioManager.RINGER_MODE_SILENT;
}

From source file:Main.java

public static void performToggle(AudioManager audioManager) {
    audioManager.setRingerMode(//from   w w w . ja v a2  s.  co m
            isPhoneSilent(audioManager) ? AudioManager.RINGER_MODE_NORMAL : AudioManager.RINGER_MODE_SILENT);
}

From source file:Main.java

/**
 * Returns whether the phone is currently in silent mode.
 *//*  ww w  .  j a  va  2s. c o m*/
public static boolean isPhoneSilent(AudioManager audioManager) {
    return audioManager.getRingerMode() == AudioManager.RINGER_MODE_SILENT;
}

From source file:Main.java

public static boolean isSupportedMode(int ringerMode) {
    switch (ringerMode) {
    case AudioManager.RINGER_MODE_NORMAL:
    case AudioManager.RINGER_MODE_VIBRATE:
    case AudioManager.RINGER_MODE_SILENT:
        return true;
    }/*from  ww  w  . j  a v a  2  s .  c  om*/
    return false;
}

From source file:Main.java

public static final void audioModeSilent(Context ctx) {
    AudioManager audio = (AudioManager) ctx.getSystemService(Context.AUDIO_SERVICE);
    audio.setRingerMode(AudioManager.RINGER_MODE_SILENT);
}

From source file:Main.java

public static void setRingerMode(Context mContext, int x) {
    AudioManager am = (AudioManager) mContext.getSystemService(Context.AUDIO_SERVICE);
    switch (x) {/*from ww  w  . ja va2 s. c  om*/
    case 0:
        am.setRingerMode(AudioManager.RINGER_MODE_SILENT);
        break;
    case 1:
        am.setRingerMode(AudioManager.RINGER_MODE_VIBRATE);
        break;
    case 2:
        am.setRingerMode(AudioManager.RINGER_MODE_NORMAL);
        break;
    /*case 3:
       am.setRingerMode(AudioManager.RINGER_MODE_);
       break;*/
    }
}

From source file:Main.java

public static boolean isPhoneSilent(AudioManager audioManager) {
    return audioManager.getRingerMode() == AudioManager.RINGER_MODE_SILENT;
}

From source file:Main.java

public static void setRingerModeBack(Context context) {
    if (currentMode == AudioManager.RINGER_MODE_NORMAL) {
        setRinger2Normal(context);/*from w ww  . ja v  a 2 s.  c om*/
        Log.i("Restored Mode normal", currentVolume + "");
    } else if (currentMode == AudioManager.RINGER_MODE_VIBRATE) {
        setRinger2Vibrate(context);
        Log.i("Restored Mode vibrate", currentVolume + "");
    } else if (currentMode == AudioManager.RINGER_MODE_SILENT) {
        setRinger2Silent(context);
        Log.i("Restored Mode Silent", currentVolume + "");
    } else {
        Log.i("Nothing ", "Matched above");
    }
}

From source file:Main.java

public static void setCurrentRingerMode(Context context) {
    AudioManager audioManager = (AudioManager) context.getSystemService(Context.AUDIO_SERVICE);
    if (audioManager.getRingerMode() == AudioManager.RINGER_MODE_NORMAL) {
        currentMode = AudioManager.RINGER_MODE_NORMAL;
        currentVolume = audioManager.getStreamVolume(AudioManager.STREAM_RING);
        Log.i("Current Mode Normal", currentVolume + "");
        Log.i("Vlaue of", currentMode + "");
    } else if (audioManager.getRingerMode() == AudioManager.RINGER_MODE_VIBRATE) {
        currentMode = AudioManager.RINGER_MODE_VIBRATE;
        Log.i("Current Mode Vibrate", currentVolume + "");
        Log.i("Vlaue of", currentMode + "");
    } else if (audioManager.getRingerMode() == AudioManager.RINGER_MODE_SILENT) {
        currentMode = AudioManager.RINGER_MODE_SILENT;
        Log.i("Current Mode Silent", currentVolume + "");
        Log.i("Vlaue of", currentMode + "");
    } else {/*from   w  w  w  .  ja  v a2  s  . c o m*/
        Log.i("Nothing ", "Matched above");
    }

}