# AudioAttributes

Added in [API level 21](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)  
Summary: [Nested Classes](https://developer.android.com/reference/android/media/AudioAttributes#nestedclasses) \| [Constants](https://developer.android.com/reference/android/media/AudioAttributes#constants) \| [Inherited Constants](https://developer.android.com/reference/android/media/AudioAttributes#inhconstants) \| [Fields](https://developer.android.com/reference/android/media/AudioAttributes#lfields) \| [Methods](https://developer.android.com/reference/android/media/AudioAttributes#pubmethods) \| [Inherited Methods](https://developer.android.com/reference/android/media/AudioAttributes#inhmethods)  

# AudioAttributes

*** ** * ** ***

[Kotlin](https://developer.android.com/reference/kotlin/android/media/AudioAttributes "View this page in Kotlin") \|Java


`
public

final

class
AudioAttributes
`


`

extends `[Object](https://developer.android.com/reference/java/lang/Object)`


`

`


implements

`[Parcelable](https://developer.android.com/reference/android/os/Parcelable)`


`

|---|-------------------------------|
| [java.lang.Object](https://developer.android.com/reference/java/lang/Object) ||
| ↳ | android.media.AudioAttributes |

<br />

*** ** * ** ***

A class to encapsulate a collection of attributes describing information about an audio
stream.

`AudioAttributes` supersede the notion of stream types (see for instance
[AudioManager.STREAM_MUSIC](https://developer.android.com/reference/android/media/AudioManager#STREAM_MUSIC) or [AudioManager.STREAM_ALARM](https://developer.android.com/reference/android/media/AudioManager#STREAM_ALARM)) for defining the
behavior of audio playback. Attributes allow an application to specify more information than is
conveyed in a stream type by allowing the application to define:

- usage: "why" you are playing a sound, what is this sound used for. This is achieved with the "usage" information. Examples of usage are [USAGE_MEDIA](https://developer.android.com/reference/android/media/AudioAttributes#USAGE_MEDIA) and [USAGE_ALARM](https://developer.android.com/reference/android/media/AudioAttributes#USAGE_ALARM). These two examples are the closest to stream types, but more detailed use cases are available. Usage information is more expressive than a stream type, and allows certain platforms or routing policies to use this information for more refined volume or routing decisions. Usage is the most important information to supply in `AudioAttributes` and it is recommended to build any instance with this information supplied, see [AudioAttributes.Builder](https://developer.android.com/reference/android/media/AudioAttributes.Builder) for exceptions.
- content type: "what" you are playing. The content type expresses the general category of the content. This information is optional. But in case it is known (for instance [CONTENT_TYPE_MOVIE](https://developer.android.com/reference/android/media/AudioAttributes#CONTENT_TYPE_MOVIE) for a movie streaming service or [CONTENT_TYPE_MUSIC](https://developer.android.com/reference/android/media/AudioAttributes#CONTENT_TYPE_MUSIC) for a music playback application) this information might be used by the audio framework to selectively configure some audio post-processing blocks.
- flags: "how" is playback to be affected, see the flag definitions for the specific playback behaviors they control.

`AudioAttributes` are used for example in one of the [AudioTrack](https://developer.android.com/reference/android/media/AudioTrack)
constructors (see [AudioTrack.AudioTrack(AudioAttributes, AudioFormat, int, int, int)](https://developer.android.com/reference/android/media/AudioTrack#AudioTrack(android.media.AudioAttributes,%20android.media.AudioFormat,%20int,%20int,%20int))),
to configure a [MediaPlayer](https://developer.android.com/reference/android/media/MediaPlayer)
(see [MediaPlayer.setAudioAttributes(AudioAttributes)](https://developer.android.com/reference/android/media/MediaPlayer#setAudioAttributes(android.media.AudioAttributes)) or a
[Notification](https://developer.android.com/reference/android/app/Notification) (see [Notification.audioAttributes](https://developer.android.com/reference/android/app/Notification#audioAttributes)). An
`AudioAttributes` instance is built through its builder,
[AudioAttributes.Builder](https://developer.android.com/reference/android/media/AudioAttributes.Builder).

## Summary

|                                                                                                           ### Nested classes                                                                                                           ||
|----------|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| ` class` | [AudioAttributes.Builder](https://developer.android.com/reference/android/media/AudioAttributes.Builder) Builder class for [AudioAttributes](https://developer.android.com/reference/android/media/AudioAttributes) objects. |

|                                                                                                                                                                                                                                       ### Constants                                                                                                                                                                                                                                        ||
|-------|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| `int` | [ALLOW_CAPTURE_BY_ALL](https://developer.android.com/reference/android/media/AudioAttributes#ALLOW_CAPTURE_BY_ALL) Indicates that the audio may be captured by any app.                                                                                                                                                                                                                                                                                                             |
| `int` | [ALLOW_CAPTURE_BY_NONE](https://developer.android.com/reference/android/media/AudioAttributes#ALLOW_CAPTURE_BY_NONE) Indicates that the audio is not to be recorded by any app, even if it is a system app.                                                                                                                                                                                                                                                                         |
| `int` | [ALLOW_CAPTURE_BY_SYSTEM](https://developer.android.com/reference/android/media/AudioAttributes#ALLOW_CAPTURE_BY_SYSTEM) Indicates that the audio may only be captured by system apps.                                                                                                                                                                                                                                                                                              |
| `int` | [CONTENT_TYPE_MOVIE](https://developer.android.com/reference/android/media/AudioAttributes#CONTENT_TYPE_MOVIE) Content type value to use when the content type is the audio typically accompanying a movie or TV program, containing a mix of dialogue, music and sound effects.                                                                                                                                                                                                    |
| `int` | [CONTENT_TYPE_MUSIC](https://developer.android.com/reference/android/media/AudioAttributes#CONTENT_TYPE_MUSIC) Content type value to use when the content type is music.                                                                                                                                                                                                                                                                                                            |
| `int` | [CONTENT_TYPE_SONIFICATION](https://developer.android.com/reference/android/media/AudioAttributes#CONTENT_TYPE_SONIFICATION) Content type value to use when the content type is a sound used to accompany a user action, such as a beep or sound effect expressing a key click, or event, such as the type of a sound for a bonus being received in a game.                                                                                                                         |
| `int` | [CONTENT_TYPE_SPEECH](https://developer.android.com/reference/android/media/AudioAttributes#CONTENT_TYPE_SPEECH) Content type value to use when the content type is speech.                                                                                                                                                                                                                                                                                                         |
| `int` | [CONTENT_TYPE_UNKNOWN](https://developer.android.com/reference/android/media/AudioAttributes#CONTENT_TYPE_UNKNOWN) Content type value to use when the content type is unknown, or other than the ones defined.                                                                                                                                                                                                                                                                      |
| `int` | [FLAG_AUDIBILITY_ENFORCED](https://developer.android.com/reference/android/media/AudioAttributes#FLAG_AUDIBILITY_ENFORCED) Flag defining a behavior where the audibility of the sound will be ensured by the system.                                                                                                                                                                                                                                                                |
| `int` | [FLAG_HW_AV_SYNC](https://developer.android.com/reference/android/media/AudioAttributes#FLAG_HW_AV_SYNC) Flag requesting the use of an output stream supporting hardware A/V synchronization.                                                                                                                                                                                                                                                                                       |
| `int` | [FLAG_LOW_LATENCY](https://developer.android.com/reference/android/media/AudioAttributes#FLAG_LOW_LATENCY) *This constant was deprecated in API level 26. Use [AudioTrack.Builder.setPerformanceMode(int)](https://developer.android.com/reference/android/media/AudioTrack.Builder#setPerformanceMode(int)) with [AudioTrack.PERFORMANCE_MODE_LOW_LATENCY](https://developer.android.com/reference/android/media/AudioTrack#PERFORMANCE_MODE_LOW_LATENCY) to control performance.* |
| `int` | [SPATIALIZATION_BEHAVIOR_AUTO](https://developer.android.com/reference/android/media/AudioAttributes#SPATIALIZATION_BEHAVIOR_AUTO) Constant indicating the audio content associated with these attributes will follow the default platform behavior with regards to which content will be spatialized or not.                                                                                                                                                                       |
| `int` | [SPATIALIZATION_BEHAVIOR_NEVER](https://developer.android.com/reference/android/media/AudioAttributes#SPATIALIZATION_BEHAVIOR_NEVER) Constant indicating the audio content associated with these attributes should never be virtualized.                                                                                                                                                                                                                                            |
| `int` | [USAGE_ALARM](https://developer.android.com/reference/android/media/AudioAttributes#USAGE_ALARM) Usage value to use when the usage is an alarm (e.g. wake-up alarm).                                                                                                                                                                                                                                                                                                                |
| `int` | [USAGE_ASSISTANCE_ACCESSIBILITY](https://developer.android.com/reference/android/media/AudioAttributes#USAGE_ASSISTANCE_ACCESSIBILITY) Usage value to use when the usage is for accessibility, such as with a screen reader.                                                                                                                                                                                                                                                        |
| `int` | [USAGE_ASSISTANCE_NAVIGATION_GUIDANCE](https://developer.android.com/reference/android/media/AudioAttributes#USAGE_ASSISTANCE_NAVIGATION_GUIDANCE) Usage value to use when the usage is driving or navigation directions.                                                                                                                                                                                                                                                           |
| `int` | [USAGE_ASSISTANCE_SONIFICATION](https://developer.android.com/reference/android/media/AudioAttributes#USAGE_ASSISTANCE_SONIFICATION) Usage value to use when the usage is sonification, such as with user interface sounds.                                                                                                                                                                                                                                                         |
| `int` | [USAGE_ASSISTANT](https://developer.android.com/reference/android/media/AudioAttributes#USAGE_ASSISTANT) Usage value to use for audio responses to user queries, audio instructions or help utterances.                                                                                                                                                                                                                                                                             |
| `int` | [USAGE_GAME](https://developer.android.com/reference/android/media/AudioAttributes#USAGE_GAME) Usage value to use when the usage is for game audio.                                                                                                                                                                                                                                                                                                                                 |
| `int` | [USAGE_MEDIA](https://developer.android.com/reference/android/media/AudioAttributes#USAGE_MEDIA) Usage value to use when the usage is media, such as music, or movie soundtracks.                                                                                                                                                                                                                                                                                                   |
| `int` | [USAGE_NOTIFICATION](https://developer.android.com/reference/android/media/AudioAttributes#USAGE_NOTIFICATION) Usage value to use when the usage is notification.                                                                                                                                                                                                                                                                                                                   |
| `int` | [USAGE_NOTIFICATION_COMMUNICATION_DELAYED](https://developer.android.com/reference/android/media/AudioAttributes#USAGE_NOTIFICATION_COMMUNICATION_DELAYED) *This constant was deprecated in API level 33. Use [USAGE_NOTIFICATION](https://developer.android.com/reference/android/media/AudioAttributes#USAGE_NOTIFICATION) which is handled the same way as this usage by the audio framework*                                                                                    |
| `int` | [USAGE_NOTIFICATION_COMMUNICATION_INSTANT](https://developer.android.com/reference/android/media/AudioAttributes#USAGE_NOTIFICATION_COMMUNICATION_INSTANT) *This constant was deprecated in API level 33. Use [USAGE_NOTIFICATION](https://developer.android.com/reference/android/media/AudioAttributes#USAGE_NOTIFICATION) which is handled the same way as this usage by the audio framework*                                                                                    |
| `int` | [USAGE_NOTIFICATION_COMMUNICATION_REQUEST](https://developer.android.com/reference/android/media/AudioAttributes#USAGE_NOTIFICATION_COMMUNICATION_REQUEST) *This constant was deprecated in API level 33. Use [USAGE_NOTIFICATION](https://developer.android.com/reference/android/media/AudioAttributes#USAGE_NOTIFICATION) which is handled the same way as this usage by the audio framework*                                                                                    |
| `int` | [USAGE_NOTIFICATION_EVENT](https://developer.android.com/reference/android/media/AudioAttributes#USAGE_NOTIFICATION_EVENT) Usage value to use when the usage is to attract the user's attention, such as a reminder or low battery warning.                                                                                                                                                                                                                                         |
| `int` | [USAGE_NOTIFICATION_RINGTONE](https://developer.android.com/reference/android/media/AudioAttributes#USAGE_NOTIFICATION_RINGTONE) Usage value to use when the usage is telephony ringtone.                                                                                                                                                                                                                                                                                           |
| `int` | [USAGE_UNKNOWN](https://developer.android.com/reference/android/media/AudioAttributes#USAGE_UNKNOWN) Usage value to use when the usage is unknown.                                                                                                                                                                                                                                                                                                                                  |
| `int` | [USAGE_VOICE_COMMUNICATION](https://developer.android.com/reference/android/media/AudioAttributes#USAGE_VOICE_COMMUNICATION) Usage value to use when the usage is voice communications, such as telephony or VoIP.                                                                                                                                                                                                                                                                  |
| `int` | [USAGE_VOICE_COMMUNICATION_SIGNALLING](https://developer.android.com/reference/android/media/AudioAttributes#USAGE_VOICE_COMMUNICATION_SIGNALLING) Usage value to use when the usage is in-call signalling, such as with a "busy" beep, or DTMF tones.                                                                                                                                                                                                                              |

|                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  ### Inherited constants                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   |
|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| From interface [android.os.Parcelable](https://developer.android.com/reference/android/os/Parcelable) |-------|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| | `int` | [CONTENTS_FILE_DESCRIPTOR](https://developer.android.com/reference/android/os/Parcelable#CONTENTS_FILE_DESCRIPTOR) Descriptor bit used with [describeContents()](https://developer.android.com/reference/android/os/Parcelable#describeContents()): indicates that the Parcelable object's flattened representation includes a file descriptor.                                                                                                                                            | | `int` | [PARCELABLE_WRITE_RETURN_VALUE](https://developer.android.com/reference/android/os/Parcelable#PARCELABLE_WRITE_RETURN_VALUE) Flag for use with [writeToParcel(Parcel, int)](https://developer.android.com/reference/android/os/Parcelable#writeToParcel(android.os.Parcel,%20int)): the object being written is a return value, that is the result of a function such as "`Parcelable someFunction()`", "`void someFunction(out Parcelable)`", or "`void someFunction(inout Parcelable)`". | |

|                                                                                                                                           ### Fields                                                                                                                                            ||
|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|------------------------------------------------------------------------------------------|
| ` public static final `[Creator](https://developer.android.com/reference/android/os/Parcelable.Creator)`<`[AudioAttributes](https://developer.android.com/reference/android/media/AudioAttributes)`>` | [CREATOR](https://developer.android.com/reference/android/media/AudioAttributes#CREATOR) |

|                                                                                                                                                                                           ### Public methods                                                                                                                                                                                            ||
|-----------------------------------------------------------------------|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| ` boolean`                                                            | ` `[areHapticChannelsMuted](https://developer.android.com/reference/android/media/AudioAttributes#areHapticChannelsMuted())`() ` Return if haptic channels are muted.                                                                                                                                                            |
| ` int`                                                                | ` `[describeContents](https://developer.android.com/reference/android/media/AudioAttributes#describeContents())`() ` Describe the kinds of special objects contained in this Parcelable instance's marshaled representation.                                                                                                     |
| ` boolean`                                                            | ` `[equals](https://developer.android.com/reference/android/media/AudioAttributes#equals(java.lang.Object))`(`[Object](https://developer.android.com/reference/java/lang/Object)` o) ` Indicates whether some other object is "equal to" this one.                                                                               |
| ` int`                                                                | ` `[getAllowedCapturePolicy](https://developer.android.com/reference/android/media/AudioAttributes#getAllowedCapturePolicy())`() ` Return the capture policy.                                                                                                                                                                    |
| ` int`                                                                | ` `[getContentType](https://developer.android.com/reference/android/media/AudioAttributes#getContentType())`() ` Return the content type.                                                                                                                                                                                        |
| ` int`                                                                | ` `[getFlags](https://developer.android.com/reference/android/media/AudioAttributes#getFlags())`() ` Return the flags.                                                                                                                                                                                                           |
| ` int`                                                                | ` `[getSpatializationBehavior](https://developer.android.com/reference/android/media/AudioAttributes#getSpatializationBehavior())`() ` Return the behavior affecting whether spatialization will be used.                                                                                                                        |
| ` int`                                                                | ` `[getUsage](https://developer.android.com/reference/android/media/AudioAttributes#getUsage())`() ` Return the usage.                                                                                                                                                                                                           |
| ` int`                                                                | ` `[getVolumeControlStream](https://developer.android.com/reference/android/media/AudioAttributes#getVolumeControlStream())`() ` Returns the stream type matching this `AudioAttributes` instance for volume control.                                                                                                            |
| ` int`                                                                | ` `[hashCode](https://developer.android.com/reference/android/media/AudioAttributes#hashCode())`() ` Returns a hash code value for the object.                                                                                                                                                                                   |
| ` boolean`                                                            | ` `[isContentSpatialized](https://developer.android.com/reference/android/media/AudioAttributes#isContentSpatialized())`() ` Return true if the audio content associated with these attributes has already been spatialized, that is it has already been processed to offer a binaural or transaural immersive audio experience. |
| ` `[String](https://developer.android.com/reference/java/lang/String) | ` `[toString](https://developer.android.com/reference/android/media/AudioAttributes#toString())`() ` Returns a string representation of the object.                                                                                                                                                                              |
| ` void`                                                               | ` `[writeToParcel](https://developer.android.com/reference/android/media/AudioAttributes#writeToParcel(android.os.Parcel,%20int))`(`[Parcel](https://developer.android.com/reference/android/os/Parcel)` dest, int flags) ` Flatten this object in to a Parcel.                                                                  |

| ### Inherited methods |
|-----------------------|---|
| From class ` `[java.lang.Object](https://developer.android.com/reference/java/lang/Object)` ` |--------------------------------------------------------------------------------|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| | ` `[Object](https://developer.android.com/reference/java/lang/Object)          | ` `[clone](https://developer.android.com/reference/java/lang/Object#clone())`() ` Creates and returns a copy of this object.                                                                                                                                                        | | ` boolean`                                                                     | ` `[equals](https://developer.android.com/reference/java/lang/Object#equals(java.lang.Object))`(`[Object](https://developer.android.com/reference/java/lang/Object)` obj) ` Indicates whether some other object is "equal to" this one.                                             | | ` void`                                                                        | ` `[finalize](https://developer.android.com/reference/java/lang/Object#finalize())`() ` Called by the garbage collector on an object when garbage collection determines that there are no more references to the object.                                                            | | ` final `[Class](https://developer.android.com/reference/java/lang/Class)`<?>` | ` `[getClass](https://developer.android.com/reference/java/lang/Object#getClass())`() ` Returns the runtime class of this `Object`.                                                                                                                                                 | | ` int`                                                                         | ` `[hashCode](https://developer.android.com/reference/java/lang/Object#hashCode())`() ` Returns a hash code value for the object.                                                                                                                                                   | | ` final void`                                                                  | ` `[notify](https://developer.android.com/reference/java/lang/Object#notify())`() ` Wakes up a single thread that is waiting on this object's monitor.                                                                                                                              | | ` final void`                                                                  | ` `[notifyAll](https://developer.android.com/reference/java/lang/Object#notifyAll())`() ` Wakes up all threads that are waiting on this object's monitor.                                                                                                                           | | ` `[String](https://developer.android.com/reference/java/lang/String)          | ` `[toString](https://developer.android.com/reference/java/lang/Object#toString())`() ` Returns a string representation of the object.                                                                                                                                              | | ` final void`                                                                  | ` `[wait](https://developer.android.com/reference/java/lang/Object#wait(long,%20int))`(long timeoutMillis, int nanos) ` Causes the current thread to wait until it is awakened, typically by being *notified* or *interrupted*, or until a certain amount of real time has elapsed. | | ` final void`                                                                  | ` `[wait](https://developer.android.com/reference/java/lang/Object#wait(long))`(long timeoutMillis) ` Causes the current thread to wait until it is awakened, typically by being *notified* or *interrupted*, or until a certain amount of real time has elapsed.                   | | ` final void`                                                                  | ` `[wait](https://developer.android.com/reference/java/lang/Object#wait())`() ` Causes the current thread to wait until it is awakened, typically by being *notified* or *interrupted*.                                                                                             | ||
| From interface ` `[android.os.Parcelable](https://developer.android.com/reference/android/os/Parcelable)` ` |------------------|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| | ` abstract int`  | ` `[describeContents](https://developer.android.com/reference/android/os/Parcelable#describeContents())`() ` Describe the kinds of special objects contained in this Parcelable instance's marshaled representation.                                    | | ` abstract void` | ` `[writeToParcel](https://developer.android.com/reference/android/os/Parcelable#writeToParcel(android.os.Parcel,%20int))`(`[Parcel](https://developer.android.com/reference/android/os/Parcel)` dest, int flags) ` Flatten this object in to a Parcel. | ||

## Constants

### ALLOW_CAPTURE_BY_ALL

Added in [API level 29](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)  

```
public static final int ALLOW_CAPTURE_BY_ALL
```

Indicates that the audio may be captured by any app.

For privacy, the following usages cannot be recorded: VOICE_COMMUNICATION\*,
USAGE_NOTIFICATION\*, USAGE_ASSISTANCE\* and USAGE_ASSISTANT.

On [Build.VERSION_CODES.Q](https://developer.android.com/reference/android/os/Build.VERSION_CODES#Q), this means only [USAGE_UNKNOWN](https://developer.android.com/reference/android/media/AudioAttributes#USAGE_UNKNOWN),
[USAGE_MEDIA](https://developer.android.com/reference/android/media/AudioAttributes#USAGE_MEDIA) and [USAGE_GAME](https://developer.android.com/reference/android/media/AudioAttributes#USAGE_GAME) may be captured.

See [MediaProjection](https://developer.android.com/reference/android/media/projection/MediaProjection) and
[Builder.setAllowedCapturePolicy](https://developer.android.com/reference/android/media/AudioAttributes.Builder#setAllowedCapturePolicy(int)).

<br />

Constant Value:

1
(0x00000001)


### ALLOW_CAPTURE_BY_NONE

Added in [API level 29](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)  

```
public static final int ALLOW_CAPTURE_BY_NONE
```

Indicates that the audio is not to be recorded by any app, even if it is a system app.

It is encouraged to use [ALLOW_CAPTURE_BY_SYSTEM](https://developer.android.com/reference/android/media/AudioAttributes#ALLOW_CAPTURE_BY_SYSTEM) instead of this value as system apps
provide significant and useful features for the user (such as live captioning
and accessibility).

See [Builder.setAllowedCapturePolicy](https://developer.android.com/reference/android/media/AudioAttributes.Builder#setAllowedCapturePolicy(int)).

<br />

Constant Value:

3
(0x00000003)


### ALLOW_CAPTURE_BY_SYSTEM

Added in [API level 29](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)  

```
public static final int ALLOW_CAPTURE_BY_SYSTEM
```

Indicates that the audio may only be captured by system apps.

System apps can capture for many purposes like accessibility, live captions, user guidance...
but abide to the following restrictions:
- the audio cannot leave the device
- the audio cannot be passed to a third party app
- the audio cannot be recorded at a higher quality than 16kHz 16bit mono

See [Builder.setAllowedCapturePolicy](https://developer.android.com/reference/android/media/AudioAttributes.Builder#setAllowedCapturePolicy(int)).

<br />

Constant Value:

2
(0x00000002)


### CONTENT_TYPE_MOVIE

Added in [API level 21](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)  

```
public static final int CONTENT_TYPE_MOVIE
```

Content type value to use when the content type is the audio typically accompanying
a movie or TV program, containing a mix of dialogue, music and sound effects.

<br />

Constant Value:

3
(0x00000003)


### CONTENT_TYPE_MUSIC

Added in [API level 21](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)  

```
public static final int CONTENT_TYPE_MUSIC
```

Content type value to use when the content type is music.

<br />

Constant Value:

2
(0x00000002)


### CONTENT_TYPE_SONIFICATION

Added in [API level 21](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)  

```
public static final int CONTENT_TYPE_SONIFICATION
```

Content type value to use when the content type is a sound used to accompany a user
action, such as a beep or sound effect expressing a key click, or event, such as the
type of a sound for a bonus being received in a game. These sounds are mostly synthesized
or short Foley sounds.

<br />

Constant Value:

4
(0x00000004)


### CONTENT_TYPE_SPEECH

Added in [API level 21](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)  

```
public static final int CONTENT_TYPE_SPEECH
```

Content type value to use when the content type is speech.

<br />

Constant Value:

1
(0x00000001)


### CONTENT_TYPE_UNKNOWN

Added in [API level 21](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)  

```
public static final int CONTENT_TYPE_UNKNOWN
```

Content type value to use when the content type is unknown, or other than the ones defined.

<br />

Constant Value:

0
(0x00000000)


### FLAG_AUDIBILITY_ENFORCED

Added in [API level 21](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)  

```
public static final int FLAG_AUDIBILITY_ENFORCED
```

Flag defining a behavior where the audibility of the sound will be ensured by the system.
To ensure sound audibility, the system only uses built-in speakers or wired headphones
and specifically excludes wireless audio devices.

Note this flag should only be used for sounds subject to regulatory behaviors in some
countries, such as for camera shutter sound, and not for routing behaviors.

<br />

Constant Value:

1
(0x00000001)


### FLAG_HW_AV_SYNC

Added in [API level 21](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)  

```
public static final int FLAG_HW_AV_SYNC
```

Flag requesting the use of an output stream supporting hardware A/V synchronization.

<br />

Constant Value:

16
(0x00000010)


### FLAG_LOW_LATENCY

Added in [API level 24](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)   
Deprecated in [API level
26](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)  

```
public static final int FLAG_LOW_LATENCY
```


**This constant was deprecated
in API level 26.**   

Use [AudioTrack.Builder.setPerformanceMode(int)](https://developer.android.com/reference/android/media/AudioTrack.Builder#setPerformanceMode(int)) with
[AudioTrack.PERFORMANCE_MODE_LOW_LATENCY](https://developer.android.com/reference/android/media/AudioTrack#PERFORMANCE_MODE_LOW_LATENCY) to control performance.

Flag requesting a low latency path when creating an AudioTrack.
When using this flag, the sample rate must match the native sample rate
of the device. Effects processing is also unavailable.

Note that if this flag is used without specifying a bufferSizeInBytes then the
AudioTrack's actual buffer size may be too small. It is recommended that a fairly
large buffer should be specified when the AudioTrack is created.
Then the actual size can be reduced by calling
[AudioTrack.setBufferSizeInFrames(int)](https://developer.android.com/reference/android/media/AudioTrack#setBufferSizeInFrames(int)). The buffer size can be optimized
by lowering it after each write() call until the audio glitches, which is detected by calling
[AudioTrack.getUnderrunCount()](https://developer.android.com/reference/android/media/AudioTrack#getUnderrunCount()). Then the buffer size can be increased
until there are no glitches.
This tuning step should be done while playing silence.
This technique provides a compromise between latency and glitch rate.

<br />

Constant Value:

256
(0x00000100)


### SPATIALIZATION_BEHAVIOR_AUTO

Added in [API level 32](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)  

```
public static final int SPATIALIZATION_BEHAVIOR_AUTO
```

Constant indicating the audio content associated with these attributes will follow the
default platform behavior with regards to which content will be spatialized or not.

<br />

**See also:**

- [getSpatializationBehavior()](https://developer.android.com/reference/android/media/AudioAttributes#getSpatializationBehavior())
- [Spatializer](https://developer.android.com/reference/android/media/Spatializer)

Constant Value:

0
(0x00000000)


### SPATIALIZATION_BEHAVIOR_NEVER

Added in [API level 32](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)  

```
public static final int SPATIALIZATION_BEHAVIOR_NEVER
```

Constant indicating the audio content associated with these attributes should never
be virtualized.

<br />

**See also:**

- [getSpatializationBehavior()](https://developer.android.com/reference/android/media/AudioAttributes#getSpatializationBehavior())
- [Spatializer](https://developer.android.com/reference/android/media/Spatializer)

Constant Value:

1
(0x00000001)


### USAGE_ALARM

Added in [API level 21](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)  

```
public static final int USAGE_ALARM
```

Usage value to use when the usage is an alarm (e.g. wake-up alarm).

<br />

Constant Value:

4
(0x00000004)


### USAGE_ASSISTANCE_ACCESSIBILITY

Added in [API level 21](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)  

```
public static final int USAGE_ASSISTANCE_ACCESSIBILITY
```

Usage value to use when the usage is for accessibility, such as with
a screen reader.

<br />

Constant Value:

11
(0x0000000b)


### USAGE_ASSISTANCE_NAVIGATION_GUIDANCE

Added in [API level 21](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)  

```
public static final int USAGE_ASSISTANCE_NAVIGATION_GUIDANCE
```

Usage value to use when the usage is driving or navigation directions.

<br />

Constant Value:

12
(0x0000000c)


### USAGE_ASSISTANCE_SONIFICATION

Added in [API level 21](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)  

```
public static final int USAGE_ASSISTANCE_SONIFICATION
```

Usage value to use when the usage is sonification, such as with user
interface sounds.

<br />

Constant Value:

13
(0x0000000d)


### USAGE_ASSISTANT

Added in [API level 26](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)  

```
public static final int USAGE_ASSISTANT
```

Usage value to use for audio responses to user queries, audio instructions or help
utterances.

<br />

Constant Value:

16
(0x00000010)


### USAGE_GAME

Added in [API level 21](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)  

```
public static final int USAGE_GAME
```

Usage value to use when the usage is for game audio.

<br />

Constant Value:

14
(0x0000000e)


### USAGE_MEDIA

Added in [API level 21](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)  

```
public static final int USAGE_MEDIA
```

Usage value to use when the usage is media, such as music, or movie
soundtracks.

<br />

Constant Value:

1
(0x00000001)


### USAGE_NOTIFICATION

Added in [API level 21](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)  

```
public static final int USAGE_NOTIFICATION
```

Usage value to use when the usage is notification. See other
notification usages for more specialized uses.

<br />

Constant Value:

5
(0x00000005)


### USAGE_NOTIFICATION_COMMUNICATION_DELAYED

Added in [API level 21](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)   
Deprecated in [API level
33](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)  

```
public static final int USAGE_NOTIFICATION_COMMUNICATION_DELAYED
```


**This constant was deprecated
in API level 33.**   

Use [USAGE_NOTIFICATION](https://developer.android.com/reference/android/media/AudioAttributes#USAGE_NOTIFICATION) which is handled
the same way as this usage by the audio framework

Usage value to use when the usage is notification for a
non-immediate type of communication such as e-mail.

<br />

Constant Value:

9
(0x00000009)


### USAGE_NOTIFICATION_COMMUNICATION_INSTANT

Added in [API level 21](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)   
Deprecated in [API level
33](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)  

```
public static final int USAGE_NOTIFICATION_COMMUNICATION_INSTANT
```


**This constant was deprecated
in API level 33.**   

Use [USAGE_NOTIFICATION](https://developer.android.com/reference/android/media/AudioAttributes#USAGE_NOTIFICATION) which is handled
the same way as this usage by the audio framework

Usage value to use when the usage is notification for an "instant"
communication such as a chat, or SMS.

<br />

Constant Value:

8
(0x00000008)


### USAGE_NOTIFICATION_COMMUNICATION_REQUEST

Added in [API level 21](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)   
Deprecated in [API level
33](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)  

```
public static final int USAGE_NOTIFICATION_COMMUNICATION_REQUEST
```


**This constant was deprecated
in API level 33.**   

Use [USAGE_NOTIFICATION](https://developer.android.com/reference/android/media/AudioAttributes#USAGE_NOTIFICATION) which is handled
the same way as this usage by the audio framework

Usage value to use when the usage is a request to enter/end a
communication, such as a VoIP communication or video-conference.

<br />

Constant Value:

7
(0x00000007)


### USAGE_NOTIFICATION_EVENT

Added in [API level 21](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)  

```
public static final int USAGE_NOTIFICATION_EVENT
```

Usage value to use when the usage is to attract the user's attention,
such as a reminder or low battery warning.

<br />

Constant Value:

10
(0x0000000a)


### USAGE_NOTIFICATION_RINGTONE

Added in [API level 21](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)  

```
public static final int USAGE_NOTIFICATION_RINGTONE
```

Usage value to use when the usage is telephony ringtone.

<br />

Constant Value:

6
(0x00000006)


### USAGE_UNKNOWN

Added in [API level 21](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)  

```
public static final int USAGE_UNKNOWN
```

Usage value to use when the usage is unknown.

<br />

Constant Value:

0
(0x00000000)


### USAGE_VOICE_COMMUNICATION

Added in [API level 21](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)  

```
public static final int USAGE_VOICE_COMMUNICATION
```

Usage value to use when the usage is voice communications, such as telephony
or VoIP.

<br />

Constant Value:

2
(0x00000002)


### USAGE_VOICE_COMMUNICATION_SIGNALLING

Added in [API level 21](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)  

```
public static final int USAGE_VOICE_COMMUNICATION_SIGNALLING
```

Usage value to use when the usage is in-call signalling, such as with
a "busy" beep, or DTMF tones.

<br />

Constant Value:

3
(0x00000003)


## Fields

### CREATOR

Added in [API level 21](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)  

```
public static final Creator<AudioAttributes> CREATOR
```

<br />

<br />

## Public methods

### areHapticChannelsMuted

Added in [API level 29](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)  

```
public boolean areHapticChannelsMuted ()
```

Return if haptic channels are muted.

<br />

|                                  Returns                                  ||
|-----------|----------------------------------------------------------------|
| `boolean` | `true` if haptic channels are muted, `false` otherwise. <br /> |

### describeContents

Added in [API level 21](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)  

```
public int describeContents ()
```

Describe the kinds of special objects contained in this Parcelable
instance's marshaled representation. For example, if the object will
include a file descriptor in the output of [writeToParcel(android.os.Parcel, int)](https://developer.android.com/reference/android/os/Parcelable#writeToParcel(android.os.Parcel,%20int)),
the return value of this method must include the
[CONTENTS_FILE_DESCRIPTOR](https://developer.android.com/reference/android/os/Parcelable#CONTENTS_FILE_DESCRIPTOR) bit.

<br />

|                                                                                                                          Returns                                                                                                                           ||
|-------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| `int` | a bitmask indicating the set of special object types marshaled by this Parcelable object instance. Value is either `0` or [CONTENTS_FILE_DESCRIPTOR](https://developer.android.com/reference/android/os/Parcelable#CONTENTS_FILE_DESCRIPTOR) <br /> |

### equals

Added in [API level 21](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)  

```
public boolean equals (Object o)
```

Indicates whether some other object is "equal to" this one.


The `equals` method implements an equivalence relation
on non-null object references:

- It is *reflexive* : for any non-null reference value `x`, `x.equals(x)` should return `true`.
- It is *symmetric* : for any non-null reference values `x` and `y`, `x.equals(y)` should return `true` if and only if `y.equals(x)` returns `true`.
- It is *transitive* : for any non-null reference values `x`, `y`, and `z`, if `x.equals(y)` returns `true` and `y.equals(z)` returns `true`, then `x.equals(z)` should return `true`.
- It is *consistent* : for any non-null reference values `x` and `y`, multiple invocations of `x.equals(y)` consistently return `true` or consistently return `false`, provided no information used in `equals` comparisons on the objects is modified.
- For any non-null reference value `x`, `x.equals(null)` should return `false`.


An equivalence relation partitions the elements it operates on
into *equivalence classes*; all the members of an
equivalence class are equal to each other. Members of an
equivalence class are substitutable for each other, at least
for some purposes.

<br />

|                            Parameters                             ||
|-----|--------------------------------------------------------------|
| `o` | `Object`: the reference object with which to compare. <br /> |

|                                           Returns                                           ||
|-----------|----------------------------------------------------------------------------------|
| `boolean` | `true` if this object is the same as the obj argument; `false` otherwise. <br /> |

### getAllowedCapturePolicy

Added in [API level 29](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)  

```
public int getAllowedCapturePolicy ()
```

Return the capture policy.

<br />

|                                                                                                                                                                                                                                                                                                    Returns                                                                                                                                                                                                                                                                                                     ||
|-------|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| `int` | the capture policy set by [Builder.setAllowedCapturePolicy(int)](https://developer.android.com/reference/android/media/AudioAttributes.Builder#setAllowedCapturePolicy(int)) or the default if it was not called. Value is [ALLOW_CAPTURE_BY_ALL](https://developer.android.com/reference/android/media/AudioAttributes#ALLOW_CAPTURE_BY_ALL), [ALLOW_CAPTURE_BY_SYSTEM](https://developer.android.com/reference/android/media/AudioAttributes#ALLOW_CAPTURE_BY_SYSTEM), or [ALLOW_CAPTURE_BY_NONE](https://developer.android.com/reference/android/media/AudioAttributes#ALLOW_CAPTURE_BY_NONE) <br /> |

### getContentType

Added in [API level 21](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)  

```
public int getContentType ()
```

Return the content type.

<br />

|                                                                                       Returns                                                                                       ||
|-------|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| `int` | one of the values that can be set in [Builder.setContentType(int)](https://developer.android.com/reference/android/media/AudioAttributes.Builder#setContentType(int)) <br /> |

### getFlags

Added in [API level 21](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)  

```
public int getFlags ()
```

Return the flags.

<br />

|                  Returns                   ||
|-------|-------------------------------------|
| `int` | a combined mask of all flags <br /> |

### getSpatializationBehavior

Added in [API level 32](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)  

```
public int getSpatializationBehavior ()
```

Return the behavior affecting whether spatialization will be used.

<br />

|                                                                                                                                                            Returns                                                                                                                                                             ||
|-------|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| `int` | the spatialization behavior Value is [SPATIALIZATION_BEHAVIOR_AUTO](https://developer.android.com/reference/android/media/AudioAttributes#SPATIALIZATION_BEHAVIOR_AUTO), or [SPATIALIZATION_BEHAVIOR_NEVER](https://developer.android.com/reference/android/media/AudioAttributes#SPATIALIZATION_BEHAVIOR_NEVER) <br /> |

### getUsage

Added in [API level 21](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)  

```
public int getUsage ()
```

Return the usage.

<br />

|                                                                                 Returns                                                                                 ||
|-------|------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| `int` | one of the values that can be set in [Builder.setUsage(int)](https://developer.android.com/reference/android/media/AudioAttributes.Builder#setUsage(int)) <br /> |

### getVolumeControlStream

Added in [API level 26](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)  

```
public int getVolumeControlStream ()
```

Returns the stream type matching this `AudioAttributes` instance for volume control.
Use this method to derive the stream type needed to configure the volume
control slider in an [Activity](https://developer.android.com/reference/android/app/Activity) with
[Activity.setVolumeControlStream(int)](https://developer.android.com/reference/android/app/Activity#setVolumeControlStream(int)) for playback conducted with these
attributes.

Do not use this method to set the stream type on an audio player object
(e.g. [AudioTrack](https://developer.android.com/reference/android/media/AudioTrack), [MediaPlayer](https://developer.android.com/reference/android/media/MediaPlayer)) as this is deprecated,
use `AudioAttributes` instead.

<br />

|                                                                                                                                                                                                                                            Returns                                                                                                                                                                                                                                             ||
|-------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| `int` | a valid stream type for `Activity` or stream volume control that matches the attributes, or [AudioManager.USE_DEFAULT_STREAM_TYPE](https://developer.android.com/reference/android/media/AudioManager#USE_DEFAULT_STREAM_TYPE) if there isn't a direct match. Note that `USE_DEFAULT_STREAM_TYPE` is not a valid value for [AudioManager.setStreamVolume(int, int, int)](https://developer.android.com/reference/android/media/AudioManager#setStreamVolume(int,%20int,%20int)). <br /> |

### hashCode

Added in [API level 21](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)  

```
public int hashCode ()
```

Returns a hash code value for the object. This method is
supported for the benefit of hash tables such as those provided by
[HashMap](https://developer.android.com/reference/java/util/HashMap).


The general contract of `hashCode` is:

- Whenever it is invoked on the same object more than once during an execution of a Java application, the `hashCode` method must consistently return the same integer, provided no information used in `equals` comparisons on the object is modified. This integer need not remain consistent from one execution of an application to another execution of the same application.
- If two objects are equal according to the [equals](https://developer.android.com/reference/java/lang/Object#equals(java.lang.Object)) method, then calling the `hashCode` method on each of the two objects must produce the same integer result.
- It is *not* required that if two objects are unequal according to the [equals](https://developer.android.com/reference/java/lang/Object#equals(java.lang.Object)) method, then calling the `hashCode` method on each of the two objects must produce distinct integer results. However, the programmer should be aware that producing distinct integer results for unequal objects may improve the performance of hash tables.

<br />

<br />

|                     Returns                      ||
|-------|-------------------------------------------|
| `int` | a hash code value for this object. <br /> |

### isContentSpatialized

Added in [API level 32](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)  

```
public boolean isContentSpatialized ()
```

Return true if the audio content associated with these attributes has already been
spatialized, that is it has already been processed to offer a binaural or transaural
immersive audio experience.

<br />

|                          Returns                           ||
|-----------|-------------------------------------------------|
| `boolean` | `true` if the content has been processed <br /> |

### toString

Added in [API level 21](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)  

```
public String toString ()
```

Returns a string representation of the object.

<br />

|                                                      Returns                                                      ||
|--------------------------------------------------------------------|-----------------------------------------------|
| [String](https://developer.android.com/reference/java/lang/String) | a string representation of the object. <br /> |

### writeToParcel

Added in [API level 21](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)  

```
public void writeToParcel (Parcel dest, 
                int flags)
```

Flatten this object in to a Parcel.

<br />

|                                                                                                                                                                                                                                 Parameters                                                                                                                                                                                                                                  ||
|---------|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| `dest`  | `Parcel`: The Parcel in which the object should be written. This value cannot be `null`. <br />                                                                                                                                                                                                                                                                                                                                                                    |
| `flags` | `int`: Additional flags about how the object should be written. May be 0 or [Parcelable.PARCELABLE_WRITE_RETURN_VALUE](https://developer.android.com/reference/android/os/Parcelable#PARCELABLE_WRITE_RETURN_VALUE). Value is either `0` or a combination of [Parcelable.PARCELABLE_WRITE_RETURN_VALUE](https://developer.android.com/reference/android/os/Parcelable#PARCELABLE_WRITE_RETURN_VALUE), and android.os.Parcelable.PARCELABLE_ELIDE_DUPLICATES <br /> |