AudioManager Class

Definition

AudioManager provides access to volume and ringer mode control.

[Android.Runtime.Register("android/media/AudioManager", DoNotGenerateAcw=true)]
public class AudioManager : Java.Lang.Object
[<Android.Runtime.Register("android/media/AudioManager", DoNotGenerateAcw=true)>]
type AudioManager = class
    inherit Object
Inheritance
AudioManager
Attributes

Remarks

AudioManager provides access to volume and ringer mode control.

Java documentation for android.media.AudioManager.

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.

Constructors

AudioManager(IntPtr, JniHandleOwnership)

A constructor used when creating managed representations of JNI objects; called by the runtime.

Fields

ActionAudioBecomingNoisy

Broadcast intent, a hint for applications that audio is about to become 'noisy' due to a change in audio outputs.

ActionHdmiAudioPlug

Broadcast Action: A sticky broadcast indicating an HDMI cable was plugged or unplugged.

ActionHeadsetPlug

Broadcast Action: Wired Headset plugged in or unplugged.

ActionMicrophoneMuteChanged

Broadcast Action: microphone muting state changed.

ActionScoAudioStateChanged
Obsolete.

Sticky broadcast intent action indicating that the Bluetooth SCO audio connection state has changed.

ActionScoAudioStateUpdated

Sticky broadcast intent action indicating that the Bluetooth SCO audio connection state has been updated.

ActionSpeakerphoneStateChanged

Broadcast Action: speakerphone state changed.

AudiofocusGain
Obsolete.

Used to indicate a gain of audio focus, or a request of audio focus, of unknown duration.

AudiofocusGainTransient
Obsolete.

Used to indicate a temporary gain or request of audio focus, anticipated to last a short amount of time.

AudiofocusGainTransientExclusive
Obsolete.

Used to indicate a temporary request of audio focus, anticipated to last a short amount of time, during which no other applications, or system components, should play anything.

AudiofocusGainTransientMayDuck
Obsolete.

Used to indicate a temporary request of audio focus, anticipated to last a short amount of time, and where it is acceptable for other audio applications to keep playing after having lowered their output level (also referred to as "ducking").

AudiofocusLoss
Obsolete.

Used to indicate a loss of audio focus of unknown duration.

AudiofocusLossTransient
Obsolete.

Used to indicate a transient loss of audio focus.

AudiofocusLossTransientCanDuck
Obsolete.

Used to indicate a transient loss of audio focus where the loser of the audio focus can lower its output volume if it wants to continue playing (also referred to as "ducking"), as the new focus owner doesn't require others to be silent.

AudiofocusNone
Obsolete.

Used to indicate no audio focus has been gained or lost, or requested.

AudiofocusRequestDelayed
Obsolete.

A focus change request whose granting is delayed: the request was successful, but the requester will only be granted audio focus once the condition that prevented immediate granting has ended.

AudiofocusRequestFailed
Obsolete.

A failed focus change request.

AudiofocusRequestGranted
Obsolete.

A successful focus change request.

AudioSessionIdGenerate

A special audio session ID to indicate that the audio session ID isn't known and the framework should generate a new value.

DirectPlaybackBitstreamSupported
Obsolete.

Return value for #getDirectPlaybackSupport(AudioFormat, AudioAttributes): direct playback supported.

DirectPlaybackNotSupported
Obsolete.

Return value for #getDirectPlaybackSupport(AudioFormat, AudioAttributes): direct playback not supported.

DirectPlaybackOffloadGaplessSupported
Obsolete.

Return value for #getDirectPlaybackSupport(AudioFormat, AudioAttributes): direct offload playback supported with gapless transitions.

DirectPlaybackOffloadSupported
Obsolete.

Return value for #getDirectPlaybackSupport(AudioFormat, AudioAttributes): direct offload playback supported.

EncodedSurroundOutputAlways
Obsolete.

The surround sound formats are ALWAYS available, even if they are not detected by the hardware.

EncodedSurroundOutputAuto
Obsolete.

The surround sound formats are available for use if they are detected.

EncodedSurroundOutputManual
Obsolete.

Surround sound formats are available according to the choice of user, even if they are not detected by the hardware.

EncodedSurroundOutputNever
Obsolete.

The surround sound formats are NEVER available, even if they are detected by the hardware.

EncodedSurroundOutputUnknown
Obsolete.

The mode for surround sound formats is unknown.

Error

A default error code.

ErrorDeadObject

