foreground

fun foreground(uiAutomation: UiAutomation, packageName: String): Boolean

Checks if the app with the given packageName is in the foreground, using the adb shell dumpsys activity activities command.

dumpsys: To dump all service info activity: To dump activity info activities: To dump all activities

Return

True if at least one activity is in foreground

Parameters

uiAutomation

The automation instance used for automated testing

packageName

The package of the app