# AudioFocusRequestCompat

Artifact: [androidx.media:media](https://developer.android.com/jetpack/androidx/releases/media) [View Source](https://cs.android.com/search?q=file:androidx/media/AudioFocusRequestCompat.java+class:androidx.media.AudioFocusRequestCompat) Added in [1.1.0](https://developer.android.com/jetpack/androidx/releases/media#1.1.0) Deprecated in [1.8.0](https://developer.android.com/jetpack/androidx/releases/media#1.8.0)

*** ** * ** ***


```
class AudioFocusRequestCompat
```

<br />

*** ** * ** ***

> [!CAUTION]
> **This class is deprecated.**   
>
> androidx.media is deprecated. Please migrate to [androidx.media3](https://developer.android.com/media/media3).

Compatibility version of an `https://developer.android.com/reference/android/media/AudioFocusRequest.html`.

## Summary

| ### Nested types |
|---|
| `class https://developer.android.com/reference/kotlin/androidx/media/AudioFocusRequestCompat.Builder` **This class is deprecated.** androidx.media is deprecated. <br /> |

| ### Public functions |
|---|---|
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html` | `[equals](https://developer.android.com/reference/kotlin/androidx/media/AudioFocusRequestCompat#equals(java.lang.Object))(o: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-any/index.html!)` **This function is deprecated.** Deprecated in Java |
| `https://developer.android.com/reference/kotlin/androidx/media/AudioAttributesCompat` | `[getAudioAttributesCompat](https://developer.android.com/reference/kotlin/androidx/media/AudioFocusRequestCompat#getAudioAttributesCompat())()` **This function is deprecated.** Deprecated in Java |
| `https://developer.android.com/reference/android/os/Handler.html` | `[getFocusChangeHandler](https://developer.android.com/reference/kotlin/androidx/media/AudioFocusRequestCompat#getFocusChangeHandler())()` **This function is deprecated.** Deprecated in Java |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | `[getFocusGain](https://developer.android.com/reference/kotlin/androidx/media/AudioFocusRequestCompat#getFocusGain())()` **This function is deprecated.** Deprecated in Java |
| `https://developer.android.com/reference/android/media/AudioManager.OnAudioFocusChangeListener.html` | `[getOnAudioFocusChangeListener](https://developer.android.com/reference/kotlin/androidx/media/AudioFocusRequestCompat#getOnAudioFocusChangeListener())()` **This function is deprecated.** Deprecated in Java |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | `[hashCode](https://developer.android.com/reference/kotlin/androidx/media/AudioFocusRequestCompat#hashCode())()` **This function is deprecated.** Deprecated in Java |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html` | `[willPauseWhenDucked](https://developer.android.com/reference/kotlin/androidx/media/AudioFocusRequestCompat#willPauseWhenDucked())()` **This function is deprecated.** Deprecated in Java |

## Public functions

### equals

```
fun [equals](https://developer.android.com/reference/kotlin/androidx/media/AudioFocusRequestCompat#equals(java.lang.Object))(o: Any!): Boolean
```

> [!CAUTION]
> **This function is deprecated.**   
> Deprecated in Java

### getAudioAttributesCompat

Added in [1.1.0](https://developer.android.com/jetpack/androidx/releases/media#1.1.0) Deprecated in [1.8.0](https://developer.android.com/jetpack/androidx/releases/media#1.8.0)

```
fun [getAudioAttributesCompat](https://developer.android.com/reference/kotlin/androidx/media/AudioFocusRequestCompat#getAudioAttributesCompat())(): AudioAttributesCompat
```

> [!CAUTION]
> **This function is deprecated.**   
> Deprecated in Java

Gets the `https://developer.android.com/reference/kotlin/androidx/media/AudioAttributesCompat` set for this `AudioFocusRequestCompat`, or the default attributes if none were set.

| Returns |
|---|---|
| `https://developer.android.com/reference/kotlin/androidx/media/AudioAttributesCompat` | non-null `https://developer.android.com/reference/kotlin/androidx/media/AudioAttributesCompat`. |

### getFocusChangeHandler

Added in [1.1.0](https://developer.android.com/jetpack/androidx/releases/media#1.1.0) Deprecated in [1.8.0](https://developer.android.com/jetpack/androidx/releases/media#1.8.0)

```
fun [getFocusChangeHandler](https://developer.android.com/reference/kotlin/androidx/media/AudioFocusRequestCompat#getFocusChangeHandler())(): Handler
```

> [!CAUTION]
> **This function is deprecated.**   
> Deprecated in Java

Gets the `https://developer.android.com/reference/android/os/Handler.html` to be used for the focus change listener.

| Returns |
|---|---|
| `https://developer.android.com/reference/android/os/Handler.html` | the same `Handler` set in. `https://developer.android.com/reference/kotlin/androidx/media/AudioFocusRequestCompat.Builder#setOnAudioFocusChangeListener(android.media.AudioManager.OnAudioFocusChangeListener,android.os.Handler)`. |

### getFocusGain

Added in [1.1.0](https://developer.android.com/jetpack/androidx/releases/media#1.1.0) Deprecated in [1.8.0](https://developer.android.com/jetpack/androidx/releases/media#1.8.0)

```
fun [getFocusGain](https://developer.android.com/reference/kotlin/androidx/media/AudioFocusRequestCompat#getFocusGain())(): Int
```

> [!CAUTION]
> **This function is deprecated.**   
> Deprecated in Java

Gets the type of audio focus request configured for this `AudioFocusRequestCompat`.

Value is one of the following:

- `AudioManagerCompat.AUDIOFOCUS_GAIN`
- `AudioManagerCompat.AUDIOFOCUS_GAIN_TRANSIENT`
- `AudioManagerCompat.AUDIOFOCUS_GAIN_TRANSIENT_MAY_DUCK`
- `AudioManagerCompat.AUDIOFOCUS_GAIN_TRANSIENT_EXCLUSIVE`

<br />

| Returns |
|---|---|
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | one of `https://developer.android.com/reference/kotlin/androidx/media/AudioManagerCompat#AUDIOFOCUS_GAIN()`, `https://developer.android.com/reference/kotlin/androidx/media/AudioManagerCompat#AUDIOFOCUS_GAIN_TRANSIENT()`, `https://developer.android.com/reference/kotlin/androidx/media/AudioManagerCompat#AUDIOFOCUS_GAIN_TRANSIENT_MAY_DUCK()`, and `https://developer.android.com/reference/kotlin/androidx/media/AudioManagerCompat#AUDIOFOCUS_GAIN_TRANSIENT_EXCLUSIVE()`. |

### getOnAudioFocusChangeListener

Added in [1.1.0](https://developer.android.com/jetpack/androidx/releases/media#1.1.0) Deprecated in [1.8.0](https://developer.android.com/jetpack/androidx/releases/media#1.8.0)

```
fun [getOnAudioFocusChangeListener](https://developer.android.com/reference/kotlin/androidx/media/AudioFocusRequestCompat#getOnAudioFocusChangeListener())(): AudioManager.OnAudioFocusChangeListener
```

> [!CAUTION]
> **This function is deprecated.**   
> Deprecated in Java

Gets the focus change listener set for this `AudioFocusRequestCompat`.

| Returns |
|---|---|
| `https://developer.android.com/reference/android/media/AudioManager.OnAudioFocusChangeListener.html` | The `https://developer.android.com/reference/android/media/AudioManager.OnAudioFocusChangeListener.html` that was set. |

### hashCode

```
fun [hashCode](https://developer.android.com/reference/kotlin/androidx/media/AudioFocusRequestCompat#hashCode())(): Int
```

> [!CAUTION]
> **This function is deprecated.**   
> Deprecated in Java

### willPauseWhenDucked

Added in [1.1.0](https://developer.android.com/jetpack/androidx/releases/media#1.1.0) Deprecated in [1.8.0](https://developer.android.com/jetpack/androidx/releases/media#1.8.0)

```
fun [willPauseWhenDucked](https://developer.android.com/reference/kotlin/androidx/media/AudioFocusRequestCompat#willPauseWhenDucked())(): Boolean
```

> [!CAUTION]
> **This function is deprecated.**   
> Deprecated in Java

Gets whether the application that would use this `AudioFocusRequestCompat` would pause when it is requested to duck. This value is only applicable on `https://developer.android.com/reference/android/os/Build.VERSION_CODES.html#O` and later.

| Returns |
|---|---|
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html` | the duck/pause behavior. |