Example usage for android.media AudioManager isStreamMute

List of usage examples for android.media AudioManager isStreamMute

Introduction

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

Prototype

public boolean isStreamMute(int streamType) 

Source Link

Document

Returns the current mute state for a particular stream.

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);
        }//from   w  w  w.j  ava 2 s. com
    } else {
        audioManager.setStreamMute(AudioManager.STREAM_MUSIC, mute);
    }
}