Android Guides | Samples

Android.Media.AudioManager Class

AudioManager provides access to volume and ringer mode control.

See Also: AudioManager

Syntax

[Android.Runtime.Register("android/media/AudioManager", DoNotGenerateAcw=true)]
public class AudioManager : Object

Remarks

AudioManager provides access to volume and ringer mode control.

Use Context.getSystemService(Context.AUDIO_SERVICE) to get an instance of this class.

[Android Documentation]

Requirements

Namespace: Android.Media
Assembly: Mono.Android (in Mono.Android.dll)
Assembly Versions: 0.0.0.0
Since: Added in API level 1

The members of Android.Media.AudioManager are listed below.

See Also: Object

Protected Constructors

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

Public Fields

const
ActionAudioBecomingNoisyString. Broadcast intent, a hint for applications that audio is about to become 'noisy' due to a change in audio outputs.
const
ActionHdmiAudioPlugString. Broadcast Action: A sticky broadcast indicating an HDMI cable was plugged or unplugged.
const
ActionHeadsetPlugString. Broadcast Action: Wired Headset plugged in or unplugged.
const
ActionScoAudioStateChangedString. Sticky broadcast intent action indicating that the bluetoooth SCO audio connection state has changed.
const
ActionScoAudioStateUpdatedString. Sticky broadcast intent action indicating that the bluetoooth SCO audio connection state has been updated.
const
AudiofocusGainAudioFocus (1). Used to indicate a gain of audio focus, or a request of audio focus, of unknown duration.
const
AudiofocusGainTransientAudioFocus (2). Used to indicate a temporary gain or request of audio focus, anticipated to last a short amount of time.
const
AudiofocusGainTransientExclusiveAudioFocus (4). 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.
const
AudiofocusGainTransientMayDuckAudioFocus (3). 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").
const
AudiofocusLossAudioFocus (-1). Used to indicate a loss of audio focus of unknown duration.
const
AudiofocusLossTransientAudioFocus (-2). Used to indicate a transient loss of audio focus.
const
AudiofocusLossTransientCanDuckAudioFocus (-3). 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.
const
AudiofocusRequestFailedAudioFocusRequest (0). A failed focus change request.
const
AudiofocusRequestGrantedAudioFocusRequest (1). A successful focus change request.
const
AudioSessionIdGenerateInt32 (0). A special audio session ID to indicate that the audio session ID isn't known and the framework should generate a new value.
const
ErrorInt32 (-1). A default error code.
const
ErrorDeadObjectInt32 (-6). An error code indicating that the object reporting it is no longer valid and needs to be recreated.
const
ExtraAudioPlugStateString. Extra used in AudioManager.ActionHdmiAudioPlug to communicate whether HDMI is plugged in or unplugged.
const
ExtraEncodingsString. Extra used in AudioManager.ActionHdmiAudioPlug to define the audio encodings supported by the connected HDMI device.
const
ExtraMaxChannelCountString. Extra used in AudioManager.ActionHdmiAudioPlug to define the maximum number of channels supported by the HDMI device.
const
ExtraRingerModeString. The new ringer mode.
const
ExtraScoAudioPreviousStateString. Extra for intent AudioManager.ActionScoAudioStateUpdated containing the previous bluetooth SCO connection state.
const
ExtraScoAudioStateString. Extra for intent AudioManager.ActionScoAudioStateChanged or AudioManager.ActionScoAudioStateUpdated containing the new bluetooth SCO connection state.
const
ExtraVibrateSettingString. The new vibrate setting for a particular type.
const
ExtraVibrateTypeString. The vibrate type whose setting has changed.
const
NumStreamsInt32 (5).
const
PropertyOutputFramesPerBufferString. Used as a key for AudioManager.GetProperty(String) to request the native or optimal output buffer size for this device's primary output stream, in decimal PCM frames.
const
PropertyOutputSampleRateString. Used as a key for AudioManager.GetProperty(String) to request the native or optimal output sample rate for this device's primary output stream, in decimal Hz.
const
RingerModeChangedActionString. Sticky broadcast intent action indicating that the ringer mode has changed.
const
ScoAudioStateConnectedScoAudioState (1). Value for extra AudioManager.ExtraScoAudioState or AudioManager.ExtraScoAudioPreviousState indicating that the SCO audio channel is established
const
ScoAudioStateConnectingScoAudioState (2). Value for extra EXTRA_SCO_AUDIO_STATE or EXTRA_SCO_AUDIO_PREVIOUS_STATE indicating that the SCO audio channel is being established
const
ScoAudioStateDisconnectedScoAudioState (0). Value for extra EXTRA_SCO_AUDIO_STATE or EXTRA_SCO_AUDIO_PREVIOUS_STATE indicating that the SCO audio channel is not established
const
ScoAudioStateErrorScoAudioState (-1). Value for extra EXTRA_SCO_AUDIO_STATE indicating that there was an error trying to obtain the state
const
UseDefaultStreamTypeInt32 (-2147483648). Suggests using the default stream type.
const
VibrateSettingChangedActionString. Broadcast intent action indicating that the vibrate setting has changed.

