ActivityCompat.PermissionCompatDelegate

Added in 1.1.0

public interface ActivityCompat.PermissionCompatDelegate


Customizable delegate that allows delegating permission compatibility methods to a custom implementation.

To delegate permission compatibility methods to a custom class, implement this interface, and call ActivityCompat.setPermissionCompatDelegate(delegate);. All future calls to the permission compatibility methods in this class will first check whether the delegate can handle the method call, and invoke the corresponding method if it can.

Summary

Public methods

abstract boolean
onActivityResult(
    @NonNull Activity activity,
    @IntRange(from = 0) int requestCode,
    int resultCode,
    @Nullable Intent data
)

Determines whether the delegate should handle the permission request as part of FragmentActivity#onActivityResult(int, int, Intent).

abstract boolean
requestPermissions(
    @NonNull Activity activity,
    @NonNull String[] permissions,
    @IntRange(from = 0) int requestCode
)

Determines whether the delegate should handle requestPermissions, and request permissions if applicable.

Public methods

onActivityResult

Added in 1.1.0
abstract boolean onActivityResult(
    @NonNull Activity activity,
    @IntRange(from = 0) int requestCode,
    int resultCode,
    @Nullable Intent data
)

Determines whether the delegate should handle the permission request as part of FragmentActivity#onActivityResult(int, int, Intent). If this method returns true, it means that activity result is successfully handled by the delegate, and no further action is needed on this activity result.

Parameters
@NonNull Activity activity

The target Activity.

@IntRange(from = 0) int requestCode

The integer request code originally supplied to startActivityForResult(), allowing you to identify who this result came from.

int resultCode

The integer result code returned by the child activity through its setResult()}.

@Nullable Intent data

An Intent, which can return result data to the caller (various data can be attached to Intent "extras").

Returns
boolean

Whether the delegate has handled the activity result.

requestPermissions

Added in 1.1.0
abstract boolean requestPermissions(
    @NonNull Activity activity,
    @NonNull String[] permissions,
    @IntRange(from = 0) int requestCode
)

Determines whether the delegate should handle requestPermissions, and request permissions if applicable. If this method returns true, it means that permission request is successfully handled by the delegate, and platform should not perform any further requests for permission.

Parameters
@NonNull Activity activity

The target activity.

@NonNull String[] permissions

The requested permissions. Must be non-null and not empty.

@IntRange(from = 0) int requestCode

Application specific request code to match with a result reported to onRequestPermissionsResult. Should be >= 0.

Returns
boolean

Whether the delegate has handled the permission request.