java.lang.Object | |
↳ | android.media.AudioManager |
AudioManager provides access to volume and ringer mode control.
Use Context.getSystemService(Context.AUDIO_SERVICE)
to get
an instance of this class.
Nested Classes | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
AudioManager.OnAudioFocusChangeListener | Interface definition for a callback to be invoked when the audio focus of the system is updated. |
Constants | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
String | ACTION_AUDIO_BECOMING_NOISY | Broadcast intent, a hint for applications that audio is about to become 'noisy' due to a change in audio outputs. | |||||||||
String | ACTION_SCO_AUDIO_STATE_CHANGED |
This constant was deprecated
in API level 14.
Use ACTION_SCO_AUDIO_STATE_UPDATED instead
|
|||||||||
String | ACTION_SCO_AUDIO_STATE_UPDATED | Sticky broadcast intent action indicating that the bluetoooth SCO audio connection state has been updated. | |||||||||
int | ADJUST_LOWER | Decrease the ringer volume. | |||||||||
int | ADJUST_RAISE | Increase the ringer volume. | |||||||||
int | ADJUST_SAME | Maintain the previous ringer volume. | |||||||||
int | AUDIOFOCUS_GAIN | Used to indicate a gain of audio focus, or a request of audio focus, of unknown duration. | |||||||||
int | AUDIOFOCUS_GAIN_TRANSIENT | Used to indicate a temporary gain or request of audio focus, anticipated to last a short amount of time. | |||||||||
int | 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. | |||||||||
int | 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"). | |||||||||
int | AUDIOFOCUS_LOSS | Used to indicate a loss of audio focus of unknown duration. | |||||||||
int | AUDIOFOCUS_LOSS_TRANSIENT | Used to indicate a transient loss of audio focus. | |||||||||
int | 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. | |||||||||
int | AUDIOFOCUS_REQUEST_FAILED | A failed focus change request. | |||||||||
int | AUDIOFOCUS_REQUEST_GRANTED | A successful focus change request. | |||||||||
String | EXTRA_RINGER_MODE | The new ringer mode. | |||||||||
String | EXTRA_SCO_AUDIO_PREVIOUS_STATE | Extra for intent ACTION_SCO_AUDIO_STATE_UPDATED containing the previous
bluetooth SCO connection state. |
|||||||||
String | EXTRA_SCO_AUDIO_STATE | Extra for intent ACTION_SCO_AUDIO_STATE_CHANGED or
ACTION_SCO_AUDIO_STATE_UPDATED containing the new bluetooth SCO connection state. |
|||||||||
String | EXTRA_VIBRATE_SETTING |
This constant was deprecated
in API level 16.
Applications should maintain their own vibrate policy based on
current ringer mode and listen to RINGER_MODE_CHANGED_ACTION instead.
|
|||||||||
String | EXTRA_VIBRATE_TYPE |
This constant was deprecated
in API level 16.
Applications should maintain their own vibrate policy based on
current ringer mode and listen to RINGER_MODE_CHANGED_ACTION instead.
|
|||||||||
int | FLAG_ALLOW_RINGER_MODES | Whether to include ringer modes as possible options when changing volume. | |||||||||
int | FLAG_PLAY_SOUND | Whether to play a sound when changing the volume. | |||||||||
int | FLAG_REMOVE_SOUND_AND_VIBRATE | Removes any sounds/vibrate that may be in the queue, or are playing (related to changing volume). | |||||||||
int | FLAG_SHOW_UI | Show a toast containing the current volume. | |||||||||
int | FLAG_VIBRATE | Whether to vibrate if going into the vibrate ringer mode. | |||||||||
int | FX_FOCUS_NAVIGATION_DOWN | Focus has moved down | |||||||||
int | FX_FOCUS_NAVIGATION_LEFT | Focus has moved left | |||||||||
int | FX_FOCUS_NAVIGATION_RIGHT | Focus has moved right | |||||||||
int | FX_FOCUS_NAVIGATION_UP | Focus has moved up | |||||||||
int | FX_KEYPRESS_DELETE | IME delete keypress sound | |||||||||
int | FX_KEYPRESS_INVALID | Invalid keypress sound | |||||||||
int | FX_KEYPRESS_RETURN | IME return_keypress sound | |||||||||
int | FX_KEYPRESS_SPACEBAR | IME spacebar keypress sound | |||||||||
int | FX_KEYPRESS_STANDARD | IME standard keypress sound | |||||||||
int | FX_KEY_CLICK | Keyboard and direction pad click sound | |||||||||
int | MODE_CURRENT | Current audio mode. | |||||||||
int | MODE_INVALID | Invalid audio mode. | |||||||||
int | MODE_IN_CALL | In call audio mode. | |||||||||
int | MODE_IN_COMMUNICATION | In communication audio mode. | |||||||||
int | MODE_NORMAL | Normal audio mode: not ringing and no call established. | |||||||||
int | MODE_RINGTONE | Ringing audio mode. | |||||||||
int | NUM_STREAMS | This constant was deprecated in API level 3. Use AudioSystem.getNumStreamTypes() instead | |||||||||
String | 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 primary output stream, in decimal PCM frames. |
|||||||||
String | PROPERTY_OUTPUT_SAMPLE_RATE | Used as a key for getProperty(String) to request the native or optimal output sample rate
for this device's primary output stream, in decimal Hz. |
|||||||||
String | RINGER_MODE_CHANGED_ACTION | Sticky broadcast intent action indicating that the ringer mode has changed. | |||||||||
int | RINGER_MODE_NORMAL | Ringer mode that may be audible and may vibrate. | |||||||||
int | RINGER_MODE_SILENT | Ringer mode that will be silent and will not vibrate. | |||||||||
int | RINGER_MODE_VIBRATE | Ringer mode that will be silent and will vibrate. | |||||||||
int | ROUTE_ALL | This constant was deprecated in API level 5. Do not set audio routing directly, use setSpeakerphoneOn(), setBluetoothScoOn() methods instead. | |||||||||
int | ROUTE_BLUETOOTH |
This constant was deprecated
in API level 3.
use ROUTE_BLUETOOTH_SCO Do not set audio routing directly, use setSpeakerphoneOn(),
setBluetoothScoOn() methods instead.
|
|||||||||
int | ROUTE_BLUETOOTH_A2DP | This constant was deprecated in API level 5. Do not set audio routing directly, use setSpeakerphoneOn(), setBluetoothScoOn() methods instead. | |||||||||
int | ROUTE_BLUETOOTH_SCO | This constant was deprecated in API level 5. Do not set audio routing directly, use setSpeakerphoneOn(), setBluetoothScoOn() methods instead. | |||||||||
int | ROUTE_EARPIECE | This constant was deprecated in API level 5. Do not set audio routing directly, use setSpeakerphoneOn(), setBluetoothScoOn() methods instead. | |||||||||
int | ROUTE_HEADSET | This constant was deprecated in API level 5. Do not set audio routing directly, use setSpeakerphoneOn(), setBluetoothScoOn() methods instead. | |||||||||
int | ROUTE_SPEAKER | This constant was deprecated in API level 5. Do not set audio routing directly, use setSpeakerphoneOn(), setBluetoothScoOn() methods instead. | |||||||||
int | SCO_AUDIO_STATE_CONNECTED | Value for extra EXTRA_SCO_AUDIO_STATE or EXTRA_SCO_AUDIO_PREVIOUS_STATE
indicating that the SCO audio channel is established
|
|||||||||
int | SCO_AUDIO_STATE_CONNECTING | Value for extra EXTRA_SCO_AUDIO_STATE or EXTRA_SCO_AUDIO_PREVIOUS_STATE indicating that the SCO audio channel is being established | |||||||||
int | SCO_AUDIO_STATE_DISCONNECTED | Value for extra EXTRA_SCO_AUDIO_STATE or EXTRA_SCO_AUDIO_PREVIOUS_STATE indicating that the SCO audio channel is not established | |||||||||
int | SCO_AUDIO_STATE_ERROR | Value for extra EXTRA_SCO_AUDIO_STATE indicating that there was an error trying to obtain the state | |||||||||
int | STREAM_ALARM | The audio stream for alarms | |||||||||
int | STREAM_DTMF | The audio stream for DTMF Tones | |||||||||
int | STREAM_MUSIC | The audio stream for music playback | |||||||||
int | STREAM_NOTIFICATION | The audio stream for notifications | |||||||||
int | STREAM_RING | The audio stream for the phone ring | |||||||||
int | STREAM_SYSTEM | The audio stream for system sounds | |||||||||
int | STREAM_VOICE_CALL | The audio stream for phone calls | |||||||||
int | USE_DEFAULT_STREAM_TYPE | Suggests using the default stream type. | |||||||||
String | VIBRATE_SETTING_CHANGED_ACTION |
This constant was deprecated
in API level 16.
Applications should maintain their own vibrate policy based on
current ringer mode and listen to RINGER_MODE_CHANGED_ACTION instead.
|
|||||||||
int | VIBRATE_SETTING_OFF |
This constant was deprecated
in API level 16.
Applications should maintain their own vibrate policy based on
current ringer mode that can be queried via getRingerMode() .
|
|||||||||
int | VIBRATE_SETTING_ON |
This constant was deprecated
in API level 16.
Applications should maintain their own vibrate policy based on
current ringer mode that can be queried via getRingerMode() .
|
|||||||||
int | VIBRATE_SETTING_ONLY_SILENT |
This constant was deprecated
in API level 16.
Applications should maintain their own vibrate policy based on
current ringer mode that can be queried via getRingerMode() .
|
|||||||||
int | VIBRATE_TYPE_NOTIFICATION |
This constant was deprecated
in API level 16.
Applications should maintain their own vibrate policy based on
current ringer mode that can be queried via getRingerMode() .
|
|||||||||
int | VIBRATE_TYPE_RINGER |
This constant was deprecated
in API level 16.
Applications should maintain their own vibrate policy based on
current ringer mode that can be queried via getRingerMode() .
|
Public Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
Abandon audio focus.
| |||||||||||
Adjusts the volume of a particular stream by one step in a direction.
| |||||||||||
Adjusts the volume of the most relevant stream, or the given fallback
stream.
| |||||||||||
Adjusts the volume of the most relevant stream.
| |||||||||||
Sends a simulated key event for a media button.
| |||||||||||
Returns the current audio mode.
| |||||||||||
Gets a variable number of parameter values from audio hardware.
| |||||||||||
Returns the value of the property with the specified key.
| |||||||||||
Returns the current ringtone mode.
| |||||||||||
This method was deprecated
in API level 4.
Do not query audio routing directly, use isSpeakerphoneOn(),
isBluetoothScoOn(), isBluetoothA2dpOn() and isWiredHeadsetOn() methods instead.
| |||||||||||
Returns the maximum volume index for a particular stream.
| |||||||||||
Returns the current volume index for a particular stream.
| |||||||||||
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() .
| |||||||||||
Checks whether A2DP audio routing to the Bluetooth headset is on or off.
| |||||||||||
Indicates if current platform supports use of SCO for off call use cases.
| |||||||||||
Checks whether communications use Bluetooth SCO.
| |||||||||||
Checks whether the microphone mute is on or off.
| |||||||||||
Checks whether any music is active.
| |||||||||||
Checks whether the speakerphone is on or off.
| |||||||||||
This method was deprecated
in API level 14.
Use only to check is a headset is connected or not.
| |||||||||||
Load Sound effects.
| |||||||||||
Plays a sound effect (Key clicks, lid open/close...)
| |||||||||||
Plays a sound effect (Key clicks, lid open/close...)
| |||||||||||
Register a component to be the sole receiver of MEDIA_BUTTON intents.
| |||||||||||
Register a component to be the sole receiver of MEDIA_BUTTON intents.
| |||||||||||
Registers the remote control client for providing information to display on the remote
controls.
| |||||||||||
Registers a
RemoteController instance for it to receive media metadata updates
and playback state information from applications using RemoteControlClient , and
control their playback. | |||||||||||
Request audio focus.
| |||||||||||
This method was deprecated
in API level 5.
Do not use.
| |||||||||||
Request use of Bluetooth SCO headset for communications.
| |||||||||||
Sets the microphone mute on or off.
| |||||||||||
Sets the audio mode.
| |||||||||||
Sets a variable number of parameter values to audio hardware.
| |||||||||||
Sets the ringer mode.
| |||||||||||
This method was deprecated
in API level 4.
Do not set audio routing directly, use setSpeakerphoneOn(),
setBluetoothScoOn() methods instead.
| |||||||||||
Sets the speakerphone on or off.
| |||||||||||
Mute or unmute an audio stream.
| |||||||||||
Solo or unsolo a particular stream.
| |||||||||||
Sets the volume index for a particular stream.
| |||||||||||
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() .
| |||||||||||
This method was deprecated
in API level 5.
Do not use.
| |||||||||||
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() .
| |||||||||||
Start bluetooth SCO audio connection.
| |||||||||||
Stop bluetooth SCO audio connection.
| |||||||||||
Unload Sound effects.
| |||||||||||
Unregister the receiver of MEDIA_BUTTON intents.
| |||||||||||
Unregister the receiver of MEDIA_BUTTON intents.
| |||||||||||
Unregisters the remote control client that was providing information to display on the
remote controls.
| |||||||||||
Unregisters a
RemoteController , causing it to no longer receive media metadata and
playback state information, and no longer be capable of controlling playback. |
[Expand]
Inherited Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
From class
java.lang.Object
|
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.
This constant was deprecated
in API level 14.
Use ACTION_SCO_AUDIO_STATE_UPDATED
instead
Sticky broadcast intent action indicating that the bluetoooth SCO audio
connection state has changed. The intent contains on extra EXTRA_SCO_AUDIO_STATE
indicating the new state which is either SCO_AUDIO_STATE_DISCONNECTED
or SCO_AUDIO_STATE_CONNECTED
Sticky broadcast intent action indicating that the bluetoooth SCO audio connection state has been updated.
This intent has two extras:
EXTRA_SCO_AUDIO_STATE
- The new SCO audio state. EXTRA_SCO_AUDIO_PREVIOUS_STATE
- The previous SCO audio state. EXTRA_SCO_AUDIO_STATE or EXTRA_SCO_AUDIO_PREVIOUS_STATE can be any of:
Decrease the ringer volume.
Increase the ringer volume.
Maintain the previous ringer volume. This may be useful when needing to show the volume toast without actually modifying the volume.
Used to indicate a gain of audio focus, or a request of audio focus, of unknown duration.
Used to indicate a temporary gain or request of audio focus, anticipated to last a short amount of time. Examples of temporary changes are the playback of driving directions, or an event notification.
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.
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.
Used to indicate a loss of audio focus of unknown duration.
Used to indicate a transient loss of audio focus.
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.
A failed focus change request.
A successful focus change request.
The new ringer mode.
Extra for intent ACTION_SCO_AUDIO_STATE_UPDATED
containing the previous
bluetooth SCO connection state.
Extra for intent ACTION_SCO_AUDIO_STATE_CHANGED
or
ACTION_SCO_AUDIO_STATE_UPDATED
containing the new bluetooth SCO connection state.
This constant was deprecated
in API level 16.
Applications should maintain their own vibrate policy based on
current ringer mode and listen to RINGER_MODE_CHANGED_ACTION
instead.
The new vibrate setting for a particular type.
This constant was deprecated
in API level 16.
Applications should maintain their own vibrate policy based on
current ringer mode and listen to RINGER_MODE_CHANGED_ACTION
instead.
The vibrate type whose setting has changed.
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.
Whether to play a sound when changing the volume.
If this is given to adjustVolume(int, int)
or
adjustSuggestedStreamVolume(int, int, int)
, it may be ignored
in some cases (for example, the decided stream type is not
STREAM_RING
, or the volume is being adjusted
downward).
Removes any sounds/vibrate that may be in the queue, or are playing (related to changing volume).
Show a toast containing the current volume.
Whether to vibrate if going into the vibrate ringer mode.
Current audio mode. Used to apply audio routing to current mode.
Invalid audio mode.
In call audio mode. A telephony call is established.
In communication audio mode. An audio/video chat or VoIP call is established.
Normal audio mode: not ringing and no call established.
Ringing audio mode. An incoming is being signaled.
This constant was deprecated
in API level 3.
Use AudioSystem.getNumStreamTypes() instead
Used as a key for getProperty(String)
to request the native or optimal output buffer size
for this device's primary output stream, in decimal PCM frames.
Used as a key for getProperty(String)
to request the native or optimal output sample rate
for this device's primary output stream, in decimal Hz.
Sticky broadcast intent action indicating that the ringer mode has changed. Includes the new ringer mode.
Ringer mode that may be audible and may vibrate. It will be audible if the volume before changing out of this mode was audible. It will vibrate if the vibrate setting is on.
Ringer mode that will be silent and will not vibrate. (This overrides the vibrate setting.)
Ringer mode that will be silent and will vibrate. (This will cause the phone ringer to always vibrate, but the notification vibrate to only vibrate if set.)
This constant was deprecated
in API level 5.
Do not set audio routing directly, use setSpeakerphoneOn(),
setBluetoothScoOn() methods instead.
Used for mask parameter of setRouting(int, int, int)
.
This constant was deprecated
in API level 3.
use ROUTE_BLUETOOTH_SCO
Do not set audio routing directly, use setSpeakerphoneOn(),
setBluetoothScoOn() methods instead.
This constant was deprecated
in API level 5.
Do not set audio routing directly, use setSpeakerphoneOn(),
setBluetoothScoOn() methods instead.
Routing audio output to bluetooth A2DP
This constant was deprecated
in API level 5.
Do not set audio routing directly, use setSpeakerphoneOn(),
setBluetoothScoOn() methods instead.
Routing audio output to bluetooth SCO
This constant was deprecated
in API level 5.
Do not set audio routing directly, use setSpeakerphoneOn(),
setBluetoothScoOn() methods instead.
Routing audio output to earpiece
This constant was deprecated
in API level 5.
Do not set audio routing directly, use setSpeakerphoneOn(),
setBluetoothScoOn() methods instead.
Routing audio output to headset
This constant was deprecated
in API level 5.
Do not set audio routing directly, use setSpeakerphoneOn(),
setBluetoothScoOn() methods instead.
Routing audio output to speaker
Value for extra EXTRA_SCO_AUDIO_STATE
or EXTRA_SCO_AUDIO_PREVIOUS_STATE
indicating that the SCO audio channel is established
Value for extra EXTRA_SCO_AUDIO_STATE or EXTRA_SCO_AUDIO_PREVIOUS_STATE indicating that the SCO audio channel is being established
Value for extra EXTRA_SCO_AUDIO_STATE or EXTRA_SCO_AUDIO_PREVIOUS_STATE indicating that the SCO audio channel is not established
Value for extra EXTRA_SCO_AUDIO_STATE indicating that there was an error trying to obtain the state
The audio stream for alarms
The audio stream for DTMF Tones
The audio stream for music playback
The audio stream for notifications
The audio stream for the phone ring
The audio stream for system sounds
The audio stream for phone calls
Suggests using the default stream type. This may not be used in all places a stream type is needed.
This constant was deprecated
in API level 16.
Applications should maintain their own vibrate policy based on
current ringer mode and listen to RINGER_MODE_CHANGED_ACTION
instead.
Broadcast intent action indicating that the vibrate setting has changed. Includes the vibrate type and its new setting.
This constant was deprecated
in API level 16.
Applications should maintain their own vibrate policy based on
current ringer mode that can be queried via getRingerMode()
.
Vibrate setting that suggests to never vibrate.
This constant was deprecated
in API level 16.
Applications should maintain their own vibrate policy based on
current ringer mode that can be queried via getRingerMode()
.
Vibrate setting that suggests to vibrate when possible.
This constant was deprecated
in API level 16.
Applications should maintain their own vibrate policy based on
current ringer mode that can be queried via getRingerMode()
.
Vibrate setting that suggests to only vibrate when in the vibrate ringer mode.
This constant was deprecated
in API level 16.
Applications should maintain their own vibrate policy based on
current ringer mode that can be queried via getRingerMode()
.
Vibrate type that corresponds to notifications.
This constant was deprecated
in API level 16.
Applications should maintain their own vibrate policy based on
current ringer mode that can be queried via getRingerMode()
.
Vibrate type that corresponds to the ringer.
Abandon audio focus. Causes the previous focus owner, if any, to receive focus.
l | the listener with which focus was requested. |
---|
Adjusts the volume of a particular stream by one step in a direction.
This method should only be used by applications that replace the platform-wide management of audio settings or the main telephony application.
streamType | The stream type to adjust. One of STREAM_VOICE_CALL ,
STREAM_SYSTEM , STREAM_RING , STREAM_MUSIC or
STREAM_ALARM |
---|---|
direction | The direction to adjust the volume. One of
ADJUST_LOWER , ADJUST_RAISE , or
ADJUST_SAME . |
flags | One or more flags. |
Adjusts the volume of the most relevant stream, or the given fallback stream.
This method should only be used by applications that replace the platform-wide management of audio settings or the main telephony application.
direction | The direction to adjust the volume. One of
ADJUST_LOWER , ADJUST_RAISE , or
ADJUST_SAME . |
---|---|
suggestedStreamType | The stream type that will be used if there
isn't a relevant stream. USE_DEFAULT_STREAM_TYPE is valid here. |
flags | One or more flags. |
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.
direction | The direction to adjust the volume. One of
ADJUST_LOWER , ADJUST_RAISE , or
ADJUST_SAME . |
---|---|
flags | One or more flags. |
Sends a simulated key event for a media button.
To simulate a key press, you must first send a KeyEvent built with a
ACTION_DOWN
action, then another event with the ACTION_UP
action.
The key event will be sent to the current media key event consumer which registered with
registerMediaButtonEventReceiver(PendingIntent)
.
keyEvent | a KeyEvent instance whose key code is one of
KEYCODE_MUTE ,
KEYCODE_HEADSETHOOK ,
KEYCODE_MEDIA_PLAY ,
KEYCODE_MEDIA_PAUSE ,
KEYCODE_MEDIA_PLAY_PAUSE ,
KEYCODE_MEDIA_STOP ,
KEYCODE_MEDIA_NEXT ,
KEYCODE_MEDIA_PREVIOUS ,
KEYCODE_MEDIA_REWIND ,
KEYCODE_MEDIA_RECORD ,
KEYCODE_MEDIA_FAST_FORWARD ,
KEYCODE_MEDIA_CLOSE ,
KEYCODE_MEDIA_EJECT ,
or KEYCODE_MEDIA_AUDIO_TRACK .
|
---|
Returns the current audio mode.
MODE_NORMAL
, MODE_RINGTONE
,
MODE_IN_CALL
or MODE_IN_COMMUNICATION
).
Returns the current current audio state from the HAL.
Gets a variable number of parameter values from audio hardware.
keys | list of parameters |
---|
Returns the value of the property with the specified key.
key | One of the strings corresponding to a property key: either
PROPERTY_OUTPUT_SAMPLE_RATE or
PROPERTY_OUTPUT_FRAMES_PER_BUFFER |
---|
Returns the current ringtone mode.
RINGER_MODE_NORMAL
,
RINGER_MODE_SILENT
, or RINGER_MODE_VIBRATE
.
This method was deprecated
in API level 4.
Do not query audio routing directly, use isSpeakerphoneOn(),
isBluetoothScoOn(), isBluetoothA2dpOn() and isWiredHeadsetOn() methods instead.
Returns the current audio routing bit vector for a specified mode.
mode | audio mode to get route (e.g., MODE_RINGTONE) |
---|
Returns the maximum volume index for a particular stream.
streamType | The stream type whose maximum volume index is returned. |
---|
Returns the current volume index for a particular stream.
streamType | The stream type whose volume index is returned. |
---|
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 the user's vibrate setting for a vibrate type.
This shouldn't be needed by most clients that want to vibrate, instead
see shouldVibrate(int)
.
vibrateType | The type of vibrate. One of
VIBRATE_TYPE_NOTIFICATION or
VIBRATE_TYPE_RINGER . |
---|
VIBRATE_SETTING_ON
,
VIBRATE_SETTING_OFF
, or
VIBRATE_SETTING_ONLY_SILENT
.Checks whether A2DP audio routing to the Bluetooth headset is on or off.
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.
Checks whether communications use Bluetooth SCO.
Checks whether the microphone mute is on or off.
Checks whether any music is active.
Checks whether the speakerphone is on or off.
This method was deprecated
in API level 14.
Use only to check is a headset is connected or not.
Checks whether a wired headset is connected or not.
This is not a valid indication that audio playback is actually over the wired headset as audio routing depends on other conditions.
Load Sound effects. This method must be called when sound effects are enabled.
Plays a sound effect (Key clicks, lid open/close...)
effectType | The type of sound effect. One of
FX_KEY_CLICK ,
FX_FOCUS_NAVIGATION_UP ,
FX_FOCUS_NAVIGATION_DOWN ,
FX_FOCUS_NAVIGATION_LEFT ,
FX_FOCUS_NAVIGATION_RIGHT ,
FX_KEYPRESS_STANDARD ,
FX_KEYPRESS_SPACEBAR ,
FX_KEYPRESS_DELETE ,
FX_KEYPRESS_RETURN ,
FX_KEYPRESS_INVALID , |
---|---|
volume | 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. |
Plays a sound effect (Key clicks, lid open/close...)
effectType | The type of sound effect. One of
FX_KEY_CLICK ,
FX_FOCUS_NAVIGATION_UP ,
FX_FOCUS_NAVIGATION_DOWN ,
FX_FOCUS_NAVIGATION_LEFT ,
FX_FOCUS_NAVIGATION_RIGHT ,
FX_KEYPRESS_STANDARD ,
FX_KEYPRESS_SPACEBAR ,
FX_KEYPRESS_DELETE ,
FX_KEYPRESS_RETURN ,
FX_KEYPRESS_INVALID ,
NOTE: This version uses the UI settings to determine
whether sounds are heard or not.
|
---|
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.
eventReceiver | target that will receive media button intents. The PendingIntent
will be sent as-is when a media button action occurs, with EXTRA_KEY_EVENT
added and holding the key code of the media button that was pressed.
|
---|
Register a component to be the sole receiver of MEDIA_BUTTON intents.
eventReceiver | 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.
|
---|
Registers the remote control client for providing information to display on the remote controls.
rcClient | The remote control client from which remote controls will receive information to display. |
---|
Registers a RemoteController
instance for it to receive media metadata updates
and playback state information from applications using RemoteControlClient
, and
control their playback.
Registration requires the RemoteController.OnClientUpdateListener
listener to be one of the
enabled notification listeners (see
NotificationListenerService
).
rctlr | the object to register. |
---|
RemoteController
was successfully registered, false if an
error occurred, due to an internal system error, or insufficient permissions.
Request audio focus. Send a request to obtain the audio focus
l | the listener to be notified of audio focus changes |
---|---|
streamType | the main audio stream type affected by the focus request |
durationHint | 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. |
This method was deprecated
in API level 5.
Do not use.
on | set true to route A2DP audio to/from Bluetooth headset; false disable A2DP audio |
---|
Request use of Bluetooth SCO headset for communications.
This method should only be used by applications that replace the platform-wide management of audio settings or the main telephony application.
on | set true to use bluetooth SCO for communications; false to not use bluetooth SCO for communications |
---|
Sets the microphone mute on or off.
This method should only be used by applications that replace the platform-wide management of audio settings or the main telephony application.
on | set true to mute the microphone; false to turn mute off |
---|
Sets the audio mode.
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.
mode | the requested audio mode (MODE_NORMAL , MODE_RINGTONE ,
MODE_IN_CALL or MODE_IN_COMMUNICATION ).
Informs the HAL about the current audio state so that
it can route the audio appropriately.
|
---|
Sets a variable number of parameter values to audio hardware.
keyValuePairs | list of parameters key value pairs in the form: key1=value1;key2=value2;... |
---|
Sets the ringer mode.
Silent mode will mute the volume and will not vibrate. Vibrate mode will mute the volume and vibrate. Normal mode will be audible and may vibrate according to user settings.
ringerMode | The ringer mode, one of RINGER_MODE_NORMAL ,
RINGER_MODE_SILENT , or RINGER_MODE_VIBRATE . |
---|
This method was deprecated
in API level 4.
Do not set audio routing directly, use setSpeakerphoneOn(),
setBluetoothScoOn() methods instead.
Sets the audio routing for a specified mode
mode | audio mode to change route. E.g., MODE_RINGTONE. |
---|---|
routes | bit vector of routes requested, created from one or more of ROUTE_xxx types. Set bits indicate that route should be on |
mask | bit vector of routes to change, created from one or more of ROUTE_xxx types. Unset bits indicate the route should be left unchanged |
Sets the speakerphone on or off.
This method should only be used by applications that replace the platform-wide management of audio settings or the main telephony application.
on | set true to turn on speakerphone; false to turn it off |
---|
Mute or unmute an audio stream.
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.
This method should only be used by applications that replace the platform-wide management of audio settings or the main telephony application.
streamType | The stream to be muted/unmuted. |
---|---|
state | The required mute state: true for mute ON, false for mute OFF |
Solo or unsolo a particular stream. All other streams are muted.
The solo command is protected against client process death: if a process with an active solo request on a stream dies, all streams that were muted because of this request will be unmuted automatically.
The solo requests for a given stream are cumulative: the AudioManager can receive several solo requests from one or more clients and the stream will be unsoloed only when the same number of unsolo requests are received.
For a better user experience, applications MUST unsolo a soloed stream in onPause() and solo is again in onResume() if appropriate.
streamType | The stream to be soloed/unsoloed. |
---|---|
state | The required solo state: true for solo ON, false for solo OFF |
Sets the volume index for a particular stream.
streamType | The stream whose volume index should be set. |
---|---|
index | The volume index to set. See
getStreamMaxVolume(int) for the largest valid value. |
flags | One or more flags. |
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()
.
Sets the setting for when the vibrate type should vibrate.
This method should only be used by applications that replace the platform-wide management of audio settings or the main telephony application.
vibrateType | The type of vibrate. One of
VIBRATE_TYPE_NOTIFICATION or
VIBRATE_TYPE_RINGER . |
---|---|
vibrateSetting | The vibrate setting, one of
VIBRATE_SETTING_ON ,
VIBRATE_SETTING_OFF , or
VIBRATE_SETTING_ONLY_SILENT . |
This method was deprecated
in API level 5.
Do not use.
Sets audio routing to the wired headset on or off.
on | set true to route audio to/from wired headset; false disable wired headset audio |
---|
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.
vibrateType | The type of vibrate. One of
VIBRATE_TYPE_NOTIFICATION or
VIBRATE_TYPE_RINGER . |
---|
Start bluetooth SCO audio connection.
Requires Permission:
MODIFY_AUDIO_SETTINGS
.
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: 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.
STREAM_VOICE_CALL
The following restrictions apply on input streams:
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.
Stop bluetooth SCO audio connection.
Requires Permission:
MODIFY_AUDIO_SETTINGS
.
This method must be called by applications having requested the use of
bluetooth SCO audio with startBluetoothSco()
when finished with the SCO connection or if connection fails.
Unload Sound effects. This method can be called to free some memory when sound effects are disabled.
Unregister the receiver of MEDIA_BUTTON intents.
eventReceiver | identifier of a BroadcastReceiver
that was registered with registerMediaButtonEventReceiver(ComponentName) .
|
---|
Unregister the receiver of MEDIA_BUTTON intents.
eventReceiver | same PendingIntent that was registed with
registerMediaButtonEventReceiver(PendingIntent) .
|
---|
Unregisters the remote control client that was providing information to display on the remote controls.
rcClient | The remote control client to unregister. |
---|
Unregisters a RemoteController
, causing it to no longer receive media metadata and
playback state information, and no longer be capable of controlling playback.
rctlr | the object to unregister. |
---|