AudioManagerCompat


@UnstableApi
class AudioManagerCompat


Compatibility layer for AudioManager with fallbacks for older Android versions.

Summary

Nested types

@Documented
@Retention(value = RetentionPolicy.SOURCE)
@Target(value = TYPE_USE)
@IntDef(value = )
annotation AudioManagerCompat.AudioFocusGain

Audio focus gain types.

Constants

const Int

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

const Int

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

const Int

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 Int

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 Int

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

Public functions

java-static Int
abandonAudioFocusRequest(
    audioManager: AudioManager!,
    focusRequest: AudioFocusRequestCompat!
)

Abandon audio focus.

java-static @IntRange(from = 0) Int
getStreamMaxVolume(
    audioManager: AudioManager!,
    @C.StreamType streamType: Int
)

Returns the maximum volume index for a particular stream.

java-static @IntRange(from = 0) Int
getStreamMinVolume(
    audioManager: AudioManager!,
    @C.StreamType streamType: Int
)

Returns the minimum volume index for a particular stream.

java-static Int
requestAudioFocus(
    audioManager: AudioManager!,
    focusRequest: AudioFocusRequestCompat!
)

Requests audio focus.

Constants

AUDIOFOCUS_GAIN

const val AUDIOFOCUS_GAIN = 1: Int

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

AUDIOFOCUS_GAIN_TRANSIENT

const val AUDIOFOCUS_GAIN_TRANSIENT = 2: Int

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.

AUDIOFOCUS_GAIN_TRANSIENT_EXCLUSIVE

const val AUDIOFOCUS_GAIN_TRANSIENT_EXCLUSIVE = 4: Int

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

const val AUDIOFOCUS_GAIN_TRANSIENT_MAY_DUCK = 3: Int

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_NONE

const val AUDIOFOCUS_NONE = 0: Int

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

Public functions

abandonAudioFocusRequest

java-static fun abandonAudioFocusRequest(
    audioManager: AudioManager!,
    focusRequest: AudioFocusRequestCompat!
): Int

Abandon audio focus. Causes the previous focus owner, if any, to receive focus.

Parameters
audioManager: AudioManager!

The AudioManager.

focusRequest: AudioFocusRequestCompat!

The AudioFocusRequestCompat that was used when requesting focus with requestAudioFocus.

getStreamMaxVolume

java-static fun getStreamMaxVolume(
    audioManager: AudioManager!,
    @C.StreamType streamType: Int
): @IntRange(from = 0) Int

Returns the maximum volume index for a particular stream.

Parameters
audioManager: AudioManager!

The AudioManager.

@C.StreamType streamType: Int

The C.StreamType whose maximum volume index is returned.

Returns
@IntRange(from = 0) Int

The maximum valid volume index for the stream.

getStreamMinVolume

java-static fun getStreamMinVolume(
    audioManager: AudioManager!,
    @C.StreamType streamType: Int
): @IntRange(from = 0) Int

Returns the minimum volume index for a particular stream.

Parameters
audioManager: AudioManager!

The AudioManager.

@C.StreamType streamType: Int

The C.StreamType whose minimum volume index is returned.

Returns
@IntRange(from = 0) Int

The minimum valid volume index for the stream.

requestAudioFocus

java-static fun requestAudioFocus(
    audioManager: AudioManager!,
    focusRequest: AudioFocusRequestCompat!
): Int

Requests audio focus. See the AudioFocusRequestCompat for information about the options available to configure your request, and notification of focus gain and loss.

Parameters
audioManager: AudioManager!

The AudioManager.

focusRequest: AudioFocusRequestCompat!

An AudioFocusRequestCompat instance used to configure how focus is requested.