# 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)

*** ** * ** ***


```
public final class ApplicationCommands
```

<br />

*** ** * ** ***

Commands to be used on applications.

## Summary

| ### Public methods |
|---|---|
| `final void` | `https://developer.android.com/reference/androidx/test/shell/command/ApplicationCommands#amStartActivityIntent(android.content.Intent,kotlin.String)( @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/android/content/Intent.html intent, @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/java/lang/String.html additionalArguments )` Starts an activity intent via `am start` shell command, using the intent uri as target. |
| `final void` | `https://developer.android.com/reference/androidx/test/shell/command/ApplicationCommands#clearAppData(kotlin.String)(@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/java/lang/String.html packageName)` Clears the application data. |
| `final void` | `https://developer.android.com/reference/androidx/test/shell/command/ApplicationCommands#startApp(kotlin.String)(@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/java/lang/String.html packageName)` Starts the application. |
| `final void` | `https://developer.android.com/reference/androidx/test/shell/command/ApplicationCommands#stopApp(kotlin.String)(@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/java/lang/String.html packageName)` Stops the application. |

## Public methods

### amStartActivityIntent

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

```
public final void amStartActivityIntent(
    @NonNull Intent intent,
    @NonNull String additionalArguments
)
```

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 |
|---|---|
| `@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/android/content/Intent.html intent` | activity intent to start. |
| `@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/java/lang/String.html additionalArguments` | 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)

```
public final void clearAppData(@NonNull String packageName)
```

Clears the application data.

### startApp

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

```
public final void startApp(@NonNull String packageName)
```

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)

```
public final void stopApp(@NonNull String packageName)
```

Stops the application.