ActivityResultCaller
public
interface
ActivityResultCaller
androidx.activity.result.ActivityResultCaller |
A class that can call Activity.startActivityForResult(Intent, int)
-style APIs without having to manage
request codes, and converting request/response to an Intent
Summary
Public methods | |
---|---|
abstract
<I, O>
ActivityResultLauncher<I>
|
registerForActivityResult(ActivityResultContract<I, O> contract, ActivityResultCallback<O> callback)
Register a request to |
abstract
<I, O>
ActivityResultLauncher<I>
|
registerForActivityResult(ActivityResultContract<I, O> contract, ActivityResultRegistry registry, ActivityResultCallback<O> callback)
Register a request to |
Public methods
registerForActivityResult
public abstract ActivityResultLauncher<I> registerForActivityResult (ActivityResultContract<I, O> contract, ActivityResultCallback<O> callback)
Register a request to start an activity for result
,
designated by the given contract
.
This creates a record in the registry
associated wit this
caller, managing request code, as well as conversions to/from Intent
under the hood.
This *must* be called unconditionally, as part of initialization path, typically as a field
initializer of an Activity or Fragment.
Parameters | |
---|---|
contract |
ActivityResultContract : the contract, specifying conversions to/from Intent s |
callback |
ActivityResultCallback : the callback to be called on the main thread when activity result
is available |
Returns | |
---|---|
ActivityResultLauncher<I> |
the launcher that can be used to start the activity or dispose of the prepared call. |
registerForActivityResult
public abstract ActivityResultLauncher<I> registerForActivityResult (ActivityResultContract<I, O> contract, ActivityResultRegistry registry, ActivityResultCallback<O> callback)
Register a request to start an activity for result
,
designated by the given contract
.
This creates a record in the given registry
, managing request
code, as well as conversions to/from Intent
under the hood.
This *must* be called unconditionally, as part of initialization path, typically as a field
initializer of an Activity or Fragment.
Parameters | |
---|---|
contract |
ActivityResultContract : the contract, specifying conversions to/from Intent s |
registry |
ActivityResultRegistry : the registry where to hold the record. |
callback |
ActivityResultCallback : the callback to be called on the main thread when activity result
is available |
Returns | |
---|---|
ActivityResultLauncher<I> |
the launcher that can be used to start the activity or dispose of the prepared call. |