# VirtualDisplayConfig.Builder

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

# Builder

*** ** * ** ***

Kotlin\|[Java](https://developer.android.com/reference/android/hardware/display/VirtualDisplayConfig.Builder "View this page in Java")  

```
class Builder
```

|---|----------------------------------------------------------------------------------------------------------------------------------------------------------------|
| [kotlin.Any](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-any/index.html)                                                                                 ||
| ↳ | [android.hardware.display.VirtualDisplayConfig.Builder](https://developer.android.com/reference/kotlin/android/hardware/display/VirtualDisplayConfig.Builder#) |

A builder for[VirtualDisplayConfig](https://developer.android.com/reference/kotlin/android/hardware/display/VirtualDisplayConfig).

## Summary

|                                                                                                                                                                                                                                                                                 Public constructors                                                                                                                                                                                                                                                                                 ||
|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|---|
| [Builder](https://developer.android.com/reference/kotlin/android/hardware/display/VirtualDisplayConfig.Builder#Builder(kotlin.String,%20kotlin.Int,%20kotlin.Int,%20kotlin.Int))`(`name:` `[String](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html)`, `width:` `[Int](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html)`, `height:` `[Int](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html)`, `densityDpi:` `[Int](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html)`)` Creates a new Builder. |

|                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                         Public methods                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          ||
|---------------------------------------------------------------------------------------------------------------------------------------|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| [VirtualDisplayConfig.Builder](https://developer.android.com/reference/kotlin/android/hardware/display/VirtualDisplayConfig.Builder#) | [addDisplayCategory](https://developer.android.com/reference/kotlin/android/hardware/display/VirtualDisplayConfig.Builder#addDisplayCategory(kotlin.String))`(`displayCategory:` `[String](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html)`)` Adds a display category.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           |
| [VirtualDisplayConfig](https://developer.android.com/reference/kotlin/android/hardware/display/VirtualDisplayConfig)                  | [build](https://developer.android.com/reference/kotlin/android/hardware/display/VirtualDisplayConfig.Builder#build())`()` Builds the[VirtualDisplayConfig](https://developer.android.com/reference/kotlin/android/hardware/display/VirtualDisplayConfig)instance.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        |
| [VirtualDisplayConfig.Builder](https://developer.android.com/reference/kotlin/android/hardware/display/VirtualDisplayConfig.Builder#) | [setBrightnessListener](https://developer.android.com/reference/kotlin/android/hardware/display/VirtualDisplayConfig.Builder#setBrightnessListener(java.util.concurrent.Executor,%20android.hardware.display.VirtualDisplayConfig.BrightnessListener))`(`executor:` `[Executor](https://developer.android.com/reference/kotlin/java/util/concurrent/Executor.html#)`, `listener:` `[VirtualDisplayConfig.BrightnessListener](https://developer.android.com/reference/kotlin/android/hardware/display/VirtualDisplayConfig.BrightnessListener)`)` Sets the listener to get notified about changes in the display brightness.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                              |
| [VirtualDisplayConfig.Builder](https://developer.android.com/reference/kotlin/android/hardware/display/VirtualDisplayConfig.Builder#) | [setDefaultBrightness](https://developer.android.com/reference/kotlin/android/hardware/display/VirtualDisplayConfig.Builder#setDefaultBrightness(kotlin.Float))`(`brightness:` `[Float](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-float/index.html)`)` Sets the default brightness of the display.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            |
| [VirtualDisplayConfig.Builder](https://developer.android.com/reference/kotlin/android/hardware/display/VirtualDisplayConfig.Builder#) | [setDimBrightness](https://developer.android.com/reference/kotlin/android/hardware/display/VirtualDisplayConfig.Builder#setDimBrightness(kotlin.Float))`(`brightness:` `[Float](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-float/index.html)`)` Sets the dim brightness of the display.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        |
| [VirtualDisplayConfig.Builder](https://developer.android.com/reference/kotlin/android/hardware/display/VirtualDisplayConfig.Builder#) | [setDisplayCategories](https://developer.android.com/reference/kotlin/android/hardware/display/VirtualDisplayConfig.Builder#setDisplayCategories(kotlin.collections.MutableSet))`(`displayCategories:` `[MutableSet](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin.collections/-mutable-set/index.html)<[String](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html)!>`)` Sets the display categories.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                         |
| [VirtualDisplayConfig.Builder](https://developer.android.com/reference/kotlin/android/hardware/display/VirtualDisplayConfig.Builder#) | [setFlags](https://developer.android.com/reference/kotlin/android/hardware/display/VirtualDisplayConfig.Builder#setFlags(kotlin.Int))`(`flags:` `[Int](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html)`)` Sets the virtual display flags, a combination of[DisplayManager.VIRTUAL_DISPLAY_FLAG_PUBLIC](https://developer.android.com/reference/kotlin/android/hardware/display/DisplayManager#VIRTUAL_DISPLAY_FLAG_PUBLIC:kotlin.Int),[DisplayManager.VIRTUAL_DISPLAY_FLAG_PRESENTATION](https://developer.android.com/reference/kotlin/android/hardware/display/DisplayManager#VIRTUAL_DISPLAY_FLAG_PRESENTATION:kotlin.Int),[DisplayManager.VIRTUAL_DISPLAY_FLAG_SECURE](https://developer.android.com/reference/kotlin/android/hardware/display/DisplayManager#VIRTUAL_DISPLAY_FLAG_SECURE:kotlin.Int),[DisplayManager.VIRTUAL_DISPLAY_FLAG_OWN_CONTENT_ONLY](https://developer.android.com/reference/kotlin/android/hardware/display/DisplayManager#VIRTUAL_DISPLAY_FLAG_OWN_CONTENT_ONLY:kotlin.Int), or[DisplayManager.VIRTUAL_DISPLAY_FLAG_AUTO_MIRROR](https://developer.android.com/reference/kotlin/android/hardware/display/DisplayManager#VIRTUAL_DISPLAY_FLAG_AUTO_MIRROR:kotlin.Int). |
| [VirtualDisplayConfig.Builder](https://developer.android.com/reference/kotlin/android/hardware/display/VirtualDisplayConfig.Builder#) | [setRequestedRefreshRate](https://developer.android.com/reference/kotlin/android/hardware/display/VirtualDisplayConfig.Builder#setRequestedRefreshRate(kotlin.Float))`(`requestedRefreshRate:` `[Float](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-float/index.html)`)` Sets the refresh rate of a virtual display in frames per second.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       |
| [VirtualDisplayConfig.Builder](https://developer.android.com/reference/kotlin/android/hardware/display/VirtualDisplayConfig.Builder#) | [setSurface](https://developer.android.com/reference/kotlin/android/hardware/display/VirtualDisplayConfig.Builder#setSurface(android.view.Surface))`(`surface:` `[Surface](https://developer.android.com/reference/kotlin/android/view/Surface.html#)?`)` Sets the surface to which the content of the virtual display should be rendered.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               |

## Public constructors

### Builder

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

```
Builder(
    name: String, 
    width: Int, 
    height: Int, 
    densityDpi: Int)
```

Creates a new Builder.

|                                                                                     Parameters                                                                                      ||
|--------------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| `name`       | [String](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html):The name of the virtual display, must be non-empty. This value cannot be`null`.      |
| `width`      | [Int](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html):The width of the virtual display in pixels. Must be greater than 0. Value is 1 or greater  |
| `height`     | [Int](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html):The height of the virtual display in pixels. Must be greater than 0. Value is 1 or greater |
| `densityDpi` | [Int](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html):The density of the virtual display in dpi. Must be greater than 0. Value is 1 or greater   |

## Public methods

### addDisplayCategory

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

```
fun addDisplayCategory(displayCategory: String): VirtualDisplayConfig.Builder
```

Adds a display category.

|                                                           Parameters                                                            ||
|-------------------|--------------------------------------------------------------------------------------------------------------|
| `displayCategory` | [String](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html):This value cannot be`null`. |

|                                                                               Return                                                                               ||
|---------------------------------------------------------------------------------------------------------------------------------------|-----------------------------|
| [VirtualDisplayConfig.Builder](https://developer.android.com/reference/kotlin/android/hardware/display/VirtualDisplayConfig.Builder#) | This value cannot be`null`. |

**See Also**

- [#setDisplayCategories](https://developer.android.com/reference/kotlin/android/hardware/display/VirtualDisplayConfig.Builder#setDisplayCategories(kotlin.collections.MutableSet))  

### build

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

```
fun build(): VirtualDisplayConfig
```

Builds the[VirtualDisplayConfig](https://developer.android.com/reference/kotlin/android/hardware/display/VirtualDisplayConfig)instance.

|                                                                      Return                                                                       ||
|----------------------------------------------------------------------------------------------------------------------|-----------------------------|
| [VirtualDisplayConfig](https://developer.android.com/reference/kotlin/android/hardware/display/VirtualDisplayConfig) | This value cannot be`null`. |

|                                                     Exceptions                                                     ||
|--------------------------------------|------------------------------------------------------------------------------|
| `java.lang.IllegalArgumentException` | if the dim brightness is set to a value greater than the default brightness. |

### setBrightnessListener

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

```
fun setBrightnessListener(
    executor: Executor, 
    listener: VirtualDisplayConfig.BrightnessListener
): VirtualDisplayConfig.Builder
```

Sets the listener to get notified about changes in the display brightness.

|                                                                                                                                                                                                                                                                                                                                                                                Parameters                                                                                                                                                                                                                                                                                                                                                                                 ||
|------------|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| `executor` | [Executor](https://developer.android.com/reference/kotlin/java/util/concurrent/Executor.html#):The executor where the callback is executed on. This value cannot be`null`. Callback and listener events are dispatched through this[Executor](https://developer.android.com/reference/kotlin/java/util/concurrent/Executor.html#), providing an easy way to control which thread is used. To dispatch events through the main thread of your application, you can use[Context.getMainExecutor()](https://developer.android.com/reference/kotlin/android/content/Context.html#getMainExecutor()). Otherwise, provide an[Executor](https://developer.android.com/reference/kotlin/java/util/concurrent/Executor.html#)that dispatches to an appropriate thread. |
| `listener` | [VirtualDisplayConfig.BrightnessListener](https://developer.android.com/reference/kotlin/android/hardware/display/VirtualDisplayConfig.BrightnessListener):The listener to get notified when the display brightness has changed. This value cannot be`null`.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  |

|                                                                               Return                                                                               ||
|---------------------------------------------------------------------------------------------------------------------------------------|-----------------------------|
| [VirtualDisplayConfig.Builder](https://developer.android.com/reference/kotlin/android/hardware/display/VirtualDisplayConfig.Builder#) | This value cannot be`null`. |

### setDefaultBrightness

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

```
fun setDefaultBrightness(brightness: Float): VirtualDisplayConfig.Builder
```

Sets the default brightness of the display.

The system will use this brightness value whenever the display should be bright, i.e. it is powered on and not modified due to user activity or app activity.

Value of`0.0`indicates the minimum supported brightness and value of`1.0`indicates the maximum supported brightness.

If unset, defaults to`0.0`

|                                                              Parameters                                                               ||
|--------------|-------------------------------------------------------------------------------------------------------------------------|
| `brightness` | [Float](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-float/index.html):Value is between 0.0f and 1.0f inclusive |

|                                                                               Return                                                                               ||
|---------------------------------------------------------------------------------------------------------------------------------------|-----------------------------|
| [VirtualDisplayConfig.Builder](https://developer.android.com/reference/kotlin/android/hardware/display/VirtualDisplayConfig.Builder#) | This value cannot be`null`. |

|                                           Exceptions                                            ||
|--------------------------------------|-----------------------------------------------------------|
| `java.lang.IllegalArgumentException` | if the brightness is outside the valid range \[0.0, 1.0\] |

**See Also**

- [android.view.View#setKeepScreenOn(boolean)](https://developer.android.com/reference/kotlin/android/view/View.html#setKeepScreenOn(kotlin.Boolean))
- [#setBrightnessListener(Executor, BrightnessListener)](https://developer.android.com/reference/kotlin/android/hardware/display/VirtualDisplayConfig.Builder#setBrightnessListener(java.util.concurrent.Executor,%20android.hardware.display.VirtualDisplayConfig.BrightnessListener))  

### setDimBrightness

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

```
fun setDimBrightness(brightness: Float): VirtualDisplayConfig.Builder
```

Sets the dim brightness of the display.

The system will use this brightness value whenever the display should be dim, i.e. it is powered on and dimmed due to user activity or app activity.

Value of`0.0`indicates the minimum supported brightness and value of`1.0`indicates the maximum supported brightness.

If set, the default brightness must also be set to a value greater or equal to the dim brightness. If unset, defaults to the system default.

|                                                              Parameters                                                               ||
|--------------|-------------------------------------------------------------------------------------------------------------------------|
| `brightness` | [Float](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-float/index.html):Value is between 0.0f and 1.0f inclusive |

|                                                                               Return                                                                               ||
|---------------------------------------------------------------------------------------------------------------------------------------|-----------------------------|
| [VirtualDisplayConfig.Builder](https://developer.android.com/reference/kotlin/android/hardware/display/VirtualDisplayConfig.Builder#) | This value cannot be`null`. |

|                                           Exceptions                                            ||
|--------------------------------------|-----------------------------------------------------------|
| `java.lang.IllegalArgumentException` | if the brightness is outside the valid range \[0.0, 1.0\] |

**See Also**

- [android.hardware.display.VirtualDisplayConfig.Builder#setDefaultBrightness(float)](https://developer.android.com/reference/kotlin/android/hardware/display/VirtualDisplayConfig.Builder#setDefaultBrightness(kotlin.Float))
- [#setBrightnessListener(Executor, BrightnessListener)](https://developer.android.com/reference/kotlin/android/hardware/display/VirtualDisplayConfig.Builder#setBrightnessListener(java.util.concurrent.Executor,%20android.hardware.display.VirtualDisplayConfig.BrightnessListener))  

### setDisplayCategories

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

```
fun setDisplayCategories(displayCategories: MutableSet<String!>): VirtualDisplayConfig.Builder
```

Sets the display categories.

The categories of the display indicate the type of activities allowed to run on that display. Activities can declare a display category using[android.content.pm.ActivityInfo#requiredDisplayCategory](https://developer.android.com/reference/kotlin/android/content/pm/ActivityInfo.html#requiredDisplayCategory:kotlin.String).

|                                                                                                                 Parameters                                                                                                                  ||
|---------------------|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| `displayCategories` | [MutableSet](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin.collections/-mutable-set/index.html)\<[String](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html)!\>:This value cannot be`null`. |

|                                                                               Return                                                                               ||
|---------------------------------------------------------------------------------------------------------------------------------------|-----------------------------|
| [VirtualDisplayConfig.Builder](https://developer.android.com/reference/kotlin/android/hardware/display/VirtualDisplayConfig.Builder#) | This value cannot be`null`. |

### setFlags

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

```
fun setFlags(flags: Int): VirtualDisplayConfig.Builder
```

Sets the virtual display flags, a combination of[DisplayManager.VIRTUAL_DISPLAY_FLAG_PUBLIC](https://developer.android.com/reference/kotlin/android/hardware/display/DisplayManager#VIRTUAL_DISPLAY_FLAG_PUBLIC:kotlin.Int),[DisplayManager.VIRTUAL_DISPLAY_FLAG_PRESENTATION](https://developer.android.com/reference/kotlin/android/hardware/display/DisplayManager#VIRTUAL_DISPLAY_FLAG_PRESENTATION:kotlin.Int),[DisplayManager.VIRTUAL_DISPLAY_FLAG_SECURE](https://developer.android.com/reference/kotlin/android/hardware/display/DisplayManager#VIRTUAL_DISPLAY_FLAG_SECURE:kotlin.Int),[DisplayManager.VIRTUAL_DISPLAY_FLAG_OWN_CONTENT_ONLY](https://developer.android.com/reference/kotlin/android/hardware/display/DisplayManager#VIRTUAL_DISPLAY_FLAG_OWN_CONTENT_ONLY:kotlin.Int), or[DisplayManager.VIRTUAL_DISPLAY_FLAG_AUTO_MIRROR](https://developer.android.com/reference/kotlin/android/hardware/display/DisplayManager#VIRTUAL_DISPLAY_FLAG_AUTO_MIRROR:kotlin.Int).

|                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  Parameters                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  ||
|---------|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| `flags` | [Int](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html):Value is either`0`or a combination of[android.hardware.display.DisplayManager#VIRTUAL_DISPLAY_FLAG_PUBLIC](https://developer.android.com/reference/kotlin/android/hardware/display/DisplayManager#VIRTUAL_DISPLAY_FLAG_PUBLIC:kotlin.Int),[android.hardware.display.DisplayManager#VIRTUAL_DISPLAY_FLAG_PRESENTATION](https://developer.android.com/reference/kotlin/android/hardware/display/DisplayManager#VIRTUAL_DISPLAY_FLAG_PRESENTATION:kotlin.Int),[android.hardware.display.DisplayManager#VIRTUAL_DISPLAY_FLAG_SECURE](https://developer.android.com/reference/kotlin/android/hardware/display/DisplayManager#VIRTUAL_DISPLAY_FLAG_SECURE:kotlin.Int),[android.hardware.display.DisplayManager#VIRTUAL_DISPLAY_FLAG_OWN_CONTENT_ONLY](https://developer.android.com/reference/kotlin/android/hardware/display/DisplayManager#VIRTUAL_DISPLAY_FLAG_OWN_CONTENT_ONLY:kotlin.Int),[android.hardware.display.DisplayManager#VIRTUAL_DISPLAY_FLAG_AUTO_MIRROR](https://developer.android.com/reference/kotlin/android/hardware/display/DisplayManager#VIRTUAL_DISPLAY_FLAG_AUTO_MIRROR:kotlin.Int), android.hardware.display.DisplayManager.VIRTUAL_DISPLAY_FLAG_CAN_SHOW_WITH_INSECURE_KEYGUARD, android.hardware.display.DisplayManager.VIRTUAL_DISPLAY_FLAG_SUPPORTS_TOUCH, android.hardware.display.DisplayManager.VIRTUAL_DISPLAY_FLAG_ROTATES_WITH_CONTENT, android.hardware.display.DisplayManager.VIRTUAL_DISPLAY_FLAG_DESTROY_CONTENT_ON_REMOVAL, android.hardware.display.DisplayManager.VIRTUAL_DISPLAY_FLAG_SHOULD_SHOW_SYSTEM_DECORATIONS, android.hardware.display.DisplayManager.VIRTUAL_DISPLAY_FLAG_TRUSTED, android.hardware.display.DisplayManager.VIRTUAL_DISPLAY_FLAG_OWN_DISPLAY_GROUP, android.hardware.display.DisplayManager.VIRTUAL_DISPLAY_FLAG_ALWAYS_UNLOCKED, android.hardware.display.DisplayManager.VIRTUAL_DISPLAY_FLAG_TOUCH_FEEDBACK_DISABLED, android.hardware.display.DisplayManager.VIRTUAL_DISPLAY_FLAG_OWN_FOCUS, and android.hardware.display.DisplayManager.VIRTUAL_DISPLAY_FLAG_STEAL_TOP_FOCUS_DISABLED |

|                                                                               Return                                                                               ||
|---------------------------------------------------------------------------------------------------------------------------------------|-----------------------------|
| [VirtualDisplayConfig.Builder](https://developer.android.com/reference/kotlin/android/hardware/display/VirtualDisplayConfig.Builder#) | This value cannot be`null`. |

### setRequestedRefreshRate

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

```
fun setRequestedRefreshRate(requestedRefreshRate: Float): VirtualDisplayConfig.Builder
```

Sets the refresh rate of a virtual display in frames per second.

For best results, specify a divisor of the physical refresh rate, e.g., 30 or 60 on a 120hz display. If an arbitrary refresh rate is specified, the rate will be rounded up to a divisor of the physical display. If unset or zero, the virtual display will be refreshed at the physical display refresh rate.

|                                                           Parameters                                                            ||
|------------------------|---------------------------------------------------------------------------------------------------------|
| `requestedRefreshRate` | [Float](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-float/index.html):Value is 0.0f or greater |

|                                                                               Return                                                                               ||
|---------------------------------------------------------------------------------------------------------------------------------------|-----------------------------|
| [VirtualDisplayConfig.Builder](https://developer.android.com/reference/kotlin/android/hardware/display/VirtualDisplayConfig.Builder#) | This value cannot be`null`. |

**See Also**

- [android.view.Display#getRefreshRate()](https://developer.android.com/reference/kotlin/android/view/Display.html#getRefreshRate())  

### setSurface

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

```
fun setSurface(surface: Surface?): VirtualDisplayConfig.Builder
```

Sets the surface to which the content of the virtual display should be rendered.

The surface can also be set after the display creation using[VirtualDisplay.setSurface(Surface)](https://developer.android.com/reference/kotlin/android/hardware/display/VirtualDisplay#setSurface(android.view.Surface)).

|                                                        Parameters                                                         ||
|-----------|----------------------------------------------------------------------------------------------------------------|
| `surface` | [Surface](https://developer.android.com/reference/kotlin/android/view/Surface.html#)?:This value may be`null`. |

|                                                                               Return                                                                               ||
|---------------------------------------------------------------------------------------------------------------------------------------|-----------------------------|
| [VirtualDisplayConfig.Builder](https://developer.android.com/reference/kotlin/android/hardware/display/VirtualDisplayConfig.Builder#) | This value cannot be`null`. |