# EmbeddingConfiguration.Builder

# EmbeddingConfiguration.Builder

Artifact:[androidx.window:window](https://developer.android.com/jetpack/androidx/releases/window)  
[View Source](https://cs.android.com/search?q=file:androidx/window/embedding/EmbeddingConfiguration.kt+class:androidx.window.embedding.EmbeddingConfiguration.Builder)  
Added in[1.4.0](https://developer.android.com/jetpack/androidx/releases/window#1.4.0)

*** ** * ** ***

Kotlin\|[Java](https://developer.android.com/reference/androidx/window/embedding/EmbeddingConfiguration.Builder "View this page in Java")

<br />

```
class EmbeddingConfiguration.Builder
```

<br />

*** ** * ** ***

Builder for creating an instance of[EmbeddingConfiguration](https://developer.android.com/reference/kotlin/androidx/window/embedding/EmbeddingConfiguration).

## Summary

|                                                     ### Public constructors                                                      |
|----------------------------------------------------------------------------------------------------------------------------------|
| [Builder](https://developer.android.com/reference/kotlin/androidx/window/embedding/EmbeddingConfiguration.Builder#Builder())`()` |

|                                                           ### Public functions                                                            |
|-------------------------------------------------------------------------------------------------------------------------------------------|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| [EmbeddingConfiguration](https://developer.android.com/reference/kotlin/androidx/window/embedding/EmbeddingConfiguration)                 | [build](https://developer.android.com/reference/kotlin/androidx/window/embedding/EmbeddingConfiguration.Builder#build())`()` Builds a[EmbeddingConfiguration](https://developer.android.com/reference/kotlin/androidx/window/embedding/EmbeddingConfiguration)instance.                                                                                                                                                                                                                                                                                                                           |
| [EmbeddingConfiguration.Builder](https://developer.android.com/reference/kotlin/androidx/window/embedding/EmbeddingConfiguration.Builder) | `@`[RequiresWindowSdkExtension](https://developer.android.com/reference/kotlin/androidx/window/RequiresWindowSdkExtension)`(version = 8)` [setAutoSaveEmbeddingState](https://developer.android.com/reference/kotlin/androidx/window/embedding/EmbeddingConfiguration.Builder#setAutoSaveEmbeddingState(kotlin.Boolean))`(saveState: `[Boolean](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html)`)` Sets whether to auto save the embedding state to the system, which can be used to restore the app embedding state once the app process is restarted (if applicable). |
| [EmbeddingConfiguration.Builder](https://developer.android.com/reference/kotlin/androidx/window/embedding/EmbeddingConfiguration.Builder) | `@`[RequiresWindowSdkExtension](https://developer.android.com/reference/kotlin/androidx/window/RequiresWindowSdkExtension)`(version = 5)` [setDimAreaBehavior](https://developer.android.com/reference/kotlin/androidx/window/embedding/EmbeddingConfiguration.Builder#setDimAreaBehavior(androidx.window.embedding.EmbeddingConfiguration.DimAreaBehavior))`(area: `[EmbeddingConfiguration.DimAreaBehavior](https://developer.android.com/reference/kotlin/androidx/window/embedding/EmbeddingConfiguration.DimAreaBehavior)`)` Sets the dim area behavior.                                     |

## Public constructors

### Builder

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

```
Builder()
```  

## Public functions

### build

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

```
fun build(): EmbeddingConfiguration
```

Builds a[EmbeddingConfiguration](https://developer.android.com/reference/kotlin/androidx/window/embedding/EmbeddingConfiguration)instance.  

|                                                          Returns                                                          |
|---------------------------------------------------------------------------------------------------------------------------|-------------------------------------------------------------------------------------------------------------------------------------------|
| [EmbeddingConfiguration](https://developer.android.com/reference/kotlin/androidx/window/embedding/EmbeddingConfiguration) | The new[EmbeddingConfiguration](https://developer.android.com/reference/kotlin/androidx/window/embedding/EmbeddingConfiguration)instance. |

### setAutoSaveEmbeddingState

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

```
@RequiresWindowSdkExtension(version = 8)
fun setAutoSaveEmbeddingState(saveState: Boolean): EmbeddingConfiguration.Builder
```

Sets whether to auto save the embedding state to the system, which can be used to restore the app embedding state once the app process is restarted (if applicable).

The embedding state is not saved by default, in which case the embedding state and the embedded activities are removed once the app process is killed.

**Note** that the applications should set the[EmbeddingRule](https://developer.android.com/reference/kotlin/androidx/window/embedding/EmbeddingRule)s using[RuleController.setRules](https://developer.android.com/reference/kotlin/androidx/window/embedding/RuleController#setRules(kotlin.collections.Set))when the application is initializing, such as configured in[androidx.startup.Initializer](https://developer.android.com/reference/kotlin/androidx/startup/Initializer)or in[android.app.Application.onCreate](https://developer.android.com/reference/android/app/Application.html#onCreate()), in order to allow the library to restore the state properly. Otherwise, the state may not be restored and the activities may not be started and layout as expected.

This can be supported only if the Window Extensions version of the target device is equals or higher than required API level. Otherwise, it would be no-op on a target device that has lower API level.  

|                                            Parameters                                            |
|--------------------------------------------------------------------------------------------------|-------------------------------------|
| `saveState: `[Boolean](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html) | whether to save the embedding state |

### setDimAreaBehavior

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

```
@RequiresWindowSdkExtension(version = 5)
fun setDimAreaBehavior(area: EmbeddingConfiguration.DimAreaBehavior): EmbeddingConfiguration.Builder
```

Sets the dim area behavior. By default, the[DimAreaBehavior.UNDEFINED](https://developer.android.com/reference/kotlin/androidx/window/embedding/EmbeddingConfiguration.DimAreaBehavior#UNDEFINED())is used if not set.

This can be supported only if the Window Extensions version of the target device is equals or higher than required API level. Otherwise, it would be no-op on a target device that has lower API level.  

|                                                                            Parameters                                                                             |
|-------------------------------------------------------------------------------------------------------------------------------------------------------------------|---------------|
| `area: `[EmbeddingConfiguration.DimAreaBehavior](https://developer.android.com/reference/kotlin/androidx/window/embedding/EmbeddingConfiguration.DimAreaBehavior) | The dim area. |

|                                                                  Returns                                                                  |
|-------------------------------------------------------------------------------------------------------------------------------------------|------------------------------------------------------------------------------------------------------------------------|
| [EmbeddingConfiguration.Builder](https://developer.android.com/reference/kotlin/androidx/window/embedding/EmbeddingConfiguration.Builder) | This[Builder](https://developer.android.com/reference/kotlin/androidx/window/embedding/EmbeddingConfiguration.Builder) |