An error code indicating that the object reporting it is no longer valid and needs to be recreated.

ExtraAudioPlugState

Extra used in #ACTION_HDMI_AUDIO_PLUG to communicate whether HDMI is plugged in or unplugged.

ExtraEncodings

Extra used in #ACTION_HDMI_AUDIO_PLUG to define the audio encodings supported by the connected HDMI device.

ExtraMaxChannelCount

Extra used in #ACTION_HDMI_AUDIO_PLUG to define the maximum number of channels supported by the HDMI device.

ExtraRingerMode

The new ringer mode.

ExtraScoAudioPreviousState

Extra for intent #ACTION_SCO_AUDIO_STATE_UPDATED containing the previous bluetooth SCO connection state.

ExtraScoAudioState

Extra for intent #ACTION_SCO_AUDIO_STATE_CHANGED or #ACTION_SCO_AUDIO_STATE_UPDATED containing the new bluetooth SCO connection state.

ExtraVibrateSetting
Obsolete.

The new vibrate setting for a particular type.

ExtraVibrateType
Obsolete.

The vibrate type whose setting has changed.

FxBack
Obsolete.

Back sound

ModeCallRedirect
Obsolete.

A telephony call is established and its audio is being redirected to another device.

ModeCallScreening
Obsolete.

Call screening in progress.

ModeCommunicationRedirect
Obsolete.

An audio/video chat or VoIP call is established and its audio is being redirected to another device.

NumStreams
Obsolete.

This member is deprecated.

PlaybackOffloadGaplessSupported
Obsolete.

Return value for #getPlaybackOffloadSupport(AudioFormat, AudioAttributes): offload playback supported with gapless transitions

PlaybackOffloadNotSupported
Obsolete.

Return value for #getPlaybackOffloadSupport(AudioFormat, AudioAttributes): offload playback not supported

PlaybackOffloadSupported
Obsolete.

Return value for #getPlaybackOffloadSupport(AudioFormat, AudioAttributes): offload playback supported

PropertyOutputFramesPerBuffer

Used as a key for #getProperty to request the native or optimal output buffer size for this device's low latency output stream, in decimal PCM frames.

PropertyOutputSampleRate

Used as a key for #getProperty to request the native or optimal output sample rate for this device's low latency output stream, in decimal Hz.

PropertySupportAudioSourceUnprocessed

Used as a key for #getProperty to determine if the unprocessed audio source is available and supported with the expected frequency range and level response.

PropertySupportMicNearUltrasound

Used as a key for #getProperty to determine if the default microphone audio source supports near-ultrasound frequencies (range of 18 - 21 kHz).

PropertySupportSpeakerNearUltrasound

Used as a key for #getProperty to determine if the default speaker audio path supports near-ultrasound frequencies (range of 18 - 21 kHz).

RingerModeChangedAction

Sticky broadcast intent action indicating that the ringer mode has changed.

ScoAudioStateConnected
Obsolete.

Value for extra #EXTRA_SCO_AUDIO_STATE or #EXTRA_SCO_AUDIO_PREVIOUS_STATE indicating that the SCO audio channel is established

ScoAudioStateConnecting
Obsolete.

Value for extra EXTRA_SCO_AUDIO_STATE or EXTRA_SCO_AUDIO_PREVIOUS_STATE indicating that the SCO audio channel is being established

ScoAudioStateDisconnected
Obsolete.

Value for extra EXTRA_SCO_AUDIO_STATE or EXTRA_SCO_AUDIO_PREVIOUS_STATE indicating that the SCO audio channel is not established

ScoAudioStateError
Obsolete.

Value for extra EXTRA_SCO_AUDIO_STATE indicating that there was an error trying to obtain the state

StreamAccessibility
Obsolete.

Used to identify the volume of audio streams for accessibility prompts

UseDefaultStreamType

Suggests using the default stream type.

VibrateSettingChangedAction
Obsolete.

Broadcast intent action indicating that the vibrate setting has changed.

Properties

ActivePlaybackConfigurations

Returns the current active audio playback configurations of the device

ActiveRecordingConfigurations

Returns the current active audio recording configurations of the device.

AllowedCapturePolicy

Return the capture policy. -or- Specifies whether the audio played by this app may or may not be captured by other apps or the system.

AvailableCommunicationDevices

Returns a list of audio devices that can be selected for communication use cases via #setCommunicationDevice(AudioDeviceInfo).

BluetoothA2dpOn
Obsolete.

