# 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)

*** ** * ** ***


```
public final class EmbeddingConfiguration.Builder
```

<br />

*** ** * ** ***

Builder for creating an instance of `https://developer.android.com/reference/androidx/window/embedding/EmbeddingConfiguration`.

## Summary

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

| ### Public methods |
|---|---|
| `final @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/window/embedding/EmbeddingConfiguration` | `https://developer.android.com/reference/androidx/window/embedding/EmbeddingConfiguration.Builder#build()()` Builds a`https://developer.android.com/reference/androidx/window/embedding/EmbeddingConfiguration` instance. |
| `final @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/window/embedding/EmbeddingConfiguration.Builder` | `@https://developer.android.com/reference/androidx/window/RequiresWindowSdkExtension(version = 8) https://developer.android.com/reference/androidx/window/embedding/EmbeddingConfiguration.Builder#setAutoSaveEmbeddingState(kotlin.Boolean)(boolean saveState)` 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). |
| `final @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/window/embedding/EmbeddingConfiguration.Builder` | `@https://developer.android.com/reference/androidx/window/RequiresWindowSdkExtension(version = 5) https://developer.android.com/reference/androidx/window/embedding/EmbeddingConfiguration.Builder#setDimAreaBehavior(androidx.window.embedding.EmbeddingConfiguration.DimAreaBehavior)(@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/window/embedding/EmbeddingConfiguration.DimAreaBehavior area)` Sets the dim area behavior. |

## Public constructors

### Builder

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

```
public Builder()
```

## Public methods

### build

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

```
public final @NonNull EmbeddingConfiguration build()
```

Builds a`https://developer.android.com/reference/androidx/window/embedding/EmbeddingConfiguration` instance.

| Returns |
|---|---|
| `@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/window/embedding/EmbeddingConfiguration` | The new `https://developer.android.com/reference/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)
public final @NonNull EmbeddingConfiguration.Builder setAutoSaveEmbeddingState(boolean saveState)
```

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 `https://developer.android.com/reference/androidx/window/embedding/EmbeddingRule`s using `https://developer.android.com/reference/androidx/window/embedding/RuleController#setRules(kotlin.collections.Set)` when the application is initializing, such as configured in `https://developer.android.com/reference/androidx/startup/Initializer` or in `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 |
|---|---|
| `boolean saveState` | 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)
public final @NonNull EmbeddingConfiguration.Builder setDimAreaBehavior(@NonNull EmbeddingConfiguration.DimAreaBehavior area)
```

Sets the dim area behavior. By default, the `https://developer.android.com/reference/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 |
|---|---|
| `@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/window/embedding/EmbeddingConfiguration.DimAreaBehavior area` | The dim area. |

| Returns |
|---|---|
| `@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/window/embedding/EmbeddingConfiguration.Builder` | This `https://developer.android.com/reference/androidx/window/embedding/EmbeddingConfiguration.Builder` |