Example usage for android.media AudioManager isMicrophoneMute

List of usage examples for android.media AudioManager isMicrophoneMute

Introduction

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

Prototype

public boolean isMicrophoneMute() 

Source Link

Document

Checks whether the microphone mute is on or off.

Usage

From source file:fr.inria.ucn.collectors.SysStateCollector.java

@SuppressWarnings("deprecation")
private JSONObject getAudioState(Context c) throws JSONException {
    AudioManager am = (AudioManager) c.getSystemService(Context.AUDIO_SERVICE);

    JSONObject data = new JSONObject();

    data.put("is_bluetooth_a2dp_on", am.isBluetoothA2dpOn());
    data.put("is_microphone_mute", am.isMicrophoneMute());
    data.put("is_music_active", am.isMusicActive());
    data.put("is_speaker_phone_on", am.isSpeakerphoneOn());
    data.put("is_wired_headset_on", am.isWiredHeadsetOn());

    switch (am.getMode()) {
    case AudioManager.MODE_IN_CALL:
        data.put("mode", "in_call");
        break;//from  w w w .j  a  va 2  s .  c  o  m
    case AudioManager.MODE_IN_COMMUNICATION:
        data.put("mode", "in_comm");
        break;
    case AudioManager.MODE_NORMAL:
        data.put("mode", "normal");
        break;
    case AudioManager.MODE_RINGTONE:
        data.put("mode", "ringtone");
        break;
    case AudioManager.MODE_INVALID:
    default:
        data.put("mode", "invalid");
        break;
    }

    switch (am.getRingerMode()) {
    case AudioManager.RINGER_MODE_VIBRATE:
        data.put("ringer_mode", "vibrate");
        break;
    case AudioManager.RINGER_MODE_SILENT:
        data.put("ringer_mode", "silent");
        break;
    case AudioManager.RINGER_MODE_NORMAL:
        data.put("ringer_mode", "normal");
        break;
    default:
        data.put("ringer_mode", "invalid");
        break;
    }
    return data;
}

From source file:com.nbplus.vbroadlauncher.RealtimeBroadcastActivity.java

private void microphoneMute(boolean onoff) {
    AudioManager audioManager = (AudioManager) getSystemService(Context.AUDIO_SERVICE);

    if (!audioManager.isMicrophoneMute() && onoff) {
        mIsMuted = true;/*from w  ww .j ava 2 s  .  c  o m*/
        audioManager.setMicrophoneMute(onoff);
    } else if (!onoff) {
        audioManager.setMicrophoneMute(onoff);
    }
}