ActivityResultLauncher

abstract class ActivityResultLauncher<I>

Known direct subclasses
ManagedActivityResultLauncher

A launcher for a previously-prepared call to start the process of executing an ActivityResultContract.


A launcher for a previously-prepared call to start the process of executing an ActivityResultContract.

Parameters
<I>

type of the input required to launch

Summary

Public constructors

Public functions

abstract ActivityResultContract<I!, Any!>

Get the ActivityResultContract that was used to create this launcher.

Unit
launch(input: I!)

Executes an ActivityResultContract.

abstract Unit
launch(input: I!, options: ActivityOptionsCompat?)

Executes an ActivityResultContract.

abstract Unit

Unregisters this launcher, releasing the underlying result callback, and any references captured within it.

Extension functions

Unit

Convenience method to launch a no-argument registered call without needing to pass in null.

Unit

Convenience method to launch a no-argument registered call without needing to pass in Unit.

Public constructors

ActivityResultLauncher

Added in 1.2.0
ActivityResultLauncher()

Public functions

getContract

Added in 1.2.0
abstract fun getContract(): ActivityResultContract<I!, Any!>

Get the ActivityResultContract that was used to create this launcher.

Returns
ActivityResultContract<I!, Any!>

the contract that was used to create this launcher

launch

Added in 1.2.0
fun launch(input: I!): Unit

Executes an ActivityResultContract.

This method throws android.content.ActivityNotFoundException if there was no Activity found to run the given Intent.

Parameters
input: I!

the input required to execute an ActivityResultContract.

launch

Added in 1.2.0
abstract fun launch(input: I!, options: ActivityOptionsCompat?): Unit

Executes an ActivityResultContract.

This method throws android.content.ActivityNotFoundException if there was no Activity found to run the given Intent.

Parameters
input: I!

the input required to execute an ActivityResultContract.

options: ActivityOptionsCompat?

Additional options for how the Activity should be started.

unregister

Added in 1.2.0
@MainThread
abstract fun unregister(): Unit

Unregisters this launcher, releasing the underlying result callback, and any references captured within it. You should call this if the registry may live longer than the callback registered for this launcher.

Extension functions

launch

fun ActivityResultLauncher<Void?>.launch(
    options: ActivityOptionsCompat? = null
): Unit

Convenience method to launch a no-argument registered call without needing to pass in null.

launch

fun ActivityResultLauncher<Unit>.launch(
    options: ActivityOptionsCompat? = null
): Unit

Convenience method to launch a no-argument registered call without needing to pass in Unit.