# ApplicationCommands

Artifact: [androidx.test.uiautomator:uiautomator-shell](https://developer.android.com/jetpack/androidx/releases/test-uiautomator) [View Source](https://cs.android.com/search?q=file:androidx/test/shell/command/ApplicationCommands.kt+class:androidx.test.shell.command.ApplicationCommands) Added in [2.4.1](https://developer.android.com/jetpack/androidx/releases/test-uiautomator#2.4.1)

*** ** * ** ***


```
class ApplicationCommands
```

<br />

*** ** * ** ***

Commands to be used on applications.

## Summary

| ### Public functions |
|---|---|
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` | `https://developer.android.com/reference/kotlin/androidx/test/shell/command/ApplicationCommands#amStartActivityIntent(android.content.Intent,kotlin.String)(intent: https://developer.android.com/reference/android/content/Intent.html, additionalArguments: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html)` Starts an activity intent via `am start` shell command, using the intent uri as target. |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` | `https://developer.android.com/reference/kotlin/androidx/test/shell/command/ApplicationCommands#clearAppData(kotlin.String)(packageName: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html)` Clears the application data. |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` | `https://developer.android.com/reference/kotlin/androidx/test/shell/command/ApplicationCommands#startApp(kotlin.String)(packageName: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html)` Starts the application. |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` | `https://developer.android.com/reference/kotlin/androidx/test/shell/command/ApplicationCommands#stopApp(kotlin.String)(packageName: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html)` Stops the application. |

## Public functions

### amStartActivityIntent

Added in [2.4.1](https://developer.android.com/jetpack/androidx/releases/test-uiautomator#2.4.1)

```
fun amStartActivityIntent(intent: Intent, additionalArguments: String = ""): Unit
```

Starts an activity intent via `am start` shell command, using the intent uri as target.

Note that parcelables are not serialized in the URI and so will be ignored as part of the intent when calling this method.

| Parameters |
|---|---|
| `intent: https://developer.android.com/reference/android/content/Intent.html` | activity intent to start. |
| `additionalArguments: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html = ""` | additional arguments to pass to `am start` command, space separated, as these are passed to adb shell directly. |

### clearAppData

Added in [2.4.1](https://developer.android.com/jetpack/androidx/releases/test-uiautomator#2.4.1)

```
fun clearAppData(packageName: String): Unit
```

Clears the application data.

### startApp

Added in [2.4.1](https://developer.android.com/jetpack/androidx/releases/test-uiautomator#2.4.1)

```
fun startApp(packageName: String): Unit
```

Starts the application. The first activity with category main and action launch is selected.

### stopApp

Added in [2.4.1](https://developer.android.com/jetpack/androidx/releases/test-uiautomator#2.4.1)

```
fun stopApp(packageName: String): Unit
```

Stops the application.