Checks whether a Bluetooth A2DP audio peripheral is connected or not. -or- This member is deprecated.

BluetoothScoOn

Checks whether communications use Bluetooth SCO. -or- Request use of Bluetooth SCO headset for communications.

Class

Returns the runtime class of this Object.

(Inherited from Object)
CommunicationDevice

Returns currently selected audio device for communication.

EncodedSurroundMode

Gets the surround sound mode.

Handle

The handle to the underlying Android instance.

(Inherited from Object)
IsBluetoothScoAvailableOffCall

Indicates if current platform supports use of SCO for off call use cases.

IsCallScreeningModeSupported

Indicates if the platform supports a special call screening and call monitoring mode.

IsHapticPlaybackSupported

Return if audio haptic coupled playback is supported or not.

IsMusicActive

Checks whether any music is active.

IsRampingRingerEnabled

Returns the current user setting for ramping ringer on incoming phone call ringtone.

IsVolumeFixed

Indicates if the device implements a fixed volume policy.

JniIdentityHashCode (Inherited from Object)
JniPeerMembers
MicrophoneMute

Checks whether the microphone mute is on or off. -or- Sets the microphone mute on or off.

Microphones

Returns a list of MicrophoneInfo that corresponds to the characteristics of all available microphones.

Mode

Returns the current audio mode. -or- Sets the audio mode.

PeerReference (Inherited from Object)
RingerMode

Returns the current ringtone mode. -or- Sets the ringer mode.

Spatializer

Return a handle to the optional platform's Spatializer

SpeakerphoneOn

Checks whether the speakerphone is on or off. -or- Sets the speakerphone on or off.

ThresholdClass

This API supports the Mono for Android infrastructure and is not intended to be used directly from your code.

ThresholdType

This API supports the Mono for Android infrastructure and is not intended to be used directly from your code.

WiredHeadsetOn
Obsolete.

Checks whether a wired headset is connected or not. -or- Sets audio routing to the wired headset on or off.

Methods

AbandonAudioFocus(AudioManager+IOnAudioFocusChangeListener)

Abandon audio focus.

AbandonAudioFocusRequest(AudioFocusRequestClass)

Abandon audio focus.

AddOnCommunicationDeviceChangedListener(IExecutor, AudioManager+IOnCommunicationDeviceChangedListener)

Adds a listener for being notified of changes to the communication audio device.

AddOnModeChangedListener(IExecutor, AudioManager+IOnModeChangedListener)

Adds a listener to be notified of changes to the audio mode.

AddOnPreferredMixerAttributesChangedListener(IExecutor, AudioManager+IOnPreferredMixerAttributesChangedListener)
AdjustStreamVolume(Stream, Adjust, VolumeNotificationFlags)

Adjusts the volume of a particular stream by one step in a direction.

AdjustSuggestedStreamVolume(Adjust, Stream, VolumeNotificationFlags)

Adjusts the volume of the most relevant stream, or the given fallback stream.

AdjustVolume(Adjust, VolumeNotificationFlags)

Adjusts the volume of the most relevant stream.

AdjustVolumeGroupVolume(Int32, Adjust, VolumeNotificationFlags)

Adjusts the volume of a particular group associated to given id by one step in a direction.

ClearCommunicationDevice()

Cancels previous communication device selection made with #setCommunicationDevice(AudioDeviceInfo).

ClearPreferredMixerAttributes(AudioAttributes, AudioDeviceInfo)

Clears the current preferred mixer attributes that were previously set via #setPreferredMixerAttributes(AudioAttributes, AudioDeviceInfo, AudioMixerAttributes)

Clone()

Creates and returns a copy of this object.

(Inherited from Object)
DispatchMediaKeyEvent(KeyEvent)

Sends a simulated key event for a media button.

Dispose() (Inherited from Object)
Dispose(Boolean) (Inherited from Object)
Equals(Object)

Indicates whether some other object is "equal to" this one.

(Inherited from Object)
FromContext(Context)
GenerateAudioSessionId()

Return a new audio session identifier not associated with any player or effect.

GetAudioDevicesForAttributes(AudioAttributes)

Get the audio devices that would be used for the routing of the given audio attributes.

GetAudioHwSyncForSession(Int32)

Retrieves the Hardware A/V synchronization ID corresponding to the given audio session ID.

GetDevices(GetDevicesTargets)

Returns an array of AudioDeviceInfo objects corresponding to the audio devices currently connected to the system and meeting the criteria specified in the flags parameter.

