The second Android 11 Developer Preview is now available, test it out and share your feedback.

ActivityResultContracts.StartActivityForResult

public static final class ActivityResultContracts.StartActivityForResult
extends ActivityResultContract<IntentActivityResult>

java.lang.Object
   ↳ androidx.activity.result.contract.ActivityResultContract<android.content.Intentandroidx.activity.result.ActivityResult>
     ↳ androidx.activity.result.contract.ActivityResultContracts.StartActivityForResult


An ActivityResultContract that doesn't do any type conversion, taking raw Intent as an input and ActivityResult as an output. Can be used with ActivityResultCaller.prepareCall(ActivityResultContract, ActivityResultCallback) to avoid having to manage request codes when calling an activity API for which a type-safe contract is not available.

Summary

Public constructors

ActivityResultContracts.StartActivityForResult()

Public methods

Intent createIntent(Context context, Intent input)

Create an intent that can be used for Activity.startActivityForResult(Intent, int)

ActivityResult parseResult(int resultCode, Intent intent)

Convert result obtained from Activity.onActivityResult(int, int, Intent) to O

Inherited methods

Public constructors

ActivityResultContracts.StartActivityForResult

public ActivityResultContracts.StartActivityForResult ()

Public methods

createIntent

public Intent createIntent (Context context, 
                Intent input)

Create an intent that can be used for Activity.startActivityForResult(Intent, int)

Parameters
context Context

input Intent

Returns
Intent

parseResult

public ActivityResult parseResult (int resultCode, 
                Intent intent)

Convert result obtained from Activity.onActivityResult(int, int, Intent) to O

Parameters
resultCode int

intent Intent

Returns
ActivityResult