# TakenAction

Artifact: [androidx.appsearch:appsearch](https://developer.android.com/jetpack/androidx/releases/appsearch) [View Source](https://cs.android.com/search?q=file:androidx/appsearch/usagereporting/TakenAction.java+class:androidx.appsearch.usagereporting.TakenAction) Added in [1.1.0](https://developer.android.com/jetpack/androidx/releases/appsearch#1.1.0)

*** ** * ** ***


```
@Document(name = "builtin:TakenAction")
@ExperimentalAppSearchApi
abstract class TakenAction
```

<br />

Known direct subclasses [ClickAction](https://developer.android.com/reference/kotlin/androidx/appsearch/usagereporting/ClickAction), [DismissAction](https://developer.android.com/reference/kotlin/androidx/appsearch/usagereporting/DismissAction), [ImpressionAction](https://developer.android.com/reference/kotlin/androidx/appsearch/usagereporting/ImpressionAction), [SearchAction](https://developer.android.com/reference/kotlin/androidx/appsearch/usagereporting/SearchAction)

|---|---|
| `https://developer.android.com/reference/kotlin/androidx/appsearch/usagereporting/ClickAction` | `https://developer.android.com/reference/kotlin/androidx/appsearch/usagereporting/ClickAction` is a built-in AppSearch document type that contains different metrics. |
| `https://developer.android.com/reference/kotlin/androidx/appsearch/usagereporting/DismissAction` | `https://developer.android.com/reference/kotlin/androidx/appsearch/usagereporting/DismissAction` is a built-in AppSearch document type that contains different metrics. |
| `https://developer.android.com/reference/kotlin/androidx/appsearch/usagereporting/ImpressionAction` | `https://developer.android.com/reference/kotlin/androidx/appsearch/usagereporting/ImpressionAction` is a built-in AppSearch document type that contains different metrics. |
| `https://developer.android.com/reference/kotlin/androidx/appsearch/usagereporting/SearchAction` | `https://developer.android.com/reference/kotlin/androidx/appsearch/usagereporting/SearchAction` is a built-in AppSearch document type that contains different metrics. |

*** ** * ** ***

`https://developer.android.com/reference/kotlin/androidx/appsearch/usagereporting/TakenAction` is an abstract class which holds common fields of other AppSearch built-in action types (e.g. `https://developer.android.com/reference/kotlin/androidx/appsearch/usagereporting/SearchAction`, `https://developer.android.com/reference/kotlin/androidx/appsearch/usagereporting/ClickAction`).

Clients can report the user's actions by creating concrete actions with `https://developer.android.com/reference/kotlin/androidx/appsearch/app/PutDocumentsRequest.Builder#addTakenActions(androidx.appsearch.usagereporting.TakenAction...)` API.

## Summary

| ### Nested types |
|---|
| `@https://developer.android.com/reference/kotlin/androidx/appsearch/app/ExperimentalAppSearchApi class https://developer.android.com/reference/kotlin/androidx/appsearch/usagereporting/TakenAction.BuilderBase<T : https://developer.android.com/reference/kotlin/androidx/appsearch/usagereporting/TakenAction.BuilderBase<T!>?>` Builder for `https://developer.android.com/reference/kotlin/androidx/appsearch/usagereporting/TakenAction`. |

| ### Public constructors |
|---|
| `@https://developer.android.com/reference/kotlin/androidx/appsearch/app/ExperimentalAppSearchApi https://developer.android.com/reference/kotlin/androidx/appsearch/usagereporting/TakenAction#TakenAction(androidx.appsearch.usagereporting.TakenAction.BuilderBase<?>)(builder: https://developer.android.com/reference/kotlin/androidx/appsearch/usagereporting/TakenAction.BuilderBase<*>)` Constructs a `https://developer.android.com/reference/kotlin/androidx/appsearch/usagereporting/TakenAction` from a `https://developer.android.com/reference/kotlin/androidx/appsearch/usagereporting/TakenAction.BuilderBase`. |

| ### Public functions |
|---|---|
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-long/index.html` | `https://developer.android.com/reference/kotlin/androidx/appsearch/usagereporting/TakenAction#getActionTimestampMillis()()` Returns the timestamp when the user took the action, in milliseconds since Unix epoch. |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | `@https://developer.android.com/reference/kotlin/androidx/appsearch/app/ExperimentalAppSearchApi https://developer.android.com/reference/kotlin/androidx/appsearch/usagereporting/TakenAction#getActionType()()` Returns the action type of the `https://developer.android.com/reference/kotlin/androidx/appsearch/usagereporting/TakenAction`. |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-long/index.html` | `https://developer.android.com/reference/kotlin/androidx/appsearch/usagereporting/TakenAction#getDocumentTtlMillis()()` Returns the time-to-live (TTL) of the `https://developer.android.com/reference/kotlin/androidx/appsearch/usagereporting/TakenAction` document as a duration in milliseconds. |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html` | `https://developer.android.com/reference/kotlin/androidx/appsearch/usagereporting/TakenAction#getId()()` Returns the unique identifier of the `https://developer.android.com/reference/kotlin/androidx/appsearch/usagereporting/TakenAction`. |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html` | `https://developer.android.com/reference/kotlin/androidx/appsearch/usagereporting/TakenAction#getNamespace()()` Returns the namespace of the `https://developer.android.com/reference/kotlin/androidx/appsearch/usagereporting/TakenAction`. |

## Public constructors

### TakenAction

Added in [1.2.0-alpha02](https://developer.android.com/jetpack/androidx/releases/appsearch#1.2.0-alpha02)

```
@ExperimentalAppSearchApi
TakenAction(builder: TakenAction.BuilderBase<*>)
```

Constructs a `https://developer.android.com/reference/kotlin/androidx/appsearch/usagereporting/TakenAction` from a `https://developer.android.com/reference/kotlin/androidx/appsearch/usagereporting/TakenAction.BuilderBase`.

| Parameters |
|---|---|
| `builder: https://developer.android.com/reference/kotlin/androidx/appsearch/usagereporting/TakenAction.BuilderBase<*>` | The builder to construct the `https://developer.android.com/reference/kotlin/androidx/appsearch/usagereporting/TakenAction` from. |

## Public functions

### getActionTimestampMillis

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

```
fun getActionTimestampMillis(): Long
```

Returns the timestamp when the user took the action, in milliseconds since Unix epoch.

The action timestamp will be used together with `https://developer.android.com/reference/kotlin/androidx/appsearch/usagereporting/TakenAction#getDocumentTtlMillis()` as the document retention.

### getActionType

Added in [1.2.0-alpha02](https://developer.android.com/jetpack/androidx/releases/appsearch#1.2.0-alpha02)

```
@ExperimentalAppSearchApi
fun getActionType(): Int
```

Returns the action type of the `https://developer.android.com/reference/kotlin/androidx/appsearch/usagereporting/TakenAction`.

Value is one of the following:

- `ActionConstants.ACTION_TYPE_UNKNOWN`
- `ActionConstants.ACTION_TYPE_SEARCH`
- `ActionConstants.ACTION_TYPE_CLICK`
- `ActionConstants.ACTION_TYPE_IMPRESSION`
- `ActionConstants.ACTION_TYPE_DISMISS`

<br />

| See also |
|---|---|
| `https://developer.android.com/reference/kotlin/androidx/appsearch/usagereporting/TakenAction.ActionType` |   |

### getDocumentTtlMillis

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

```
fun getDocumentTtlMillis(): Long
```

Returns the time-to-live (TTL) of the `https://developer.android.com/reference/kotlin/androidx/appsearch/usagereporting/TakenAction` document as a duration in milliseconds.

The document will be automatically deleted when the TTL expires (since `https://developer.android.com/reference/kotlin/androidx/appsearch/usagereporting/TakenAction#getActionTimestampMillis()`).

The default TTL for `https://developer.android.com/reference/kotlin/androidx/appsearch/usagereporting/TakenAction` document is 60 days.

See `https://developer.android.com/reference/kotlin/androidx/appsearch/annotation/Document.TtlMillis` for more information on TTL.

### getId

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

```
fun getId(): String
```

Returns the unique identifier of the `https://developer.android.com/reference/kotlin/androidx/appsearch/usagereporting/TakenAction`.

### getNamespace

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

```
fun getNamespace(): String
```

Returns the namespace of the `https://developer.android.com/reference/kotlin/androidx/appsearch/usagereporting/TakenAction`.