Example usage for android.media AudioManager ADJUST_MUTE

List of usage examples for android.media AudioManager ADJUST_MUTE

Introduction

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

Prototype

int ADJUST_MUTE

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

Click Source Link

Document

Mute the volume.

Usage

From source file:com.android.msahakyan.fma.fragment.TrackDetailFragment.java

private void mute(boolean mute) {
    AudioManager audioManager = (AudioManager) activity.getSystemService(Context.AUDIO_SERVICE);

    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
        if (!audioManager.isStreamMute(AudioManager.STREAM_MUSIC)) {
            audioManager.adjustStreamVolume(AudioManager.STREAM_MUSIC,
                    mute ? AudioManager.ADJUST_MUTE : AudioManager.ADJUST_UNMUTE, 0);
        }/*  w  ww.  j av  a2  s . c  o m*/
    } else {
        audioManager.setStreamMute(AudioManager.STREAM_MUSIC, mute);
    }
}