ActivityResultLauncher

public abstract class ActivityResultLauncher<I>


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 methods

abstract @NonNull ActivityResultContract<I, Object>

Get the ActivityResultContract that was used to create this launcher.

void
launch(I input)

Executes an ActivityResultContract.

abstract void
launch(I input, @Nullable ActivityOptionsCompat options)

Executes an ActivityResultContract.

abstract @MainThread void

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

Extension functions

final void

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

final void

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

Public constructors

ActivityResultLauncher

public final ActivityResultLauncher()

Public methods

getContract

public abstract @NonNull ActivityResultContract<I, ObjectgetContract()

Get the ActivityResultContract that was used to create this launcher.

Returns
@NonNull ActivityResultContract<I, Object>

the contract that was used to create this launcher

launch

public void launch(I input)

Executes an ActivityResultContract.

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

Parameters
I input

the input required to execute an ActivityResultContract.

Throws
android.content.ActivityNotFoundException

launch

public abstract void launch(I input, @Nullable ActivityOptionsCompat options)

Executes an ActivityResultContract.

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

Parameters
I input

the input required to execute an ActivityResultContract.

@Nullable ActivityOptionsCompat options

Additional options for how the Activity should be started.

Throws
android.content.ActivityNotFoundException

unregister

@MainThread
public abstract void unregister()

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

ActivityResultLauncherKt.launch

public final void ActivityResultLauncherKt.launch(
    ActivityResultLauncher<Void> receiver,
    ActivityOptionsCompat options
)

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

ActivityResultLauncherKt.launch

public final void ActivityResultLauncherKt.launch(
    ActivityResultLauncher<Unit> receiver,
    ActivityOptionsCompat options
)

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