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

```
public final 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/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/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/androidx/credentials/GetCredentialResponse` using `https://developer.android.com/reference/androidx/credentials/provider/PendingIntentHandler#setGetCredentialResponse(android.content.Intent,androidx.credentials.GetCredentialResponse,androidx.credentials.provider.ProviderGetCredentialRequest)`, or by setting `https://developer.android.com/reference/androidx/credentials/exceptions/GetCredentialException` using `https://developer.android.com/reference/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/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/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/androidx/credentials/provider/Action#title()` or `https://developer.android.com/reference/androidx/credentials/provider/Action#pendingIntent()` is null |

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

## Summary

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

| ### Public constructors |
|---|
| `https://developer.android.com/reference/androidx/credentials/provider/Action#Action(kotlin.CharSequence,android.app.PendingIntent,kotlin.CharSequence)( @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/java/lang/CharSequence.html title, @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/android/app/PendingIntent.html pendingIntent, https://developer.android.com/reference/java/lang/CharSequence.html subtitle )` constructs an instance of `https://developer.android.com/reference/androidx/credentials/provider/Action` |

| ### Public methods |
|---|---|
| `boolean` | `https://developer.android.com/reference/androidx/credentials/provider/Action#equals(kotlin.Any)(https://developer.android.com/reference/java/lang/Object.html other)` |
| `static final https://developer.android.com/reference/androidx/credentials/provider/Action` | `https://developer.android.com/reference/androidx/credentials/provider/Action#fromAction(android.service.credentials.Action)(@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/android/service/credentials/Action.html action)` Converts a framework `https://developer.android.com/reference/android/service/credentials/Action.html` class to a Jetpack `https://developer.android.com/reference/androidx/credentials/provider/Action` class |
| `final @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/android/app/PendingIntent.html` | `https://developer.android.com/reference/androidx/credentials/provider/Action#getPendingIntent()()` 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 |
| `final https://developer.android.com/reference/java/lang/CharSequence.html` | `https://developer.android.com/reference/androidx/credentials/provider/Action#getSubtitle()()` the optional subtitle that is displayed on the entry |
| `final @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/java/lang/CharSequence.html` | `https://developer.android.com/reference/androidx/credentials/provider/Action#getTitle()()` the title of the entry |
| `int` | `https://developer.android.com/reference/androidx/credentials/provider/Action#hashCode()()` |

## Public constructors

### Action

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

```
public Action(
    @NonNull CharSequence title,
    @NonNull PendingIntent pendingIntent,
    CharSequence subtitle
)
```

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

| Parameters |
|---|---|
| `@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/java/lang/CharSequence.html title` | the title of the entry |
| `@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/android/app/PendingIntent.html 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://developer.android.com/reference/java/lang/CharSequence.html subtitle` | the optional subtitle that is displayed on the entry |

## Public methods

### equals

```
public boolean equals(Object other)
```

### fromAction

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

```
public static final Action fromAction(@NonNull Action action)
```

Converts a framework `https://developer.android.com/reference/android/service/credentials/Action.html` class to a Jetpack `https://developer.android.com/reference/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/androidx/credentials/provider/Action` to populate the `https://developer.android.com/reference/androidx/credentials/provider/BeginGetCredentialResponse`, along with setting other entries.

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

### getPendingIntent

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

```
public final @NonNull PendingIntent getPendingIntent()
```

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

### getSubtitle

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

```
public final CharSequence getSubtitle()
```

the optional subtitle that is displayed on the entry

### getTitle

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

```
public final @NonNull CharSequence getTitle()
```

the title of the entry

### hashCode

```
public int hashCode()
```