Google 致力于为黑人社区推动种族平等。查看具体举措

ActivityResultLauncher

public abstract class ActivityResultLauncher
extends Object

java.lang.Object
   ↳ androidx.activity.result.ActivityResultLauncher<I>


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

Summary

Public constructors

ActivityResultLauncher()

Public methods

abstract ActivityResultContract<I, ?> getContract()

Get the ActivityResultContract that was used to create this launcher.

void launch(I input)

Executes an ActivityResultContract.

abstract void launch(I input, ActivityOptionsCompat options)

Executes an ActivityResultContract.

abstract void unregister()

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

Inherited methods

Public constructors

ActivityResultLauncher

public ActivityResultLauncher ()

Public methods

getContract

public abstract ActivityResultContract<I, ?> getContract ()

Get the ActivityResultContract that was used to create this launcher.

Returns
ActivityResultContract<I, ?> the contract that was used to create this launcher

launch

public void launch (I input)

Executes an ActivityResultContract.

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

Parameters
input I: the input required to execute an ActivityResultContract.

Throws
ActivityNotFoundException

launch

public abstract void launch (I input, 
                ActivityOptionsCompat options)

Executes an ActivityResultContract.

This method throws 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.

Throws
ActivityNotFoundException

unregister

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.