ActivityResultRegistry

Registry for handling Android activity results in a suspendable manner.

Makes startActivityForResult into a linear suspend function instead of scattered callback-based code.

Usage:

val outcome = registry.awaitResult(
feature = ActivityResultFeature.GOOGLE_DRIVE_CONSENT,
intent = consentIntent,
)

Constructors

Link copied to clipboard
constructor(context: PlatformContext)

Types

Link copied to clipboard

Policy for handling concurrent requests for the same feature.

Functions

Link copied to clipboard
suspend fun awaitResult(feature: ActivityResultFeature, intent: Intent, conflictPolicy: ActivityResultRegistry.ConflictPolicy = ConflictPolicy.WAIT): ActivityResultOutcome

Start an activity for result and suspend until result arrives.

Link copied to clipboard
fun clear()

Clear all pending continuations. Called when Activity is destroyed.

Link copied to clipboard
fun dispatch(requestCode: Int, resultCode: Int, data: Intent?): Boolean

Dispatch an activity result to the appropriate pending continuation.