ActivityResultContract

abstract class ActivityResultContract<I : Any!, O : Any!>
kotlin.Any
   ↳ androidx.activity.result.contract.ActivityResultContract

A contract specifying that an activity can be called with an input of type I and produce an output of type O Makes calling an activity for result type-safe.

Summary

Nested classes

The wrapper for a result provided in getSynchronousResult

Public constructors

A contract specifying that an activity can be called with an input of type I and produce an output of type O Makes calling an activity for result type-safe.

Public methods

abstract Intent
createIntent(@NonNull context: Context, input: I)

Create an intent that can be used for Activity#startActivityForResult

open ActivityResultContract.SynchronousResult<O>?
getSynchronousResult(@NonNull context: Context, input: I)

An optional method you can implement that can be used to potentially provide a result in lieu of starting an activity.

abstract O
parseResult(resultCode: Int, @Nullable intent: Intent?)

Convert result obtained from Activity#onActivityResult to O

Public constructors

<init>

ActivityResultContract()

A contract specifying that an activity can be called with an input of type I and produce an output of type O Makes calling an activity for result type-safe.

Public methods

createIntent

@NonNull abstract fun createIntent(
    @NonNull context: Context,
    input: I
): Intent

Create an intent that can be used for Activity#startActivityForResult

getSynchronousResult

@Nullable open fun getSynchronousResult(
    @NonNull context: Context,
    input: I
): ActivityResultContract.SynchronousResult<O>?

An optional method you can implement that can be used to potentially provide a result in lieu of starting an activity.

Return
ActivityResultContract.SynchronousResult<O>? the result wrapped in a SynchronousResult or null if the call should proceed to start an activity.

parseResult

abstract fun parseResult(
    resultCode: Int,
    @Nullable intent: Intent?
): O

Convert result obtained from Activity#onActivityResult to O