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").

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.

Causes the current thread to wait until another thread invokes the
notify() method or the
notifyAll() method for this object, or
some other thread interrupts the current thread, or a certain
amount of real time has elapsed.

Constants

ACTION_AUDIO_BECOMING_NOISY

Broadcast intent, a hint for applications that audio is about to become
'noisy' due to a change in audio outputs. For example, this intent may
be sent when a wired headset is unplugged, or when an A2DP audio
sink is disconnected, and the audio system is about to automatically
switch audio route to the speaker. Applications that are controlling
audio streams may consider pausing, reducing volume or some other action
on receipt of this intent so as not to surprise the user with audio
from the speaker.

AUDIOFOCUS_GAIN_TRANSIENT_EXCLUSIVE

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. Examples of exclusive and transient audio focus requests are voice
memo recording and speech recognition, during which the system shouldn't play any
notifications, and media playback should have paused.

AUDIOFOCUS_GAIN_TRANSIENT_MAY_DUCK

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").
Examples of temporary changes are the playback of driving directions where playback of music
in the background is acceptable.

AUDIOFOCUS_LOSS_TRANSIENT_CAN_DUCK

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.

EXTRA_MAX_CHANNEL_COUNT

Extra used in ACTION_HDMI_AUDIO_PLUG to define the maximum number of channels
supported by the HDMI device.
The corresponding integer value is only available when the device is plugged in (as expressed
by EXTRA_AUDIO_PLUG_STATE).

FLAG_ALLOW_RINGER_MODES

Whether to include ringer modes as possible options when changing volume.
For example, if true and volume level is 0 and the volume is adjusted
with ADJUST_LOWER, then the ringer mode may switch the silent or
vibrate mode.

By default this is on for the ring stream. If this flag is included,
this behavior will be present regardless of the stream type being
affected by the ringer mode.

PROPERTY_OUTPUT_FRAMES_PER_BUFFER

Used as a key for getProperty(String) to request the native or optimal output buffer size
for this device's low latency output stream, in decimal PCM frames. Latency-sensitive apps
should use this value as a minimum, and offer the user the option to override it.
The low latency output stream is typically either the device's primary output stream,
or another output stream with smaller buffers.

Constant Value:
"android.media.property.OUTPUT_FRAMES_PER_BUFFER"

PROPERTY_OUTPUT_SAMPLE_RATE

Used as a key for getProperty(String) to request the native or optimal output sample rate
for this device's low latency output stream, in decimal Hz. Latency-sensitive apps
should use this value as a default, and offer the user the option to override it.
The low latency output stream is typically either the device's primary output stream,
or another output stream with smaller buffers.

adjustVolume

Adjusts the volume of the most relevant stream. For example, if a call is
active, it will have the highest priority regardless of if the in-call
screen is showing. Another example, if music is playing in the background
and a call is not active, the music stream will be adjusted.

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().

generateAudioSessionId

Return a new audio session identifier not associated with any player or effect.
An audio session identifier is a system wide unique identifier for a set of audio streams
(one or more mixed together).

The primary use of the audio session ID is to associate audio effects to audio players,
such as MediaPlayer or AudioTrack: all audio effects sharing the same audio
session ID will be applied to the mixed audio content of the players that share the same
audio session.

This method can for instance be used when creating one of the
AudioEffect objects to define the audio session of the effect,
or to specify a session for a speech synthesis utterance
in TextToSpeech.Engine.

Returns

int

a new unclaimed and unused audio session identifier, or ERROR when the
system failed to generate a new session, a condition in which audio playback or recording
will subsequently fail as well.

isBluetoothScoAvailableOffCall

Indicates if current platform supports use of SCO for off call use cases.
Application wanted to use bluetooth SCO audio when the phone is not in call
must first call this method to make sure that the platform supports this
feature.

Returns

boolean

true if bluetooth SCO can be used for audio when not in call
false otherwise

float: Sound effect volume.
The volume value is a raw scalar so UI controls should be scaled logarithmically.
If a volume of -1 is specified, the AudioManager.STREAM_MUSIC stream volume minus 3dB will be used.
NOTE: This version is for applications that have their own
settings panel for enabling and controlling volume.

