# OnConfigurationChangedProvider

# OnConfigurationChangedProvider

Artifact:[androidx.core:core](https://developer.android.com/jetpack/androidx/releases/core)  
[View Source](https://cs.android.com/search?q=file:androidx/core/content/OnConfigurationChangedProvider.kt+class:androidx.core.content.OnConfigurationChangedProvider)  
Added in[1.8.0](https://developer.android.com/jetpack/androidx/releases/core#1.8.0)

*** ** * ** ***

Kotlin\|[Java](https://developer.android.com/reference/androidx/core/content/OnConfigurationChangedProvider "View this page in Java")

<br />

```
interface OnConfigurationChangedProvider
```

<br />

Known direct subclasses  
[ComponentActivity](https://developer.android.com/reference/kotlin/androidx/activity/ComponentActivity)  

|---------------------------------------------------------------------------------------------------------|--------------------------------------------------------------------------------|
| [ComponentActivity](https://developer.android.com/reference/kotlin/androidx/activity/ComponentActivity) | Base class for activities that enables composition of higher level components. |

Known indirect subclasses  
[AppCompatActivity](https://developer.android.com/reference/kotlin/androidx/appcompat/app/AppCompatActivity),[BaseCarAppActivity](https://developer.android.com/reference/kotlin/androidx/car/app/activity/BaseCarAppActivity),[CarAppActivity](https://developer.android.com/reference/kotlin/androidx/car/app/activity/CarAppActivity),[FragmentActivity](https://developer.android.com/reference/kotlin/androidx/fragment/app/FragmentActivity),[LauncherActivity](https://developer.android.com/reference/kotlin/androidx/car/app/activity/LauncherActivity),[PreviewActivity](https://developer.android.com/reference/kotlin/androidx/compose/ui/tooling/PreviewActivity)  

|-------------------------------------------------------------------------------------------------------------------|---------------------------------------------------------------------------------------------------------------------------------------------------------|
| [AppCompatActivity](https://developer.android.com/reference/kotlin/androidx/appcompat/app/AppCompatActivity)      | Base class for activities that wish to use some of the newer platform features on older Android devices.                                                |
| [BaseCarAppActivity](https://developer.android.com/reference/kotlin/androidx/car/app/activity/BaseCarAppActivity) | Core logic for CarAppLibrary Activity interaction with a host.                                                                                          |
| [CarAppActivity](https://developer.android.com/reference/kotlin/androidx/car/app/activity/CarAppActivity)         | The class representing a car app activity in the main display.                                                                                          |
| [FragmentActivity](https://developer.android.com/reference/kotlin/androidx/fragment/app/FragmentActivity)         | Base class for activities that want to use the support-based[Fragments](https://developer.android.com/reference/kotlin/androidx/fragment/app/Fragment). |
| [LauncherActivity](https://developer.android.com/reference/kotlin/androidx/car/app/activity/LauncherActivity)     | This class handles providing the right launcher activity when running native applications and Car App Library applications.                             |
| [PreviewActivity](https://developer.android.com/reference/kotlin/androidx/compose/ui/tooling/PreviewActivity)     | Activity used to run`@Composable`previews from Android Studio.                                                                                          |

*** ** * ** ***

Interface for components that can dispatch calls from[ComponentCallbacks.onConfigurationChanged](https://developer.android.com/reference/android/content/ComponentCallbacks.html#onConfigurationChanged(android.content.res.Configuration)).

## Summary

|                             ### Public functions                              |
|-------------------------------------------------------------------------------|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| [Unit](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html) | [addOnConfigurationChangedListener](https://developer.android.com/reference/kotlin/androidx/core/content/OnConfigurationChangedProvider#addOnConfigurationChangedListener(androidx.core.util.Consumer))`(listener: `[Consumer](https://developer.android.com/reference/kotlin/androidx/core/util/Consumer)`<`[Configuration](https://developer.android.com/reference/android/content/res/Configuration.html)`>)` Add a new listener that will get a callback associated with[ComponentCallbacks.onConfigurationChanged](https://developer.android.com/reference/android/content/ComponentCallbacks.html#onConfigurationChanged(android.content.res.Configuration))with the new[Configuration](https://developer.android.com/reference/android/content/res/Configuration.html). |
| [Unit](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html) | [removeOnConfigurationChangedListener](https://developer.android.com/reference/kotlin/androidx/core/content/OnConfigurationChangedProvider#removeOnConfigurationChangedListener(androidx.core.util.Consumer))`(listener: `[Consumer](https://developer.android.com/reference/kotlin/androidx/core/util/Consumer)`<`[Configuration](https://developer.android.com/reference/android/content/res/Configuration.html)`>)` Remove a previously added listener.                                                                                                                                                                                                                                                                                                                     |

## Public functions

### addOnConfigurationChangedListener

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

```
fun addOnConfigurationChangedListener(listener: Consumer<Configuration>): Unit
```

Add a new listener that will get a callback associated with[ComponentCallbacks.onConfigurationChanged](https://developer.android.com/reference/android/content/ComponentCallbacks.html#onConfigurationChanged(android.content.res.Configuration))with the new[Configuration](https://developer.android.com/reference/android/content/res/Configuration.html).  

|                                                                                               Parameters                                                                                                |
|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| `listener: `[Consumer](https://developer.android.com/reference/kotlin/androidx/core/util/Consumer)`<`[Configuration](https://developer.android.com/reference/android/content/res/Configuration.html)`>` | The listener that should be called whenever {[ComponentCallbacks.onConfigurationChanged](https://developer.android.com/reference/android/content/ComponentCallbacks.html#onConfigurationChanged(android.content.res.Configuration))was called. |

### removeOnConfigurationChangedListener

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

```
fun removeOnConfigurationChangedListener(listener: Consumer<Configuration>): Unit
```

Remove a previously added listener. It will not receive any future callbacks.  

|                                                                                               Parameters                                                                                                |
|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| `listener: `[Consumer](https://developer.android.com/reference/kotlin/androidx/core/util/Consumer)`<`[Configuration](https://developer.android.com/reference/android/content/res/Configuration.html)`>` | The listener previously added with[addOnConfigurationChangedListener](https://developer.android.com/reference/kotlin/androidx/core/content/OnConfigurationChangedProvider#addOnConfigurationChangedListener(androidx.core.util.Consumer))that should be removed. |