Added in API level 34

Builder

class Builder
kotlin.Any
   ↳ android.hardware.display.VirtualDisplayConfig.Builder

A builder for VirtualDisplayConfig.

Summary

Public constructors
Builder(name: String, width: Int, height: Int, densityDpi: Int)

Creates a new Builder.

Public methods
VirtualDisplayConfig.Builder
addDisplayCategory(displayCategory: String)

Adds a display category.

VirtualDisplayConfig

Builds the VirtualDisplayConfig instance.

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

Sets the display categories.

VirtualDisplayConfig.Builder
setFlags(flags: Int)

Sets the virtual display flags, a combination of DisplayManager#VIRTUAL_DISPLAY_FLAG_PUBLIC, DisplayManager#VIRTUAL_DISPLAY_FLAG_PRESENTATION, DisplayManager#VIRTUAL_DISPLAY_FLAG_SECURE, DisplayManager#VIRTUAL_DISPLAY_FLAG_OWN_CONTENT_ONLY, or DisplayManager#VIRTUAL_DISPLAY_FLAG_AUTO_MIRROR.

VirtualDisplayConfig.Builder
setRequestedRefreshRate(requestedRefreshRate: Float)

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

VirtualDisplayConfig.Builder
setSurface(surface: Surface?)

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

Public constructors

Builder

Added in API level 34
Builder(
    name: String,
    width: Int,
    height: Int,
    densityDpi: Int)

Creates a new Builder.

Parameters
name String: The name of the virtual display, must be non-empty. This value cannot be null.
width Int: The width of the virtual display in pixels. Must be greater than 0. Value is 1 or greater
height Int: The height of the virtual display in pixels. Must be greater than 0. Value is 1 or greater
densityDpi Int: 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
fun addDisplayCategory(displayCategory: String): VirtualDisplayConfig.Builder

Adds a display category.

Parameters
displayCategory String: This value cannot be null.
Return
VirtualDisplayConfig.Builder This value cannot be null.

build

Added in API level 34
fun build(): VirtualDisplayConfig

Builds the VirtualDisplayConfig instance.

Return
VirtualDisplayConfig This value cannot be null.

setDisplayCategories

Added in API level 34
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.

Parameters
displayCategories MutableSet<String!>: This value cannot be null.
Return
VirtualDisplayConfig.Builder This value cannot be null.

setFlags

Added in API level 34
fun setFlags(flags: Int): VirtualDisplayConfig.Builder

Sets the virtual display flags, a combination of DisplayManager#VIRTUAL_DISPLAY_FLAG_PUBLIC, DisplayManager#VIRTUAL_DISPLAY_FLAG_PRESENTATION, DisplayManager#VIRTUAL_DISPLAY_FLAG_SECURE, DisplayManager#VIRTUAL_DISPLAY_FLAG_OWN_CONTENT_ONLY, or DisplayManager#VIRTUAL_DISPLAY_FLAG_AUTO_MIRROR.

Parameters
flags Int: Value is either 0 or a combination of android.hardware.display.DisplayManager#VIRTUAL_DISPLAY_FLAG_PUBLIC, android.hardware.display.DisplayManager#VIRTUAL_DISPLAY_FLAG_PRESENTATION, android.hardware.display.DisplayManager#VIRTUAL_DISPLAY_FLAG_SECURE, android.hardware.display.DisplayManager#VIRTUAL_DISPLAY_FLAG_OWN_CONTENT_ONLY, android.hardware.display.DisplayManager#VIRTUAL_DISPLAY_FLAG_AUTO_MIRROR, 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 This value cannot be null.

setRequestedRefreshRate

Added in API level 34
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: Value is 0.0f or greater
Return
VirtualDisplayConfig.Builder This value cannot be null.

setSurface

Added in API level 34
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).

Parameters
surface Surface?: This value may be null.
Return
VirtualDisplayConfig.Builder This value cannot be null.