다음을 통해 공유


AudioManager.SetStreamMute(Stream, Boolean) Method

Definition

Mute or unmute an audio stream.

[Android.Runtime.Register("setStreamMute", "(IZ)V", "GetSetStreamMute_IZHandler")]
public virtual void SetStreamMute (Android.Media.Stream streamType, bool state);
[<Android.Runtime.Register("setStreamMute", "(IZ)V", "GetSetStreamMute_IZHandler")>]
abstract member SetStreamMute : Android.Media.Stream * bool -> unit
override this.SetStreamMute : Android.Media.Stream * bool -> unit

Parameters

streamType
Stream

The stream to be muted/unmuted.

state
Boolean

The required mute state: true for mute ON, false for mute OFF

Attributes

Remarks

Mute or unmute an audio stream.

This method should only be used by applications that replace the platform-wide management of audio settings or the main telephony application.

This method has no effect if the device implements a fixed volume policy as indicated by #isVolumeFixed().

This method was deprecated in API level 22. Prior to API level 22 this method had significantly different behavior and should be used carefully. The following applies only to pre-22 platforms: <ul> <li>The mute command is protected against client process death: if a process with an active mute request on a stream dies, this stream will be unmuted automatically.</li> <li>The mute requests for a given stream are cumulative: the AudioManager can receive several mute requests from one or more clients and the stream will be unmuted only when the same number of unmute requests are received.</li> <li>For a better user experience, applications MUST unmute a muted stream in onPause() and mute is again in onResume() if appropriate.</li> </ul>

This member is deprecated. Use #adjustStreamVolume(int, int, int) with #ADJUST_MUTE or #ADJUST_UNMUTE instead.

Java documentation for android.media.AudioManager.setStreamMute(int, boolean).

Portions of this page are modifications based on work created and shared by the Android Open Source Project and used according to terms described in the Creative Commons 2.5 Attribution License.

Applies to

See also