|
Build 1.0_r1(from source) | |||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectandroid.media.AudioManager
public class AudioManager
AudioManager provides access to volume and ringer mode control.
Use Context.getSystemService(Context.AUDIO_SERVICE) to get
an instance of this class.
| Field Summary | |
|---|---|
static int |
ADJUST_LOWER
Decrease the ringer volume. |
static int |
ADJUST_RAISE
Increase the ringer volume. |
static int |
ADJUST_SAME
Maintain the previous ringer volume. |
static int[] |
DEFAULT_STREAM_VOLUME
|
static String |
EXTRA_RINGER_MODE
The new ringer mode. |
static String |
EXTRA_VIBRATE_SETTING
The new vibrate setting for a particular type. |
static String |
EXTRA_VIBRATE_TYPE
The vibrate type whose setting has changed. |
static int |
FLAG_ALLOW_RINGER_MODES
Whether to include ringer modes as possible options when changing volume. |
static int |
FLAG_PLAY_SOUND
Whether to play a sound when changing the volume. |
static int |
FLAG_REMOVE_SOUND_AND_VIBRATE
Removes any sounds/vibrate that may be in the queue, or are playing (related to changing volume). |
static int |
FLAG_SHOW_UI
Show a toast containing the current volume. |
static int |
FLAG_VIBRATE
Whether to vibrate if going into the vibrate ringer mode. |
static int |
FX_FOCUS_NAVIGATION_DOWN
Focuse has moved down |
static int |
FX_FOCUS_NAVIGATION_LEFT
Focuse has moved left |
static int |
FX_FOCUS_NAVIGATION_RIGHT
Focuse has moved right |
static int |
FX_FOCUS_NAVIGATION_UP
Focuse has moved up |
static int |
FX_KEY_CLICK
Keyboard and direction pad click sound |
static int[] |
MAX_STREAM_VOLUME
|
static int |
MODE_CURRENT
Current audio mode. |
static int |
MODE_IN_CALL
In call audio mode. |
static int |
MODE_INVALID
Invalid audio mode. |
static int |
MODE_NORMAL
Normal audio mode: not ringing and no call established. |
static int |
MODE_RINGTONE
Ringing audio mode. |
static int |
NUM_SOUND_EFFECTS
|
static int |
NUM_STREAMS
Number of audio streams |
static String |
RINGER_MODE_CHANGED_ACTION
Sticky broadcast intent action indicating that the ringer mode has changed. |
static int |
RINGER_MODE_NORMAL
Ringer mode that may be audible and may vibrate. |
static int |
RINGER_MODE_SILENT
Ringer mode that will be silent and will not vibrate. |
static int |
RINGER_MODE_VIBRATE
Ringer mode that will be silent and will vibrate. |
static int |
ROUTE_ALL
Used for mask parameter of setRouting(int,int,int). |
static int |
ROUTE_BLUETOOTH
Routing audio output to bluetooth |
static int |
ROUTE_EARPIECE
Routing audio output to earpiece |
static int |
ROUTE_HEADSET
Routing audio output to headset |
static int |
ROUTE_SPEAKER
Routing audio output to spaker |
static int |
STREAM_ALARM
The audio stream for alarms |
static int |
STREAM_MUSIC
The audio stream for music playback |
static int |
STREAM_RING
The audio stream for the phone ring and message alerts |
static int |
STREAM_SYSTEM
The audio stream for system sounds |
static int |
STREAM_VOICE_CALL
The audio stream for phone calls |
static int |
USE_DEFAULT_STREAM_TYPE
Suggests using the default stream type. |
static String |
VIBRATE_SETTING_CHANGED_ACTION
Broadcast intent action indicating that the vibrate setting has changed. |
static int |
VIBRATE_SETTING_OFF
Vibrate setting that suggests to never vibrate. |
static int |
VIBRATE_SETTING_ON
Vibrate setting that suggests to vibrate when possible. |
static int |
VIBRATE_SETTING_ONLY_SILENT
Vibrate setting that suggests to only vibrate when in the vibrate ringer mode. |
static int |
VIBRATE_TYPE_NOTIFICATION
Vibrate type that corresponds to notifications. |
static int |
VIBRATE_TYPE_RINGER
Vibrate type that corresponds to the ringer. |
| Constructor Summary | |
|---|---|
AudioManager(Context context)
|
|
| Method Summary | |
|---|---|
void |
adjustStreamVolume(int streamType,
int direction,
int flags)
Adjusts the volume of a particular stream by one step in a direction. |
void |
adjustSuggestedStreamVolume(int direction,
int suggestedStreamType,
int flags)
Adjusts the volume of the most relevant stream, or the given fallback stream. |
void |
adjustVolume(int direction,
int flags)
Adjusts the volume of the most relevant stream. |
int |
getMode()
Returns the current audio mode. |
int |
getRingerMode()
Returns the current ringtone mode. |
int |
getRouting(int mode)
Returns the current audio routing bit vector for a specified mode. |
int |
getStreamMaxVolume(int streamType)
Returns the maximum volume index for a particular stream. |
int |
getStreamVolume(int streamType)
Returns the current volume index for a particular stream. |
int |
getVibrateSetting(int vibrateType)
Returns whether the user's vibrate setting for a vibrate type. |
boolean |
isBluetoothScoOn()
Checks whether audio routing to the Bluetooth headset is on or off. |
boolean |
isMicrophoneMute()
Checks whether the microphone mute is on or off. |
boolean |
isMusicActive()
Checks whether any music is active. |
boolean |
isSpeakerphoneOn()
Checks whether the speakerphone is on or off. |
void |
loadSoundEffects()
Load Sound effects. |
void |
playSoundEffect(int effectType)
Plays a sound effect (Key clicks, lid open/close...) |
void |
setBluetoothScoOn(boolean on)
Sets audio routing to the Bluetooth headset on or off. |
void |
setMicrophoneMute(boolean on)
Sets the microphone mute on or off. |
void |
setMode(int mode)
Sets the audio mode. |
void |
setParameter(String key,
String value)
|
void |
setRingerMode(int ringerMode)
Sets the ringer mode. |
void |
setRouting(int mode,
int routes,
int mask)
Sets the audio routing for a specified mode |
void |
setSpeakerphoneOn(boolean on)
Sets the speakerphone on or off. |
void |
setStreamMute(int streamType,
boolean state)
Mute or unmute an audio stream. |
void |
setStreamSolo(int streamType,
boolean state)
Solo or unsolo a particular stream. |
void |
setStreamVolume(int streamType,
int index,
int flags)
Sets the volume index for a particular stream. |
void |
setVibrateSetting(int vibrateType,
int vibrateSetting)
Sets the setting for when the vibrate type should vibrate. |
boolean |
shouldVibrate(int vibrateType)
Returns whether a particular type should vibrate according to user settings and the current ringer mode. |
void |
unloadSoundEffects()
Unload Sound effects. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
public static final String RINGER_MODE_CHANGED_ACTION
EXTRA_RINGER_MODE,
Constant Field Valuespublic static final String EXTRA_RINGER_MODE
RINGER_MODE_CHANGED_ACTION,
RINGER_MODE_NORMAL,
RINGER_MODE_SILENT,
RINGER_MODE_VIBRATE,
Constant Field Valuespublic static final String VIBRATE_SETTING_CHANGED_ACTION
EXTRA_VIBRATE_TYPE,
EXTRA_VIBRATE_SETTING,
Constant Field Valuespublic static final String EXTRA_VIBRATE_SETTING
VIBRATE_SETTING_CHANGED_ACTION,
EXTRA_VIBRATE_TYPE,
VIBRATE_SETTING_ON,
VIBRATE_SETTING_OFF,
VIBRATE_SETTING_ONLY_SILENT,
Constant Field Valuespublic static final String EXTRA_VIBRATE_TYPE
VIBRATE_SETTING_CHANGED_ACTION,
VIBRATE_TYPE_NOTIFICATION,
VIBRATE_TYPE_RINGER,
Constant Field Valuespublic static final int STREAM_VOICE_CALL
public static final int STREAM_SYSTEM
public static final int STREAM_RING
public static final int STREAM_MUSIC
public static final int STREAM_ALARM
public static final int NUM_STREAMS
public static final int[] MAX_STREAM_VOLUME
public static final int[] DEFAULT_STREAM_VOLUME
public static final int ADJUST_RAISE
adjustVolume(int, int),
adjustStreamVolume(int, int, int),
Constant Field Valuespublic static final int ADJUST_LOWER
adjustVolume(int, int),
adjustStreamVolume(int, int, int),
Constant Field Valuespublic static final int ADJUST_SAME
adjustVolume(int, int),
adjustStreamVolume(int, int, int),
Constant Field Valuespublic static final int FLAG_SHOW_UI
adjustStreamVolume(int, int, int),
adjustVolume(int, int),
setStreamVolume(int, int, int),
setRingerMode(int),
Constant Field Valuespublic static final int FLAG_ALLOW_RINGER_MODES
ADJUST_LOWER, then the ringer mode may switch the silent
or vibrate mode.
By default this is on for stream types that are affected by the ringer mode (for example, the ring stream type). If this flag is included, this behavior will be present regardless of the stream type being affected by the ringer mode.
adjustVolume(int, int),
adjustStreamVolume(int, int, int),
Constant Field Valuespublic static final int FLAG_PLAY_SOUND
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).
adjustStreamVolume(int, int, int),
adjustVolume(int, int),
setStreamVolume(int, int, int),
Constant Field Valuespublic static final int FLAG_REMOVE_SOUND_AND_VIBRATE
public static final int FLAG_VIBRATE
public static final int RINGER_MODE_SILENT
setRingerMode(int),
getRingerMode(),
Constant Field Valuespublic static final int RINGER_MODE_VIBRATE
setRingerMode(int),
getRingerMode(),
Constant Field Valuespublic static final int RINGER_MODE_NORMAL
setRingerMode(int),
getRingerMode(),
Constant Field Valuespublic static final int VIBRATE_TYPE_RINGER
setVibrateSetting(int, int),
getVibrateSetting(int),
shouldVibrate(int),
Constant Field Valuespublic static final int VIBRATE_TYPE_NOTIFICATION
setVibrateSetting(int, int),
getVibrateSetting(int),
shouldVibrate(int),
Constant Field Valuespublic static final int VIBRATE_SETTING_OFF
setVibrateSetting(int, int),
getVibrateSetting(int),
Constant Field Valuespublic static final int VIBRATE_SETTING_ON
setVibrateSetting(int, int),
getVibrateSetting(int),
Constant Field Valuespublic static final int VIBRATE_SETTING_ONLY_SILENT
setVibrateSetting(int, int),
getVibrateSetting(int),
Constant Field Valuespublic static final int USE_DEFAULT_STREAM_TYPE
public static final int MODE_INVALID
public static final int MODE_CURRENT
public static final int MODE_NORMAL
public static final int MODE_RINGTONE
public static final int MODE_IN_CALL
public static final int ROUTE_EARPIECE
public static final int ROUTE_SPEAKER
public static final int ROUTE_BLUETOOTH
public static final int ROUTE_HEADSET
public static final int ROUTE_ALL
setRouting(int,int,int).
public static final int FX_KEY_CLICK
playSoundEffect(int),
Constant Field Valuespublic static final int FX_FOCUS_NAVIGATION_UP
playSoundEffect(int),
Constant Field Valuespublic static final int FX_FOCUS_NAVIGATION_DOWN
playSoundEffect(int),
Constant Field Valuespublic static final int FX_FOCUS_NAVIGATION_LEFT
playSoundEffect(int),
Constant Field Valuespublic static final int FX_FOCUS_NAVIGATION_RIGHT
playSoundEffect(int),
Constant Field Valuespublic static final int NUM_SOUND_EFFECTS
| Constructor Detail |
|---|
public AudioManager(Context context)
| Method Detail |
|---|
public void adjustStreamVolume(int streamType,
int direction,
int flags)
streamType - The stream type to adjust. One of STREAM_VOICE_CALL,
STREAM_SYSTEM, STREAM_RING, STREAM_MUSIC or
STREAM_ALARMdirection - The direction to adjust the volume. One of
ADJUST_LOWER, ADJUST_RAISE, or
ADJUST_SAME.flags - One or more flags.adjustVolume(int, int),
setStreamVolume(int, int, int)
public void adjustVolume(int direction,
int flags)
direction - The direction to adjust the volume. One of
ADJUST_LOWER, ADJUST_RAISE, or
ADJUST_SAME.flags - One or more flags.adjustSuggestedStreamVolume(int, int, int),
adjustStreamVolume(int, int, int),
setStreamVolume(int, int, int)
public void adjustSuggestedStreamVolume(int direction,
int suggestedStreamType,
int flags)
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.adjustVolume(int, int),
adjustStreamVolume(int, int, int),
setStreamVolume(int, int, int)public int getRingerMode()
RINGER_MODE_NORMAL,
RINGER_MODE_SILENT, or RINGER_MODE_VIBRATE.setRingerMode(int)public int getStreamMaxVolume(int streamType)
streamType - The stream type whose maximum volume index is returned.
getStreamVolume(int)public int getStreamVolume(int streamType)
streamType - The stream type whose volume index is returned.
getStreamMaxVolume(int),
setStreamVolume(int, int, int)public void setRingerMode(int ringerMode)
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.getRingerMode()
public void setStreamVolume(int streamType,
int index,
int flags)
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.getStreamMaxVolume(int),
getStreamVolume(int)
public void setStreamSolo(int streamType,
boolean state)
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
public void setStreamMute(int streamType,
boolean state)
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.
streamType - The stream to be muted/unmuted.state - The required mute state: true for mute ON, false for mute OFFpublic boolean shouldVibrate(int vibrateType)
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.
setVibrateSetting(int, int),
getVibrateSetting(int)public int getVibrateSetting(int vibrateType)
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.setVibrateSetting(int, int),
shouldVibrate(int)
public void setVibrateSetting(int vibrateType,
int vibrateSetting)
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.getVibrateSetting(int),
shouldVibrate(int)public void setSpeakerphoneOn(boolean on)
on - set true to turn on speakerphone;
false to turn it offpublic boolean isSpeakerphoneOn()
public void setBluetoothScoOn(boolean on)
on - set true to route SCO (voice) audio to/from Bluetooth
headset; false to route audio to/from phone earpiecepublic boolean isBluetoothScoOn()
public void setMicrophoneMute(boolean on)
on - set true to mute the microphone;
false to turn mute offpublic boolean isMicrophoneMute()
public void setMode(int mode)
mode - the requested audio mode (NORMAL, RINGTONE, or IN_CALL).
Informs the HAL about the current audio state so that
it can route the audio appropriately.public int getMode()
public void setRouting(int mode,
int routes,
int mask)
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 onmask - bit vector of routes to change, created from one or more of
ROUTE_xxx types. Unset bits indicate the route should be left unchangedpublic int getRouting(int mode)
mode - audio mode to get route (e.g., MODE_RINGTONE)
public boolean isMusicActive()
public void setParameter(String key,
String value)
public void playSoundEffect(int effectType)
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,public void loadSoundEffects()
public void unloadSoundEffects()
|
Build 1.0_r1(from source) | |||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||