Public Properties

BluetoothA2dpOnBoolean. Checks whether A2DP audio routing to the Bluetooth headset is on or off.
BluetoothScoOnBoolean. Checks whether communications use Bluetooth SCO.
[read-only]
IsBluetoothScoAvailableOffCallBoolean. Indicates if current platform supports use of SCO for off call use cases.
[read-only]
IsMusicActiveBoolean. Checks whether any music is active.
[read-only]
IsVolumeFixedBoolean. Indicates if the device implements a fixed volume policy.
MicrophoneMuteBoolean. Checks whether the microphone mute is on or off.
ModeMode. Returns the current audio mode.
RingerModeRingerMode. Returns the current ringtone mode.
SpeakerphoneOnBoolean. Checks whether the speakerphone is on or off.
WiredHeadsetOnBoolean. Checks whether a wired headset is connected or not.

Protected Properties

[read-only]
override
ThresholdClassIntPtr. This API supports the Mono for Android infrastructure and is not intended to be used directly from your code.
[read-only]
override
ThresholdTypeType. This API supports the Mono for Android infrastructure and is not intended to be used directly from your code.

Public Methods

AbandonAudioFocus(AudioManager+IOnAudioFocusChangeListener) : AudioFocusRequest
Abandon audio focus.
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.
DispatchMediaKeyEvent(KeyEvent)
Sends a simulated key event for a media button.
static
FromContext(Context) : AudioManager
GenerateAudioSessionId() : Int32
Return a new audio session identifier not associated with any player or effect.
GetParameters(String) : String
Gets a variable number of parameter values from audio hardware.
GetProperty(String) : String
Returns the value of the property with the specified key.
GetRouting(Mode) : Route
Returns the current audio routing bit vector for a specified mode.
GetStreamMaxVolume(Stream) : Int32
Returns the maximum volume index for a particular stream.
GetStreamVolume(Stream) : Int32
Returns the current volume index for a particular stream.
GetVibrateSetting(VibrateType) : VibrateSetting
Returns whether the user's vibrate setting for a vibrate type.
LoadSoundEffects()
Load Sound effects.
LoadSoundEffectsAsync() : Task
PlaySoundEffect(SoundEffect)
Plays a sound effect (Key clicks, lid open/close.
PlaySoundEffect(SoundEffect, Single)
Plays a sound effect (Key clicks, lid open/close.
RegisterMediaButtonEventReceiver(PendingIntent)
Register a component to be the sole receiver of MEDIA_BUTTON intents.
RegisterMediaButtonEventReceiver(ComponentName)
Register a component to be the sole receiver of MEDIA_BUTTON intents.
RegisterRemoteControlClient(RemoteControlClient)
Registers the remote control client for providing information to display on the remote controls.
RegisterRemoteController(RemoteController) : Boolean
Registers a RemoteController instance for it to receive media metadata updates and playback state information from applications using RemoteControlClient, and control their playback.
RequestAudioFocus(AudioManager+IOnAudioFocusChangeListener, Stream, AudioFocus) : AudioFocusRequest
Request audio focus.
SetParameters(String)
Sets a variable number of parameter values to audio hardware.
SetRouting(Mode, Route, Route)
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.
SetVibrateSetting(VibrateType, VibrateSetting)
Sets the setting for when the vibrate type should vibrate.
ShouldVibrate(VibrateType) : Boolean
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.
UnloadSoundEffects()
Unload Sound effects.
UnregisterMediaButtonEventReceiver(PendingIntent)
Unregister the receiver of MEDIA_BUTTON intents.
UnregisterMediaButtonEventReceiver(ComponentName)
Unregister the receiver of MEDIA_BUTTON intents.
UnregisterRemoteControlClient(RemoteControlClient)
Unregisters the remote control client that was providing information to display on the remote controls.
UnregisterRemoteController(RemoteController)
Unregisters a RemoteController, causing it to no longer receive media metadata and playback state information, and no longer be capable of controlling playback.