GetDirectPlaybackSupport(AudioFormat, AudioAttributes)

Returns a bitfield representing the different forms of direct playback currently available for a given audio format.

GetDirectProfilesForAttributes(AudioAttributes)

Returns a list of direct AudioProfile that are supported for the specified AudioAttributes.

GetHashCode()

Returns a hash code value for the object.

(Inherited from Object)
GetParameters(String)

Gets a variable number of parameter values from audio hardware.

GetPlaybackOffloadSupport(AudioFormat, AudioAttributes)

Returns whether offloaded playback of an audio format is supported on the device or not and when supported whether gapless transitions are possible or not.

GetPreferredMixerAttributes(AudioAttributes, AudioDeviceInfo)

Returns current preferred mixer attributes that is set via #setPreferredMixerAttributes(AudioAttributes, AudioDeviceInfo, AudioMixerAttributes)

GetProperty(String)

Returns the value of the property with the specified key.

GetRouting(Mode)
Obsolete.

Returns the current audio routing bit vector for a specified mode.

GetStreamMaxVolume(Stream)

Returns the maximum volume index for a particular stream.

GetStreamMinVolume(Stream)

Returns the minimum volume index for a particular stream.

GetStreamVolume(Stream)

Returns the current volume index for a particular stream.

GetStreamVolumeDb(Stream, Int32, Int32)

Returns the volume in dB (decibel) for the given stream type at the given volume index, on the given type of audio output device.

GetSupportedMixerAttributes(AudioDeviceInfo)

Returns the AudioMixerAttributes that can be used to set as preferred mixer attributes via #setPreferredMixerAttributes( AudioAttributes, AudioDeviceInfo, AudioMixerAttributes).

GetVibrateSetting(VibrateType)
Obsolete.

Returns whether the user's vibrate setting for a vibrate type.

GetVolumeGroupIdForAttributes(AudioAttributes)

Returns the volume group id associated to the given AudioAttributes.

IsOffloadedPlaybackSupported(AudioFormat, AudioAttributes)

Returns whether offloaded playback of an audio format is supported on the device.

IsStreamMute(Stream)

Returns the current mute state for a particular stream.

IsSurroundFormatEnabled(Int32)

Gets whether a certain surround format is enabled or not.

IsVolumeGroupMuted(Int32)

Returns the current mute state for a particular volume group associated to the given id.

JavaFinalize()

Called by the garbage collector on an object when garbage collection determines that there are no more references to the object.

(Inherited from Object)
LoadSoundEffects()

Load Sound effects.

LoadSoundEffectsAsync()
Notify()

Wakes up a single thread that is waiting on this object's monitor.

(Inherited from Object)
NotifyAll()

Wakes up all threads that are waiting on this object's monitor.

(Inherited from Object)
PlaySoundEffect(SoundEffect)

