# ProviderEventsManager

Artifact: [androidx.credentials.providerevents:providerevents](https://developer.android.com/jetpack/androidx/releases/credentials-providerevents) [View Source](https://cs.android.com/search?q=file:androidx/credentials/providerevents/ProviderEventsManager.kt+class:androidx.credentials.providerevents.ProviderEventsManager) Added in [1.0.0-beta01](https://developer.android.com/jetpack/androidx/releases/credentials-providerevents#1.0.0-beta01)

*** ** * ** ***


```
public interface ProviderEventsManager
```

<br />

*** ** * ** ***

Provides APIs for credential providers to participate in provider events, such as same-device credential transfer.

This manager supports two primary roles for credential transfer:

- **Importing (Client Role):** A provider can initiate a flow to import credentials by calling `https://developer.android.com/reference/androidx/credentials/providerevents/ProviderEventsManager#importCredentials(android.content.Context,androidx.credentials.providerevents.transfer.ImportCredentialsRequest)`. This will display a UI allowing the user to select another provider to import from.

- **Exporting (Source Role):** A provider must first register its ability to export credentials by calling `https://developer.android.com/reference/androidx/credentials/providerevents/ProviderEventsManager#registerExport(androidx.credentials.providerevents.transfer.RegisterExportRequest)`. Once registered, it will appear in the UI when other providers initiate an import flow.

## Summary

| ### Public methods |
|---|---|
| `default @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/credentials/providerevents/transfer/ClearExportResponse` | `https://developer.android.com/reference/androidx/credentials/providerevents/ProviderEventsManager#clearExport(androidx.credentials.providerevents.transfer.ClearExportRequest)(@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/credentials/providerevents/transfer/ClearExportRequest request)` Clears all previously registered `https://developer.android.com/reference/androidx/credentials/providerevents/transfer/ExportEntry` registered through the `https://developer.android.com/reference/androidx/credentials/providerevents/ProviderEventsManager#registerExport(androidx.credentials.providerevents.transfer.RegisterExportRequest)` API. |
| `abstract void` | `https://developer.android.com/reference/androidx/credentials/providerevents/ProviderEventsManager#clearExportAsync(androidx.credentials.providerevents.transfer.ClearExportRequest,java.util.concurrent.Executor,androidx.credentials.CredentialManagerCallback)( @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/credentials/providerevents/transfer/ClearExportRequest request, @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/java/util/concurrent/Executor.html executor, @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/credentials/CredentialManagerCallback<@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/credentials/providerevents/transfer/ClearExportResponse, @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/credentials/providerevents/exception/ClearExportException> callback )` Clears all previously registered `https://developer.android.com/reference/androidx/credentials/providerevents/transfer/ExportEntry`. |
| `default static final @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/credentials/providerevents/ProviderEventsManager` | `https://developer.android.com/reference/androidx/credentials/providerevents/ProviderEventsManager#create(android.content.Context)(@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/android/content/Context.html context)` Creates a `https://developer.android.com/reference/androidx/credentials/providerevents/ProviderEventsManager` based on the given `https://developer.android.com/reference/androidx/credentials/providerevents/ProviderEventsManager.Companion#create(android.content.Context)`. |
| `default @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/credentials/providerevents/transfer/ProviderImportCredentialsResponse` | `https://developer.android.com/reference/androidx/credentials/providerevents/ProviderEventsManager#importCredentials(android.content.Context,androidx.credentials.providerevents.transfer.ImportCredentialsRequest)( @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/android/content/Context.html context, @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/credentials/providerevents/transfer/ImportCredentialsRequest request )` Initiates a flow to import credentials from another credential provider. |
| `abstract void` | `https://developer.android.com/reference/androidx/credentials/providerevents/ProviderEventsManager#importCredentialsAsync(android.content.Context,androidx.credentials.providerevents.transfer.ImportCredentialsRequest,android.os.CancellationSignal,java.util.concurrent.Executor,androidx.credentials.CredentialManagerCallback)( @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/android/content/Context.html context, @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/credentials/providerevents/transfer/ImportCredentialsRequest request, https://developer.android.com/reference/android/os/CancellationSignal.html cancellationSignal, @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/java/util/concurrent/Executor.html executor, @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/credentials/CredentialManagerCallback<@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/credentials/providerevents/transfer/ProviderImportCredentialsResponse, @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/credentials/providerevents/exception/ImportCredentialsException> callback )` Initiates a flow to import credentials from another credential provider. |
| `default @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/credentials/providerevents/transfer/RegisterExportResponse` | `https://developer.android.com/reference/androidx/credentials/providerevents/ProviderEventsManager#registerExport(androidx.credentials.providerevents.transfer.RegisterExportRequest)(@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/credentials/providerevents/transfer/RegisterExportRequest request)` Registers the calling credential provider as a source for exporting credentials. |
| `abstract void` | `https://developer.android.com/reference/androidx/credentials/providerevents/ProviderEventsManager#registerExportAsync(androidx.credentials.providerevents.transfer.RegisterExportRequest,java.util.concurrent.Executor,androidx.credentials.CredentialManagerCallback)( @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/credentials/providerevents/transfer/RegisterExportRequest request, @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/java/util/concurrent/Executor.html executor, @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/credentials/CredentialManagerCallback<@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/credentials/providerevents/transfer/RegisterExportResponse, @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/credentials/providerevents/exception/RegisterExportException> callback )` Registers the calling credential provider as a source for exporting credentials. |

## Public methods

### clearExport

```
default @NonNull ClearExportResponse clearExport(@NonNull ClearExportRequest request)
```

Clears all previously registered `https://developer.android.com/reference/androidx/credentials/providerevents/transfer/ExportEntry` registered through the `https://developer.android.com/reference/androidx/credentials/providerevents/ProviderEventsManager#registerExport(androidx.credentials.providerevents.transfer.RegisterExportRequest)` API. This API should be used to clear all `https://developer.android.com/reference/androidx/credentials/providerevents/transfer/ExportEntry` from the device. If trying to override the existing `https://developer.android.com/reference/androidx/credentials/providerevents/transfer/ExportEntry` with new ones, there is no need to clear the old ones. `https://developer.android.com/reference/androidx/credentials/providerevents/ProviderEventsManager#registerExport(androidx.credentials.providerevents.transfer.RegisterExportRequest)` can be used to directly override `https://developer.android.com/reference/androidx/credentials/providerevents/transfer/ExportEntry`.

| Parameters |
|---|---|
| `@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/credentials/providerevents/transfer/ClearExportRequest request` | the request to clear all the `https://developer.android.com/reference/androidx/credentials/providerevents/transfer/ExportEntry` |

| Returns |
|---|---|
| `@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/credentials/providerevents/transfer/ClearExportResponse` | a `https://developer.android.com/reference/androidx/credentials/providerevents/transfer/ClearExportResponse` on successful clear. |

| Throws |
|---|---|
| `https://developer.android.com/reference/androidx/credentials/providerevents/exception/ClearExportException` | if the registration fails. |

### clearExportAsync

Added in [1.0.0-beta01](https://developer.android.com/jetpack/androidx/releases/credentials-providerevents#1.0.0-beta01)

```
abstract void clearExportAsync(
    @NonNull ClearExportRequest request,
    @NonNull Executor executor,
    @NonNull CredentialManagerCallback<@NonNull ClearExportResponse, @NonNull ClearExportException> callback
)
```

Clears all previously registered `https://developer.android.com/reference/androidx/credentials/providerevents/transfer/ExportEntry`. All `https://developer.android.com/reference/androidx/credentials/providerevents/transfer/ExportEntry` will be cleared from the device. In order to override the previously registered `https://developer.android.com/reference/androidx/credentials/providerevents/transfer/ExportEntry` with different ones, `https://developer.android.com/reference/androidx/credentials/providerevents/ProviderEventsManager#registerExport(androidx.credentials.providerevents.transfer.RegisterExportRequest)` can be used to override the entries.

| Parameters |
|---|---|
| `@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/credentials/providerevents/transfer/ClearExportRequest request` | the request to clear all the `https://developer.android.com/reference/androidx/credentials/providerevents/transfer/ExportEntry` |
| `@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/java/util/concurrent/Executor.html executor` | the callback will take place on this executor |
| `@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/credentials/CredentialManagerCallback<@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/credentials/providerevents/transfer/ClearExportResponse, @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/credentials/providerevents/exception/ClearExportException> callback` | the callback invoked when the request succeeds or fails |

### create

Added in [1.0.0-beta01](https://developer.android.com/jetpack/androidx/releases/credentials-providerevents#1.0.0-beta01)

```
default static final @NonNull ProviderEventsManager create(@NonNull Context context)
```

Creates a `https://developer.android.com/reference/androidx/credentials/providerevents/ProviderEventsManager` based on the given `https://developer.android.com/reference/androidx/credentials/providerevents/ProviderEventsManager.Companion#create(android.content.Context)`.

| Parameters |
|---|---|
| `@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/android/content/Context.html context` | the context with which the ProviderEventsManager should be associated |

### importCredentials

```
default @NonNull ProviderImportCredentialsResponse importCredentials(
    @NonNull Context context,
    @NonNull ImportCredentialsRequest request
)
```

Initiates a flow to import credentials from another credential provider.

This method launches a provider selector UI, allowing the user to choose a source provider from a list of those registered via `https://developer.android.com/reference/androidx/credentials/providerevents/ProviderEventsManager#registerExport(androidx.credentials.providerevents.transfer.RegisterExportRequest)`. The request is then forwarded to the selected provider.

Under the hood, this API facilitates the transfer by creating a temporary file in the
caller's cache directory. The framework handles the file I/O, permissions, and cleanup,
providing a seamless transfer medium between the two providers.

| Parameters |
|---|---|
| `@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/android/content/Context.html context` | the activity context required to launch the UI. |
| `@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/credentials/providerevents/transfer/ImportCredentialsRequest request` | the request detailing the credentials to be imported. |

| Returns |
|---|---|
| `@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/credentials/providerevents/transfer/ProviderImportCredentialsResponse` | a `https://developer.android.com/reference/androidx/credentials/providerevents/transfer/ProviderImportCredentialsResponse` with the imported credential data. |

| Throws |
|---|---|
| `https://developer.android.com/reference/androidx/credentials/providerevents/exception/ImportCredentialsException` | on failure, with a subclass indicating the error type. |

### importCredentialsAsync

Added in [1.0.0-beta01](https://developer.android.com/jetpack/androidx/releases/credentials-providerevents#1.0.0-beta01)

```
abstract void importCredentialsAsync(
    @NonNull Context context,
    @NonNull ImportCredentialsRequest request,
    CancellationSignal cancellationSignal,
    @NonNull Executor executor,
    @NonNull CredentialManagerCallback<@NonNull ProviderImportCredentialsResponse, @NonNull ImportCredentialsException> callback
)
```

Initiates a flow to import credentials from another credential provider.

This method launches a provider selector UI, allowing the user to choose a source provider from a list of those registered via `https://developer.android.com/reference/androidx/credentials/providerevents/ProviderEventsManager#registerExport(androidx.credentials.providerevents.transfer.RegisterExportRequest)`. The request is then forwarded to the selected provider.

Under the hood, this API facilitates the transfer by creating a temporary file in the
caller's cache directory. The framework handles the file I/O, permissions, and cleanup,
providing a seamless transfer medium between the two providers.

| Parameters |
|---|---|
| `@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/android/content/Context.html context` | the activity context required to launch the UI. |
| `@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/credentials/providerevents/transfer/ImportCredentialsRequest request` | request the request detailing the credentials to be imported. |
| `https://developer.android.com/reference/android/os/CancellationSignal.html cancellationSignal` | an optional signal that allows for cancelling this call |
| `@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/java/util/concurrent/Executor.html executor` | the callback will take place on this executor |
| `@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/credentials/CredentialManagerCallback<@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/credentials/providerevents/transfer/ProviderImportCredentialsResponse, @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/credentials/providerevents/exception/ImportCredentialsException> callback` | the callback invoked when the request succeeds or fails |

### registerExport

```
default @NonNull RegisterExportResponse registerExport(@NonNull RegisterExportRequest request)
```

Registers the calling credential provider as a source for exporting credentials.

Once registered, the provider's `https://developer.android.com/reference/androidx/credentials/providerevents/transfer/ExportEntry` will be displayed in the provider selector UI when another provider initiates an `https://developer.android.com/reference/androidx/credentials/providerevents/ProviderEventsManager#importCredentials(android.content.Context,androidx.credentials.providerevents.transfer.ImportCredentialsRequest)` flow.

In addition to calling this method, a provider that wishes to export credentials must
declare an \[Activity\] in its manifest that can handle the transfer request. This activity
must have an intent filter configured with the following:

- An intent action of "androidx.identitycredentials.action.IMPORT_CREDENTIALS"
- A data element with a "content" scheme

The framework will invoke this activity with an intent containing a content URI, which serves as the medium for transferring the credential data. The activity can retrieve the request from the intent by calling `https://developer.android.com/reference/androidx/credentials/providerevents/IntentHandler#retrieveProviderImportCredentialsRequest(android.content.Intent)`. In addition to the `https://developer.android.com/reference/androidx/credentials/providerevents/transfer/ImportCredentialsRequest`, the `https://developer.android.com/reference/androidx/credentials/providerevents/transfer/ProviderImportCredentialsRequest` contains a few security measures. The importer's `https://developer.android.com/reference/androidx/credentials/provider/CallingAppInfo` is provided to verify the importer. The 'credId' is provided to validate the selected `https://developer.android.com/reference/androidx/credentials/providerevents/transfer/ExportEntry`.

After the activity processes the request, the activity should return the `https://developer.android.com/reference/androidx/credentials/providerevents/transfer/ImportCredentialsResponse` through the 'uri' of `https://developer.android.com/reference/androidx/credentials/providerevents/transfer/ProviderImportCredentialsRequest` to successfully return the credentials or set an exception by calling `https://developer.android.com/reference/androidx/credentials/providerevents/IntentHandler#setImportCredentialsException(android.content.Intent,androidx.credentials.providerevents.exception.ImportCredentialsException)`.

| Parameters |
|---|---|
| `@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/credentials/providerevents/transfer/RegisterExportRequest request` | the request containing the provider data to register |

| Returns |
|---|---|
| `@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/credentials/providerevents/transfer/RegisterExportResponse` | a `https://developer.android.com/reference/androidx/credentials/providerevents/transfer/RegisterExportResponse` on successful registration. |

| Throws |
|---|---|
| `https://developer.android.com/reference/androidx/credentials/providerevents/exception/RegisterExportException` | if the registration fails. |

### registerExportAsync

Added in [1.0.0-beta01](https://developer.android.com/jetpack/androidx/releases/credentials-providerevents#1.0.0-beta01)

```
abstract void registerExportAsync(
    @NonNull RegisterExportRequest request,
    @NonNull Executor executor,
    @NonNull CredentialManagerCallback<@NonNull RegisterExportResponse, @NonNull RegisterExportException> callback
)
```

Registers the calling credential provider as a source for exporting credentials.

Once registered, the provider's `https://developer.android.com/reference/androidx/credentials/providerevents/transfer/ExportEntry` will be displayed in the provider selector UI when another provider initiates an `https://developer.android.com/reference/androidx/credentials/providerevents/ProviderEventsManager#importCredentials(android.content.Context,androidx.credentials.providerevents.transfer.ImportCredentialsRequest)` flow.

In addition to calling this method, a provider that wishes to export credentials must
declare an \[Activity\] in its manifest that can handle the transfer request. This activity
must have an intent filter configured with the following:

- An intent action of "androidx.identitycredentials.action.IMPORT_CREDENTIALS"
- A data element with a "content" scheme

The framework will invoke this activity with an intent containing a content URI, which serves as the medium for transferring the credential data. The activity can retrieve the request from the intent by calling `https://developer.android.com/reference/androidx/credentials/providerevents/IntentHandler#retrieveProviderImportCredentialsRequest(android.content.Intent)`. In addition to the `https://developer.android.com/reference/androidx/credentials/providerevents/transfer/ImportCredentialsRequest`, the `https://developer.android.com/reference/androidx/credentials/providerevents/transfer/ProviderImportCredentialsRequest` contains a few security measures. The importer's `https://developer.android.com/reference/androidx/credentials/provider/CallingAppInfo` is provided to verify the importer. The 'credId' is provided to validate the selected `https://developer.android.com/reference/androidx/credentials/providerevents/transfer/ExportEntry`.

After the activity processes the request, the activity should return the `https://developer.android.com/reference/androidx/credentials/providerevents/transfer/ImportCredentialsResponse` through the 'uri' of `https://developer.android.com/reference/androidx/credentials/providerevents/transfer/ProviderImportCredentialsRequest` to successfully return the credentials or set an exception by calling `https://developer.android.com/reference/androidx/credentials/providerevents/IntentHandler#setImportCredentialsException(android.content.Intent,androidx.credentials.providerevents.exception.ImportCredentialsException)`.

| Parameters |
|---|---|
| `@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/credentials/providerevents/transfer/RegisterExportRequest request` | the request containing the provider data to register |
| `@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/java/util/concurrent/Executor.html executor` | the callback will take place on this executor |
| `@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/credentials/CredentialManagerCallback<@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/credentials/providerevents/transfer/RegisterExportResponse, @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/credentials/providerevents/exception/RegisterExportException> callback` | the callback invoked when the request succeeds or fails |