# Action

Artifact: [androidx.credentials:credentials](https://developer.android.com/jetpack/androidx/releases/credentials) [View Source](https://cs.android.com/search?q=file:androidx/credentials/provider/Action.kt+class:androidx.credentials.provider.Action) Added in [1.2.0](https://developer.android.com/jetpack/androidx/releases/credentials#1.2.0)

*** ** * ** ***

<br />

```
class Action
```

<br />

*** ** * ** ***

An actionable entry that is returned as part of the `https://developer.android.com/reference/android/service/credentials/BeginGetCredentialResponse.html`, and then shown on the user selector under a separate category of 'Actions'. An action entry is expected to navigate the user to an activity belonging to the credential provider, and finally result in a `https://developer.android.com/reference/kotlin/androidx/credentials/GetCredentialResponse`.

When selected, the associated `https://developer.android.com/reference/android/app/PendingIntent.html` is invoked to launch a provider controlled activity. The activity invoked due to this pending intent will contain the `https://developer.android.com/reference/android/service/credentials/BeginGetCredentialRequest.html` as part of the intent extras. Providers must use `https://developer.android.com/reference/kotlin/androidx/credentials/provider/PendingIntentHandler#retrieveBeginGetCredentialRequest(android.content.Intent)` to get the request.

When the user is done interacting with the activity and the provider has a credential to return, provider must call `https://developer.android.com/reference/android/app/Activity.html#setResult(int)` with the result code as `https://developer.android.com/reference/android/app/Activity.html#RESULT_OK`, and the `https://developer.android.com/reference/android/content/Intent.html` data that has been prepared by setting `https://developer.android.com/reference/kotlin/androidx/credentials/GetCredentialResponse` using `https://developer.android.com/reference/kotlin/androidx/credentials/provider/PendingIntentHandler#setGetCredentialResponse(android.content.Intent,androidx.credentials.GetCredentialResponse,androidx.credentials.provider.ProviderGetCredentialRequest)`, or by setting `https://developer.android.com/reference/kotlin/androidx/credentials/exceptions/GetCredentialException` using `https://developer.android.com/reference/kotlin/androidx/credentials/provider/PendingIntentHandler#setGetCredentialException(android.content.Intent,androidx.credentials.exceptions.GetCredentialException)` before ending the activity. If the provider does not have a credential, or an exception to return, provider must call `https://developer.android.com/reference/android/app/Activity.html#setResult(int)` with the result code as `https://developer.android.com/reference/android/app/Activity.html#RESULT_CANCELED`. Setting the result code to `https://developer.android.com/reference/android/app/Activity.html#RESULT_CANCELED` will re-surface the selector.

Examples of `https://developer.android.com/reference/kotlin/androidx/credentials/provider/Action` entries include an entry that is titled 'Add a new Password', and navigates to the 'add password' page of the credential provider app, or an entry that is titled 'Manage Credentials' and navigates to a particular page that lists all credentials, where the user may end up selecting a credential that the provider can then return.

| Throws |
|---|---|
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-illegal-argument-exception/index.html` | If `https://developer.android.com/reference/kotlin/androidx/credentials/provider/Action#title()` is empty |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-null-pointer-exception/index.html` | If `https://developer.android.com/reference/kotlin/androidx/credentials/provider/Action#title()` or `https://developer.android.com/reference/kotlin/androidx/credentials/provider/Action#pendingIntent()` is null |

| See also |
|---|---|
| `https://developer.android.com/reference/android/service/credentials/BeginGetCredentialResponse.html` | for usage. |

## Summary

| ### Nested types |
|---|
| `class https://developer.android.com/reference/kotlin/androidx/credentials/provider/Action.Builder` A builder for `https://developer.android.com/reference/kotlin/androidx/credentials/provider/Action` |

| ### Public companion functions |
|---|---|
| `https://developer.android.com/reference/kotlin/androidx/credentials/provider/Action?` | `https://developer.android.com/reference/kotlin/androidx/credentials/provider/Action#fromAction(android.service.credentials.Action)(action: https://developer.android.com/reference/android/service/credentials/Action.html)` Converts a framework `https://developer.android.com/reference/android/service/credentials/Action.html` class to a Jetpack `https://developer.android.com/reference/kotlin/androidx/credentials/provider/Action` class |

| ### Public constructors |
|---|
| `https://developer.android.com/reference/kotlin/androidx/credentials/provider/Action#Action(kotlin.CharSequence,android.app.PendingIntent,kotlin.CharSequence)( title: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-char-sequence/index.html, pendingIntent: https://developer.android.com/reference/android/app/PendingIntent.html, subtitle: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-char-sequence/index.html? )` constructs an instance of `https://developer.android.com/reference/kotlin/androidx/credentials/provider/Action` |

| ### Public functions |
|---|---|
| `open operator https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html` | `https://developer.android.com/reference/kotlin/androidx/credentials/provider/Action#equals(kotlin.Any)(other: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-any/index.html?)` |
| `open https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | `https://developer.android.com/reference/kotlin/androidx/credentials/provider/Action#hashCode()()` |

| ### Public properties |
|---|---|
| `https://developer.android.com/reference/android/app/PendingIntent.html` | `https://developer.android.com/reference/kotlin/androidx/credentials/provider/Action#pendingIntent()` the `https://developer.android.com/reference/android/app/PendingIntent.html` that will get invoked when the user selects this entry, must be created with a unique request code per entry, with flag `https://developer.android.com/reference/android/app/PendingIntent.html#FLAG_MUTABLE` to allow the Android system to attach the final request, and NOT with flag `https://developer.android.com/reference/android/app/PendingIntent.html#FLAG_ONE_SHOT` as it can be invoked multiple times |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-char-sequence/index.html?` | `https://developer.android.com/reference/kotlin/androidx/credentials/provider/Action#subtitle()` the optional subtitle that is displayed on the entry |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-char-sequence/index.html` | `https://developer.android.com/reference/kotlin/androidx/credentials/provider/Action#title()` the title of the entry |

## Public companion functions

### fromAction

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

```
fun fromAction(action: Action): Action?
```

Converts a framework `https://developer.android.com/reference/android/service/credentials/Action.html` class to a Jetpack `https://developer.android.com/reference/kotlin/androidx/credentials/provider/Action` class

Note that this API is not needed in a general credential retrieval flow that is implemented using this jetpack library, where you are only required to construct an instance of `https://developer.android.com/reference/kotlin/androidx/credentials/provider/Action` to populate the `https://developer.android.com/reference/kotlin/androidx/credentials/provider/BeginGetCredentialResponse`, along with setting other entries.

| Parameters |
|---|---|
| `action: https://developer.android.com/reference/android/service/credentials/Action.html` | the instance of framework action class to be converted |

## Public constructors

### Action

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

```
Action(
    title: CharSequence,
    pendingIntent: PendingIntent,
    subtitle: CharSequence? = null
)
```

constructs an instance of `https://developer.android.com/reference/kotlin/androidx/credentials/provider/Action`

| Parameters |
|---|---|
| `title: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-char-sequence/index.html` | the title of the entry |
| `pendingIntent: https://developer.android.com/reference/android/app/PendingIntent.html` | the `https://developer.android.com/reference/android/app/PendingIntent.html` that will get invoked when the user selects this entry, must be created with a unique request code per entry, with flag `https://developer.android.com/reference/android/app/PendingIntent.html#FLAG_MUTABLE` to allow the Android system to attach the final request, and NOT with flag `https://developer.android.com/reference/android/app/PendingIntent.html#FLAG_ONE_SHOT` as it can be invoked multiple times |
| `subtitle: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-char-sequence/index.html? = null` | the optional subtitle that is displayed on the entry |

## Public functions

### equals

```
open operator fun equals(other: Any?): Boolean
```

### hashCode

```
open fun hashCode(): Int
```

## Public properties

### pendingIntent

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

```
val pendingIntent: PendingIntent
```

the `https://developer.android.com/reference/android/app/PendingIntent.html` that will get invoked when the user selects this entry, must be created with a unique request code per entry, with flag `https://developer.android.com/reference/android/app/PendingIntent.html#FLAG_MUTABLE` to allow the Android system to attach the final request, and NOT with flag `https://developer.android.com/reference/android/app/PendingIntent.html#FLAG_ONE_SHOT` as it can be invoked multiple times

### subtitle

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

```
val subtitle: CharSequence?
```

the optional subtitle that is displayed on the entry

### title

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

```
val title: CharSequence
```

the title of the entry