ComponentName: identifier of a BroadcastReceiver
that will receive the media button intent. This broadcast receiver must be declared
in the application manifest. The package of the component must match that of
the context you're registering from.

registerMediaButtonEventReceiver

Register a component to be the sole receiver of MEDIA_BUTTON intents. This is like
registerMediaButtonEventReceiver(android.content.ComponentName), but allows
the buttons to go to any PendingIntent. Note that you should only use this form if
you know you will continue running for the full time until unregistering the
PendingIntent.

Parameters

eventReceiver

PendingIntent: target that will receive media button intents. The PendingIntent
will be sent an ACTION_MEDIA_BUTTON event when a media button action
occurs, with EXTRA_KEY_EVENT added and holding the key code of the
media button that was pressed.

AudioManager.OnAudioFocusChangeListener: the listener to be notified of audio focus changes

streamType

int: the main audio stream type affected by the focus request

durationHint

int: use AUDIOFOCUS_GAIN_TRANSIENT to indicate this focus request
is temporary, and focus will be abandonned shortly. Examples of transient requests are
for the playback of driving directions, or notifications sounds.
Use AUDIOFOCUS_GAIN_TRANSIENT_MAY_DUCK to indicate also that it's ok for
the previous focus owner to keep playing if it ducks its audio output.
Alternatively use AUDIOFOCUS_GAIN_TRANSIENT_EXCLUSIVE for a temporary request
that benefits from the system not playing disruptive sounds like notifications, for
usecases such as voice memo recording, or speech recognition.
Use AUDIOFOCUS_GAIN for a focus request of unknown duration such
as the playback of a song or a video.

setMode

The audio mode encompasses audio routing AND the behavior of
the telephony layer. Therefore this method should only be used by applications that
replace the platform-wide management of audio settings or the main telephony application.
In particular, the MODE_IN_CALL mode should only be used by the telephony
application when it places a phone call, as it will cause signals from the radio layer
to feed the platform mixer.

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:

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.

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.

For a better user experience, applications MUST unmute a muted stream
in onPause() and mute is again in onResume() if appropriate.

Parameters

streamType

int: The stream to be muted/unmuted.

state

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

shouldVibrate

This method was deprecated
in API level 16.
Applications should maintain their own vibrate policy based on
current ringer mode that can be queried via getRingerMode().

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

This shouldn't be needed by most clients that use notifications to
vibrate. The notification manager will not vibrate if the policy doesn't
allow it, so the client should always set a vibrate pattern and let the
notification manager control whether or not to actually vibrate.

startBluetoothSco

This method can be used by applications wanting to send and received audio
to/from a bluetooth SCO headset while the phone is not in call.

As the SCO connection establishment can take several seconds,
applications should not rely on the connection to be available when the method
returns but instead register to receive the intent ACTION_SCO_AUDIO_STATE_UPDATED
and wait for the state to be SCO_AUDIO_STATE_CONNECTED.

As the ACTION_SCO_AUDIO_STATE_UPDATED intent is sticky, the application can check the SCO
audio state before calling startBluetoothSco() by reading the intent returned by the receiver
registration. If the state is already CONNECTED, no state change will be received via the
intent after calling startBluetoothSco(). It is however useful to call startBluetoothSco()
so that the connection stays active in case the current initiator stops the connection.

Unless the connection is already active as described above, the state will always
transition from DISCONNECTED to CONNECTING and then either to CONNECTED if the connection
succeeds or back to DISCONNECTED if the connection fails (e.g no headset is connected).

When finished with the SCO connection or if the establishment fails, the application must
call stopBluetoothSco() to clear the request and turn down the bluetooth connection.

Even if a SCO connection is established, the following restrictions apply on audio
output streams so that they can be routed to SCO headset:

Note that the phone application always has the priority on the usage of the SCO
connection for telephony. If this method is called while the phone is in call
it will be ignored. Similarly, if a call is received or sent while an application
is using the SCO connection, the connection will be lost for the application and NOT
returned automatically when the call ends.

NOTE: up to and including API version
JELLY_BEAN_MR1, this method initiates a virtual
voice call to the bluetooth headset.
After API version JELLY_BEAN_MR2 only a raw SCO audio
connection is established.