IntentHandler
public final class IntentHandler
IntentHandler to be used by credential providers to extract requests from a given intent, or to set back a response or an exception to a given intent while dealing with activities invoked by intents from the import flow.
The Provider Selector UI Activity will display a list of ExportEntry and create a launch intent that corresponds to the provider's activity. More info on how the intent is constructed for the provider activity can be found in the documentation of ProviderEventsManager.registerExport.
When user selects one of the ExportEntry, the credential provider's corresponding activity is invoked. The intent associated with this activity must be extracted and passed into the utils in this class to extract the required requests.
When user interaction is complete, credential providers must set the activity result by calling android.app.Activity.setResult by setting an appropriate result code and data of type Intent. This data should also be prepared by using the utils in this class to populate the required response/exception.
Summary
Public constructors |
|---|
Public methods |
|
|---|---|
static final ProviderImportCredentialsRequest |
Extracts the |
static final void |
setImportCredentialsException(Sets the |
static final void |
setImportCredentialsResponse(Writes the successful |
Public constructors
Public methods
retrieveProviderImportCredentialsRequest
public static final ProviderImportCredentialsRequest retrieveProviderImportCredentialsRequest(@NonNull Intent intent)
Extracts the ProviderImportCredentialsRequest from the Intent that started the provider's exporting Activity.
This should be called in your activity's onCreate method to retrieve the details of the import request, including the calling app's information and the Uri for writing the response back.
| Returns | |
|---|---|
ProviderImportCredentialsRequest |
the parsed |
setImportCredentialsException
public static final void setImportCredentialsException(
@NonNull Intent intent,
@NonNull ImportCredentialsException exception
)
Sets the androidx.credentials.providerevents.exception.ImportCredentialsException if an error is encountered when the provider application is invoked to fulfill the credential import request.
Note: After populating the intent with an exception, the provider must still use [Activity.RESULT_OK] when calling [Activity.setResult]. The system will inspect the `Intent` data to determine if an error occurred and return the exception back to the caller. If both a valid response and an exception are found, then the exception will be returned to the caller.
| Parameters | |
|---|---|
@NonNull Intent intent |
the result |
@NonNull ImportCredentialsException exception |
the exception to be returned to the importer. |
setImportCredentialsResponse
public static final void setImportCredentialsResponse(
@NonNull Context context,
@NonNull Uri uri,
@NonNull Intent intent,
@NonNull ImportCredentialsResponse response
)
Writes the successful ImportCredentialsResponse to the content Uri provided by the importing framework. The 'responseJson' of the successful ImportCredentialsResponse will be written to the content 'Uri' to bypass the binder transaction limit. For any additional parameters of the ImportCredentialsResponse will be written to the intent that is passed in. This intent and Activity.RESULT_OK should be set as the result of the activity that was invoked for credential transfer.