ActivityResultLauncher

public 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 methods

abstract @NonNull ActivityResultContract<@NonNull I, @NonNull Object>

Get the ActivityResultContract that was used to create this launcher.

@NonNull void
launch(@NonNull I input)

Executes an ActivityResultContract.

abstract @NonNull void

Executes an ActivityResultContract.

abstract @MainThread @NonNull 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 methods

getContract

@NonNull
public abstract ActivityResultContract<@NonNull I, @NonNull ObjectgetContract()

Get the ActivityResultContract that was used to create this launcher.

Returns
ActivityResultContract<@NonNull I, @NonNull Object>

the contract that was used to create this launcher

launch

@NonNull
public void launch(@NonNull I input)

Executes an ActivityResultContract.

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

Parameters
@NonNull I input

the input required to execute an ActivityResultContract.

Throws
android.content.ActivityNotFoundException

launch

@NonNull
public abstract void launch(@NonNull 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
@NonNull 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
@NonNull
public abstract @MainThread 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

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

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

ActivityResultLauncherKt.launch

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

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