Example usage for android.media AudioManager ADJUST_UNMUTE

List of usage examples for android.media AudioManager ADJUST_UNMUTE

Introduction

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

Prototype

int ADJUST_UNMUTE

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

Click Source Link

Document

Unmute 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);
        }//from w w w .ja  va  2s  .  co  m
    } else {
        audioManager.setStreamMute(AudioManager.STREAM_MUSIC, mute);
    }
}