Google se compromete a impulsar la igualdad racial para las comunidades afrodescendientes. Obtén información al respecto.

ActivityResultRegistry

abstract class ActivityResultRegistry
kotlin.Any
   ↳ androidx.activity.result.ActivityResultRegistry

A registry that stores activity result callbacks for ActivityResultCaller#registerForActivityResult. You can create your own instance for testing by overriding onLaunch and calling #dispatchResult immediately within it, thus skipping the actual Activity#startActivityForResult call. When testing, make sure to explicitly provide a registry instance whenever calling ActivityResultCaller#registerForActivityResult, to be able to inject a test instance.

Summary

Public constructors

A registry that stores activity result callbacks for ActivityResultCaller#registerForActivityResult.

Public methods
Boolean
dispatchResult(requestCode: Int, resultCode: Int, @Nullable data: Intent?)

Dispatch a result received via Activity#onActivityResult to the callback on record, or store the result if callback was not yet registered.

Boolean
dispatchResult(requestCode: Int, result: O)

Dispatch a result object to the callback on record.

abstract Unit
onLaunch(requestCode: Int, @NonNull contract: ActivityResultContract<I, O>, input: I, @Nullable options: ActivityOptionsCompat?)

Start the process of executing an ActivityResultContract in a type-safe way, using the provided contract.

Unit
onRestoreInstanceState(@Nullable savedInstanceState: Bundle?)

Restore the state of this registry from the given Bundle

Unit
onSaveInstanceState(@NonNull outState: Bundle)

Save the state of this registry in the given Bundle

ActivityResultLauncher<I>
register(@NonNull key: String, @NonNull lifecycleOwner: LifecycleOwner, @NonNull contract: ActivityResultContract<I, O>, @NonNull callback: ActivityResultCallback<O>)

Register a new callback with this registry.

ActivityResultLauncher<I>
register(@NonNull key: String, @NonNull contract: ActivityResultContract<I, O>, @NonNull callback: ActivityResultCallback<O>)

Register a new callback with this registry.

Public constructors

<init>

ActivityResultRegistry()

A registry that stores activity result callbacks for ActivityResultCaller#registerForActivityResult. You can create your own instance for testing by overriding onLaunch and calling #dispatchResult immediately within it, thus skipping the actual Activity#startActivityForResult call. When testing, make sure to explicitly provide a registry instance whenever calling ActivityResultCaller#registerForActivityResult, to be able to inject a test instance.

Public methods

dispatchResult

@MainThread fun dispatchResult(
    requestCode: Int,
    resultCode: Int,
    @Nullable data: Intent?
): Boolean

Dispatch a result received via Activity#onActivityResult to the callback on record, or store the result if callback was not yet registered.

Parameters
requestCode Int: request code to identify the callback
resultCode Int: status to indicate the success of the operation
data Intent?: an intent that carries the result data
Return