Example usage for android.media AudioManager setStreamMute

List of usage examples for android.media AudioManager setStreamMute

Introduction

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

Prototype

@Deprecated
public void setStreamMute(int streamType, boolean state) 

Source Link

Document

Mute or unmute an audio stream.

Usage

From source file:Main.java

public static void setVolumeUnmute(Context mc) {
    AudioManager am = (AudioManager) mc.getSystemService(Context.AUDIO_SERVICE);
    am.setStreamMute(AudioManager.STREAM_MUSIC, false);
}

From source file:Main.java

public static void setVolumeMute(Context mc) {
    AudioManager am = (AudioManager) mc.getSystemService(Context.AUDIO_SERVICE);
    am.setStreamMute(AudioManager.STREAM_MUSIC, true);
}

From source file:Main.java

public static void setMusicMute(Context context, boolean isMute) {
    AudioManager mAudioManager = (AudioManager) context.getSystemService(Context.AUDIO_SERVICE);
    mAudioManager.setStreamMute(AudioManager.STREAM_MUSIC, isMute);
}

From source file:Main.java

public static void setAudioManage(Context context) {
    AudioManager audioManager = (AudioManager) context.getSystemService(Context.AUDIO_SERVICE);
    audioManager.setStreamMute(AudioManager.STREAM_SYSTEM, true);
    audioManager.setStreamMute(AudioManager.STREAM_MUSIC, true);
    audioManager.setStreamVolume(AudioManager.STREAM_ALARM, 0, 0);
    audioManager.setStreamVolume(AudioManager.STREAM_DTMF, 0, 0);
    audioManager.setStreamVolume(AudioManager.STREAM_NOTIFICATION, 0, 0);
    audioManager.setStreamVolume(AudioManager.STREAM_RING, 0, 0);
}

From source file:com.prey.actions.picture.PictureUtil.java

private static byte[] getPicture(Context ctx, String focus) {
    AudioManager mgr = null;
    SimpleCameraActivity.dataImagen = null;
    int streamType = AudioManager.STREAM_SYSTEM;
    SimpleCameraActivity.activity = null;
    Intent intent = new Intent(ctx, SimpleCameraActivity.class);
    intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
    intent.putExtra("focus", focus);
    ctx.startActivity(intent);//from   w  w w.ja v  a  2 s. c  o m
    int i = 0;
    mgr = (AudioManager) ctx.getSystemService(Context.AUDIO_SERVICE);
    mgr.setStreamSolo(streamType, true);
    mgr.setRingerMode(AudioManager.RINGER_MODE_SILENT);
    mgr.setStreamMute(streamType, true);
    while (SimpleCameraActivity.activity == null && i < 10) {
        try {
            Thread.sleep(1000);
        } catch (InterruptedException e) {
        }
        i++;
    }
    if (SimpleCameraActivity.activity != null) {
        SimpleCameraActivity.activity.takePicture(ctx, focus);
    }
    try {
        Thread.sleep(4000);
    } catch (InterruptedException e) {
    }
    mgr.setStreamSolo(streamType, false);
    mgr.setRingerMode(AudioManager.RINGER_MODE_NORMAL);
    mgr.setStreamMute(streamType, false);
    try {
        i = 0;
        while (SimpleCameraActivity.activity != null && SimpleCameraActivity.dataImagen == null && i < 5) {
            Thread.sleep(2000);
            i++;
        }
    } catch (InterruptedException e) {
        PreyLogger.i("Error:" + e.getMessage());
    }
    byte[] out = null;
    if (SimpleCameraActivity.activity != null) {
        out = SimpleCameraActivity.dataImagen;
        SimpleCameraActivity.activity.finish();
        SimpleCameraActivity.activity = null;
        SimpleCameraActivity.dataImagen = null;

    }
    return out;
}

From source file:org.noise_planet.noisecapture.MeasurementService.java

@Override
public void onCreate() {
    mNM = (NotificationManager) getSystemService(NOTIFICATION_SERVICE);
    this.measurementManager = new MeasurementManager(getApplicationContext());
    // Display a notification about us starting.  We put an icon in the status bar.
    showNotification();//from  w w w. j av  a 2s .c  o  m
    // Mute NoiseCapture while measuring (do not capture android sounds)
    try {
        AudioManager mgr = (AudioManager) getSystemService(Context.AUDIO_SERVICE);
        mgr.setStreamMute(AudioManager.STREAM_SYSTEM, true);
    } catch (SecurityException ex) {
        // Ignore
    }
}

From source file:org.noise_planet.noisecapture.MeasurementService.java

@Override
public void onDestroy() {
    // Hide notification
    mNM.cancel(NOTIFICATION);//w w  w  .  j a v a2  s . c  o  m
    // Stop record
    if (isRecording()) {
        cancel();
    }
    try {
        AudioManager mgr = (AudioManager) getSystemService(Context.AUDIO_SERVICE);
        mgr.setStreamMute(AudioManager.STREAM_SYSTEM, false);
    } catch (SecurityException ex) {
        // Ignore
    }
}

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  w  w . ja  v a2 s. com
    } else {
        audioManager.setStreamMute(AudioManager.STREAM_MUSIC, mute);
    }
}

From source file:com.almalence.opencam.ApplicationScreen.java

public void muteShutter(boolean mute) {
    AudioManager mgr = (AudioManager) ApplicationScreen.instance
            .getSystemService(ApplicationScreen.AUDIO_SERVICE);
    mgr.setStreamMute(AudioManager.STREAM_SYSTEM, mute);
}