# KeyedAppStatesReporter

Artifact: [androidx.enterprise:enterprise-feedback](https://developer.android.com/jetpack/androidx/releases/enterprise) [View Source](https://cs.android.com/search?q=file:androidx/enterprise/feedback/KeyedAppStatesReporter.java+class:androidx.enterprise.feedback.KeyedAppStatesReporter) Added in [1.0.0](https://developer.android.com/jetpack/androidx/releases/enterprise#1.0.0)

*** ** * ** ***


```
abstract class KeyedAppStatesReporter
```

<br />

Known direct subclasses [FakeKeyedAppStatesReporter](https://developer.android.com/reference/kotlin/androidx/enterprise/feedback/FakeKeyedAppStatesReporter)

|---|---|
| `https://developer.android.com/reference/kotlin/androidx/enterprise/feedback/FakeKeyedAppStatesReporter` | A fake `https://developer.android.com/reference/kotlin/androidx/enterprise/feedback/KeyedAppStatesReporter` for testing. |

*** ** * ** ***

A reporter of keyed app states to enable communication between an app and an EMM (enterprise mobility management). For production, create an instance using `https://developer.android.com/reference/kotlin/androidx/enterprise/feedback/KeyedAppStatesReporter#create(android.content.Context)`. For testing see the `FakeKeyedAppStatesReporter` class in the `enterprise-feedback-testing` artifact.

## Summary

| ### Public functions |
|---|---|
| `java-static https://developer.android.com/reference/kotlin/androidx/enterprise/feedback/KeyedAppStatesReporter` | `https://developer.android.com/reference/kotlin/androidx/enterprise/feedback/KeyedAppStatesReporter#create(android.content.Context)(context: https://developer.android.com/reference/android/content/Context.html)` Create a reporter that binds to device owners, profile owners, and the Play store. |
| `java-static https://developer.android.com/reference/kotlin/androidx/enterprise/feedback/KeyedAppStatesReporter` | `https://developer.android.com/reference/kotlin/androidx/enterprise/feedback/KeyedAppStatesReporter#create(android.content.Context,java.util.concurrent.Executor)(context: https://developer.android.com/reference/android/content/Context.html, executor: https://developer.android.com/reference/java/util/concurrent/Executor.html)` Create a reporter using the specified executor. |
| `abstract https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` | `[setStates](https://developer.android.com/reference/kotlin/androidx/enterprise/feedback/KeyedAppStatesReporter#setStates(java.util.Collection<androidx.enterprise.feedback.KeyedAppState>))(states: (https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.collections/-mutable-collection/index.html)https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.collections/-collection/index.html<https://developer.android.com/reference/kotlin/androidx/enterprise/feedback/KeyedAppState!>)` **This function is deprecated.** use `https://developer.android.com/reference/kotlin/androidx/enterprise/feedback/KeyedAppStatesReporter#setStates(java.util.Collection<androidx.enterprise.feedback.KeyedAppState>,androidx.enterprise.feedback.KeyedAppStatesCallback)` which reports errors. <br /> |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` | `https://developer.android.com/reference/kotlin/androidx/enterprise/feedback/KeyedAppStatesReporter#setStates(java.util.Collection<androidx.enterprise.feedback.KeyedAppState>,androidx.enterprise.feedback.KeyedAppStatesCallback)( states: (https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.collections/-mutable-collection/index.html)https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.collections/-collection/index.html<https://developer.android.com/reference/kotlin/androidx/enterprise/feedback/KeyedAppState!>, callback: https://developer.android.com/reference/kotlin/androidx/enterprise/feedback/KeyedAppStatesCallback? )` Set app states to be sent to an EMM (enterprise mobility management). |
| `abstract https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` | `[setStatesImmediate](https://developer.android.com/reference/kotlin/androidx/enterprise/feedback/KeyedAppStatesReporter#setStatesImmediate(java.util.Collection<androidx.enterprise.feedback.KeyedAppState>))(states: (https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.collections/-mutable-collection/index.html)https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.collections/-collection/index.html<https://developer.android.com/reference/kotlin/androidx/enterprise/feedback/KeyedAppState!>)` **This function is deprecated.** use `https://developer.android.com/reference/kotlin/androidx/enterprise/feedback/KeyedAppStatesReporter#setStatesImmediate(java.util.Collection<androidx.enterprise.feedback.KeyedAppState>,androidx.enterprise.feedback.KeyedAppStatesCallback)` which reports errors. <br /> |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` | `https://developer.android.com/reference/kotlin/androidx/enterprise/feedback/KeyedAppStatesReporter#setStatesImmediate(java.util.Collection<androidx.enterprise.feedback.KeyedAppState>,androidx.enterprise.feedback.KeyedAppStatesCallback)( states: (https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.collections/-mutable-collection/index.html)https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.collections/-collection/index.html<https://developer.android.com/reference/kotlin/androidx/enterprise/feedback/KeyedAppState!>, callback: https://developer.android.com/reference/kotlin/androidx/enterprise/feedback/KeyedAppStatesCallback? )` Performs the same function as `https://developer.android.com/reference/kotlin/androidx/enterprise/feedback/KeyedAppStatesReporter#setStates(java.util.Collection<androidx.enterprise.feedback.KeyedAppState>,androidx.enterprise.feedback.KeyedAppStatesCallback)`, except it also requests that the states are immediately uploaded to be accessible via server APIs. |

## Public functions

### create

Added in [1.0.0](https://developer.android.com/jetpack/androidx/releases/enterprise#1.0.0)

```
java-static fun create(context: Context): KeyedAppStatesReporter
```

Create a reporter that binds to device owners, profile owners, and the Play store.

Each instance maintains bindings, so it's recommended that you maintain a single instance for your whole app, rather than creating instances as needed.

### create

Added in [1.0.0](https://developer.android.com/jetpack/androidx/releases/enterprise#1.0.0)

```
java-static fun create(context: Context, executor: Executor): KeyedAppStatesReporter
```

Create a reporter using the specified executor.

Each instance maintains bindings, so it's recommended that you maintain a single instance for your whole app, rather than creating instances as needed.

The executor must run all `https://developer.android.com/reference/java/lang/Runnable.html` instances on the same thread, serially.

### setStates

Added in [1.0.0](https://developer.android.com/jetpack/androidx/releases/enterprise#1.0.0) Deprecated in [1.1.0](https://developer.android.com/jetpack/androidx/releases/enterprise#1.1.0)

```
abstract fun [setStates](https://developer.android.com/reference/kotlin/androidx/enterprise/feedback/KeyedAppStatesReporter#setStates(java.util.Collection<androidx.enterprise.feedback.KeyedAppState>))(states: (Mutable)Collection<KeyedAppState!>): Unit
```

> [!CAUTION]
> **This function is deprecated.**   
>
> use `https://developer.android.com/reference/kotlin/androidx/enterprise/feedback/KeyedAppStatesReporter#setStates(java.util.Collection<androidx.enterprise.feedback.KeyedAppState>,androidx.enterprise.feedback.KeyedAppStatesCallback)` which reports errors.

### setStates

Added in [1.1.0](https://developer.android.com/jetpack/androidx/releases/enterprise#1.1.0)

```
fun setStates(
    states: (Mutable)Collection<KeyedAppState!>,
    callback: KeyedAppStatesCallback?
): Unit
```

Set app states to be sent to an EMM (enterprise mobility management). The EMM can then display this information to the management organization.

Do not send personally-identifiable information with this method.

Each provided keyed app state will replace any previously set keyed app states with the same key for this package name.

If multiple keyed app states are set with the same key, only one will be received by the EMM. Which will be received is not defined.

This information is sent immediately to all device owner and profile owner apps on the device. It is also sent immediately to the app with package name com.android.vending if it exists, which is the Play Store on GMS devices.

EMMs can access these states either directly in a custom DPC (device policy manager), via Android Management APIs, or via Play EMM APIs.

`https://developer.android.com/reference/kotlin/androidx/enterprise/feedback/KeyedAppStatesCallback#onResult(int,java.lang.Throwable)` will be called when an error occurs.

| See also |
|---|---|
| `https://developer.android.com/reference/kotlin/androidx/enterprise/feedback/KeyedAppStatesReporter#setStatesImmediate(java.util.Collection<androidx.enterprise.feedback.KeyedAppState>,androidx.enterprise.feedback.KeyedAppStatesCallback)` |   |

### setStatesImmediate

Added in [1.0.0](https://developer.android.com/jetpack/androidx/releases/enterprise#1.0.0) Deprecated in [1.1.0](https://developer.android.com/jetpack/androidx/releases/enterprise#1.1.0)

```
abstract fun [setStatesImmediate](https://developer.android.com/reference/kotlin/androidx/enterprise/feedback/KeyedAppStatesReporter#setStatesImmediate(java.util.Collection<androidx.enterprise.feedback.KeyedAppState>))(states: (Mutable)Collection<KeyedAppState!>): Unit
```

> [!CAUTION]
> **This function is deprecated.**   
>
> use `https://developer.android.com/reference/kotlin/androidx/enterprise/feedback/KeyedAppStatesReporter#setStatesImmediate(java.util.Collection<androidx.enterprise.feedback.KeyedAppState>,androidx.enterprise.feedback.KeyedAppStatesCallback)` which reports errors.

### setStatesImmediate

Added in [1.1.0](https://developer.android.com/jetpack/androidx/releases/enterprise#1.1.0)

```
fun setStatesImmediate(
    states: (Mutable)Collection<KeyedAppState!>,
    callback: KeyedAppStatesCallback?
): Unit
```

Performs the same function as `https://developer.android.com/reference/kotlin/androidx/enterprise/feedback/KeyedAppStatesReporter#setStates(java.util.Collection<androidx.enterprise.feedback.KeyedAppState>,androidx.enterprise.feedback.KeyedAppStatesCallback)`, except it also requests that the states are immediately uploaded to be accessible via server APIs.

The receiver is not obligated to meet this immediate upload request. For example, Play and Android Management APIs have daily quotas.

`https://developer.android.com/reference/kotlin/androidx/enterprise/feedback/KeyedAppStatesCallback#onResult(int,java.lang.Throwable)` will be called when an error occurs.

| See also |
|---|---|
| `https://developer.android.com/reference/kotlin/androidx/enterprise/feedback/KeyedAppStatesReporter#setStates(java.util.Collection<androidx.enterprise.feedback.KeyedAppState>,androidx.enterprise.feedback.KeyedAppStatesCallback)` |   |