class ByWindowSelector


A ByWindowSelector specifies criteria for matching UI windows during a call to findWindow.

Summary

Public functions

ByWindowSelector
active(isActive: Boolean)

Sets the search criteria to match windows that are active or inactive.

ByWindowSelector
@RequiresApi(value = 30)
displayId(displayId: Int)

Adds a display ID selector criteria for matching.

ByWindowSelector
focused(isFocused: Boolean)

Sets the search criteria to match windows that are focused or not.

ByWindowSelector
id(id: Int)

Sets the id criteria for matching.

ByWindowSelector
layer(exactLayer: @IntRange(from = 0) Int)

Sets the layer (Z-order) criteria for matching.

ByWindowSelector
layerAbove(referenceLayer: @IntRange(from = 0) Int)

Sets the layer (Z-order) criteria for finding windows that are layered above the specified reference layer.

ByWindowSelector
layerBelow(referenceLayer: @IntRange(from = 1) Int)

Sets the layer (Z-order) criteria for finding windows that are layered below the specified reference layer.

ByWindowSelector
pkg(packageName: Pattern)

Sets the package name criteria for window matching.

ByWindowSelector
pkg(packageName: String)

Sets the package name criteria for window matching.

ByWindowSelector
title(title: Pattern)

Sets the title criteria for matching.

ByWindowSelector
title(title: String)

Sets the title criteria for matching.

ByWindowSelector
titleContains(substring: String)

Sets the title criteria for matching.

ByWindowSelector

Sets the title criteria for matching.

ByWindowSelector

Sets the title criteria for matching.

String

Returns a String representation of this ByWindowSelector.

ByWindowSelector
type(type: Int)

Sets the type criteria for window matching.

Public functions

active

Added in 2.4.0-alpha06
fun active(isActive: Boolean): ByWindowSelector

Sets the search criteria to match windows that are active or inactive.

Parameters
isActive: Boolean

Whether to match windows that are active or inactive.

Returns
ByWindowSelector

A reference to this ByWindowSelector.

displayId

Added in 2.4.0-alpha06
@RequiresApi(value = 30)
fun displayId(displayId: Int): ByWindowSelector

Adds a display ID selector criteria for matching. A UI element will be considered a match if it is within the display with the ID of displayId and all other criteria for this selector are met.

Parameters
displayId: Int

The display ID to match. Use Display#getDisplayId() to get the ID.

Returns
ByWindowSelector

A reference to this ByWindowSelector.

focused

Added in 2.4.0-alpha06
fun focused(isFocused: Boolean): ByWindowSelector

Sets the search criteria to match windows that are focused or not.

Parameters
isFocused: Boolean

Whether to match windows that are focused or not.

Returns
ByWindowSelector

A reference to this ByWindowSelector.

id

Added in 2.4.0-alpha06
fun id(id: Int): ByWindowSelector

Sets the id criteria for matching. A UI window will be considered a match if its id matches the id parameter and all other criteria for this selector are met.

Parameters
id: Int

The id to match.

Returns
ByWindowSelector

A reference to this ByWindowSelector.

layer

Added in 2.4.0-alpha06
fun layer(exactLayer: @IntRange(from = 0) Int): ByWindowSelector

Sets the layer (Z-order) criteria for matching. A UI window will be considered a match if its layer matches the layer parameter and all other criteria for this selector are met.

Parameters
exactLayer: @IntRange(from = 0) Int

The layer to match.

Returns
ByWindowSelector

A reference to this ByWindowSelector.

layerAbove

Added in 2.4.0-alpha06
fun layerAbove(referenceLayer: @IntRange(from = 0) Int): ByWindowSelector

Sets the layer (Z-order) criteria for finding windows that are layered above the specified reference layer.

Parameters
referenceLayer: @IntRange(from = 0) Int

The layer which matching windows must be above.

Returns
ByWindowSelector

A reference to this ByWindowSelector.

layerBelow

Added in 2.4.0-alpha06
fun layerBelow(referenceLayer: @IntRange(from = 1) Int): ByWindowSelector

Sets the layer (Z-order) criteria for finding windows that are layered below the specified reference layer.

Parameters
referenceLayer: @IntRange(from = 1) Int

The layer which matching windows must be below. must be positive.

Returns
ByWindowSelector

A reference to this ByWindowSelector.

pkg

Added in 2.4.0-alpha06
fun pkg(packageName: Pattern): ByWindowSelector

Sets the package name criteria for window matching. A UI window will be considered a match if its package name exactly matches the packageName and all other criteria for this selector are met.

Parameters
packageName: Pattern

The Pattern to be used for window matching.

Returns
ByWindowSelector

A reference to this ByWindowSelector.

pkg

Added in 2.4.0-alpha06
fun pkg(packageName: String): ByWindowSelector

Sets the package name criteria for window matching. A UI window will be considered a match if its package name exactly matches the packageName and all other criteria for this selector are met.

Parameters
packageName: String

The exact package name to match (case-sensitive). e.g. "com.example .android"

Returns
ByWindowSelector

A reference to this ByWindowSelector.

title

Added in 2.4.0-alpha06
fun title(title: Pattern): ByWindowSelector

Sets the title criteria for matching. A UI window will be considered a match if its title matches the titlePattern and all other criteria for this selector are met.

Parameters
title: Pattern

The Pattern to be used for window matching.

Returns
ByWindowSelector

A reference to this ByWindowSelector.

title

Added in 2.4.0-alpha06
fun title(title: String): ByWindowSelector

Sets the title criteria for matching. A UI window will be considered a match if its title exactly matches the title parameter and all other criteria for this selector are met.

Parameters
title: String

The exact value to match (case-sensitive).

Returns
ByWindowSelector

A reference to this ByWindowSelector.

titleContains

Added in 2.4.0-alpha06
fun titleContains(substring: String): ByWindowSelector

Sets the title criteria for matching. A UI window will be considered a match if its title contains the substring and all other criteria for this selector are met.

Parameters
substring: String

The substring to match (case-sensitive).

Returns
ByWindowSelector

A reference to this ByWindowSelector.

titleEndsWith

Added in 2.4.0-alpha06
fun titleEndsWith(suffix: String): ByWindowSelector

Sets the title criteria for matching. A UI window will be considered a match if its title ends with the suffix and all other criteria for this selector are met.

Parameters
suffix: String

The suffix to match (case-sensitive).

Returns
ByWindowSelector

A reference to this ByWindowSelector.

titleStartsWith

Added in 2.4.0-alpha06
fun titleStartsWith(prefix: String): ByWindowSelector

Sets the title criteria for matching. A UI window will be considered a match if its title starts with the prefix and all other criteria for this selector are met.

Parameters
prefix: String

The prefix to match (case-sensitive).

Returns
ByWindowSelector

A reference to this ByWindowSelector.

toString

fun toString(): String

Returns a String representation of this ByWindowSelector. The format is "ByWindowSelector [='', ... ]". Each criteria is listed as a key-value pair where the key is the name of the criteria expressed in all caps (e.g. TYPE, TITLE, etc).

type

Added in 2.4.0-alpha06
fun type(type: Int): ByWindowSelector

Sets the type criteria for window matching. A UI window will be considered a match if its type exactly matches the type and all other criteria for this selector are met.

Parameters
type: Int

The exact type to match (e.g. TYPE_APPLICATION).

Returns
ByWindowSelector

A reference to this ByWindowSelector.