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

ActivityResultContracts.RequestPermission

public static final class ActivityResultContracts.RequestPermission
extends ActivityResultContract<String, Boolean>

java.lang.Object
   ↳ androidx.activity.result.contract.ActivityResultContract<java.lang.String, java.lang.Boolean>
     ↳ androidx.activity.result.contract.ActivityResultContracts.RequestPermission


An ActivityResultContract to request a permission

Summary

Public constructors

ActivityResultContracts.RequestPermission()

Public methods

Intent createIntent(Context context, String input)

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

SynchronousResult<Boolean> getSynchronousResult(Context context, String input)

An optional method you can implement that can be used to potentially provide a result in lieu of starting an activity.

Boolean parseResult(int resultCode, Intent intent)

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

Inherited methods

Public constructors

ActivityResultContracts.RequestPermission

public ActivityResultContracts.RequestPermission ()

Public methods

createIntent

public Intent createIntent (Context context, 
                String input)

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

Parameters
context Context

input String

Returns
Intent

getSynchronousResult

public SynchronousResult<Boolean> getSynchronousResult (Context context, 
                String input)

An optional method you can implement that can be used to potentially provide a result in lieu of starting an activity.

Parameters
context Context

input String

Returns
SynchronousResult<Boolean> the result wrapped in a ActivityResultContract.SynchronousResult or null if the call should proceed to start an activity.

parseResult

public Boolean parseResult (int resultCode, 
                Intent intent)

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

Parameters
resultCode int

intent Intent

Returns
Boolean