# AuthenticationAction

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

*** ** * ** ***

<br />

```
public final class AuthenticationAction
```

<br />

*** ** * ** ***

An entry on the selector, denoting that the provider service is locked and authentication is needed to proceed.

Providers should set this entry when the provider app is locked, and no credentials can be returned. Providers must set the `https://developer.android.com/reference/android/app/PendingIntent.html` that leads to their unlock activity. When the user selects this entry, the corresponding `https://developer.android.com/reference/android/app/PendingIntent.html` is fired and the unlock activity is invoked.

When the user is done with the authentication flow and the provider has credential entries 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/provider/BeginGetCredentialResponse` using `https://developer.android.com/reference/androidx/credentials/provider/PendingIntentHandler#setBeginGetCredentialResponse(android.content.Intent,androidx.credentials.provider.BeginGetCredentialResponse)`, 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, with this authentication action labeled as having no valid credentials.

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

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

## Summary

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

| ### Public constructors |
|---|
| `https://developer.android.com/reference/androidx/credentials/provider/AuthenticationAction#AuthenticationAction(kotlin.CharSequence,android.app.PendingIntent)( @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 )` constructs an instance of `https://developer.android.com/reference/androidx/credentials/provider/AuthenticationAction` |

| ### Public methods |
|---|---|
| `boolean` | `https://developer.android.com/reference/androidx/credentials/provider/AuthenticationAction#equals(kotlin.Any)(https://developer.android.com/reference/java/lang/Object.html other)` |
| `static final https://developer.android.com/reference/androidx/credentials/provider/AuthenticationAction` | `@https://developer.android.com/reference/androidx/annotation/RequiresApi(value = 34) https://developer.android.com/reference/androidx/credentials/provider/AuthenticationAction#fromAction(android.service.credentials.Action)(@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/android/service/credentials/Action.html authenticationAction)` 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/AuthenticationAction` 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/AuthenticationAction#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/androidx/annotation/NonNull https://developer.android.com/reference/java/lang/CharSequence.html` | `https://developer.android.com/reference/androidx/credentials/provider/AuthenticationAction#getTitle()()` the title to be shown with this entry on the account selector UI |
| `int` | `https://developer.android.com/reference/androidx/credentials/provider/AuthenticationAction#hashCode()()` |

## Public constructors

### AuthenticationAction

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

```
public AuthenticationAction(
    @NonNull CharSequence title,
    @NonNull PendingIntent pendingIntent
)
```

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

| Parameters |
|---|---|
| `@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/java/lang/CharSequence.html title` | the title to be shown with this entry on the account selector UI |
| `@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 |

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

```
@RequiresApi(value = 34)
public static final AuthenticationAction fromAction(@NonNull Action authenticationAction)
```

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/AuthenticationAction` 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/AuthenticationAction` 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 authenticationAction` | 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

### getTitle

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

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

the title to be shown with this entry on the account selector UI

### hashCode

```
public int hashCode()
```