Plays a sound effect (Key clicks, lid open/close.

PlaySoundEffect(SoundEffect, Single)

Plays a sound effect (Key clicks, lid open/close.

RegisterAudioDeviceCallback(AudioDeviceCallback, Handler)

Registers an AudioDeviceCallback object to receive notifications of changes to the set of connected audio devices.

RegisterAudioPlaybackCallback(AudioManager+AudioPlaybackCallback, Handler)

Register a callback to be notified of audio playback changes through AudioPlaybackCallback

RegisterAudioRecordingCallback(AudioManager+AudioRecordingCallback, Handler)

Register a callback to be notified of audio recording changes through AudioRecordingCallback

RegisterMediaButtonEventReceiver(ComponentName)
Obsolete.

Register a component to be the sole receiver of MEDIA_BUTTON intents.

RegisterMediaButtonEventReceiver(PendingIntent)
Obsolete.

Register a component to be the sole receiver of MEDIA_BUTTON intents.

RegisterRemoteControlClient(RemoteControlClient)
Obsolete.

Registers the remote control client for providing information to display on the remote controls.

RegisterRemoteController(RemoteController)
Obsolete.

Registers a RemoteController instance for it to receive media metadata updates and playback state information from applications using RemoteControlClient, and control their playback.

RemoveOnCommunicationDeviceChangedListener(AudioManager+IOnCommunicationDeviceChangedListener)
RemoveOnModeChangedListener(AudioManager+IOnModeChangedListener)
RemoveOnPreferredMixerAttributesChangedListener(AudioManager+IOnPreferredMixerAttributesChangedListener)
RequestAudioFocus(AudioFocusRequestClass)

Request audio focus.

RequestAudioFocus(AudioManager+IOnAudioFocusChangeListener, Stream, AudioFocus)

Request audio focus.

SetCommunicationDevice(AudioDeviceInfo)

Selects the audio device that should be used for communication use cases, for instance voice or video calls.

SetEncodedSurroundMode(Int32)

Sets the surround sound mode.

SetHandle(IntPtr, JniHandleOwnership)

Sets the Handle property.

(Inherited from Object)
SetParameters(String)

Sets a variable number of parameter values to audio hardware.

SetPreferredMixerAttributes(AudioAttributes, AudioDeviceInfo, AudioMixerAttributes)

Configures the mixer attributes for a particular AudioAttributes over a given AudioDeviceInfo.

SetRouting(Mode, Route, Route)
Obsolete.

Sets the audio routing for a specified mode

SetStreamMute(Stream, Boolean)

Mute or unmute an audio stream.

SetStreamSolo(Stream, Boolean)

Solo or unsolo a particular stream.

SetStreamVolume(Stream, Int32, VolumeNotificationFlags)

Sets the volume index for a particular stream.

SetSurroundFormatEnabled(Int32, Boolean)

Sets and persists a certain surround format as enabled or not.

SetVibrateSetting(VibrateType, VibrateSetting)
Obsolete.

Sets the setting for when the vibrate type should vibrate.

ShouldVibrate(VibrateType)
Obsolete.

Returns whether a particular type should vibrate according to user settings and the current ringer mode.

StartBluetoothSco()

Start bluetooth SCO audio connection.

StopBluetoothSco()

Stop bluetooth SCO audio connection.

ToArray<T>() (Inherited from Object)
ToString()

Returns a string representation of the object.

(Inherited from Object)
UnloadSoundEffects()

Unload Sound effects.

UnregisterAudioDeviceCallback(AudioDeviceCallback)

Unregisters an AudioDeviceCallback object which has been previously registered to receive notifications of changes to the set of connected audio devices.

UnregisterAudioPlaybackCallback(AudioManager+AudioPlaybackCallback)

Unregister an audio playback callback previously registered with #registerAudioPlaybackCallback(AudioPlaybackCallback, Handler).

UnregisterAudioRecordingCallback(AudioManager+AudioRecordingCallback)

Unregister an audio recording callback previously registered with #registerAudioRecordingCallback(AudioRecordingCallback, Handler).

UnregisterFromRuntime() (Inherited from Object)
UnregisterMediaButtonEventReceiver(ComponentName)
Obsolete.

Unregister the receiver of MEDIA_BUTTON intents.

UnregisterMediaButtonEventReceiver(PendingIntent)
Obsolete.

Unregister the receiver of MEDIA_BUTTON intents.

UnregisterRemoteControlClient(RemoteControlClient)
Obsolete.

Unregisters the remote control client that was providing information to display on the remote controls.

UnregisterRemoteController(RemoteController)
Obsolete.

Unregisters a RemoteController, causing it to no longer receive media metadata and playback state information, and no longer be capable of controlling playback.

Wait()

Causes the current thread to wait until it is awakened, typically by being <em>notified</em> or <em>interrupted</em>.

(Inherited from Object)
Wait(Int64)

Causes the current thread to wait until it is awakened, typically by being <em>notified</em> or <em>interrupted</em>, or until a certain amount of real time has elapsed.

(Inherited from Object)
Wait(Int64, Int32)

Causes the current thread to wait until it is awakened, typically by being <em>notified</em> or <em>interrupted</em>, or until a certain amount of real time has elapsed.

(Inherited from Object)

Explicit Interface Implementations

IJavaPeerable.Disposed() (Inherited from Object)
IJavaPeerable.DisposeUnlessReferenced() (Inherited from Object)
IJavaPeerable.Finalized() (Inherited from Object)
IJavaPeerable.JniManagedPeerState (Inherited from Object)
IJavaPeerable.SetJniIdentityHashCode(Int32) (Inherited from Object)
IJavaPeerable.SetJniManagedPeerState(JniManagedPeerStates) (Inherited from Object)
IJavaPeerable.SetPeerReference(JniObjectReference) (Inherited from Object)

Extension Methods

JavaCast<TResult>(IJavaObject)

Performs an Android runtime-checked type conversion.

JavaCast<TResult>(IJavaObject)
GetJniTypeName(IJavaPeerable)

Applies to