Skip to content
This repository has been archived by the owner on Oct 3, 2024. It is now read-only.

onRequestPermissionsResult of fragment is marked deprecated #338

Open
AndyAWD opened this issue Dec 7, 2021 · 0 comments
Open

onRequestPermissionsResult of fragment is marked deprecated #338

AndyAWD opened this issue Dec 7, 2021 · 0 comments

Comments

@AndyAWD
Copy link

AndyAWD commented Dec 7, 2021

Basic Information

Device type: Pixel 3a XL
OS version: Android 12 targetSdk 31
EasyPermissions version: 3.0.0

Describe the problem

In android sdk 31, onRequestPermissionsResult of fragment is marked deprecated.

Code and logs

/**
 * Callback for the result from requesting permissions. This method
 * is invoked for every call on {@link #requestPermissions(String[], int)}.
 * <p>
 * <strong>Note:</strong> It is possible that the permissions request interaction
 * with the user is interrupted. In this case you will receive empty permissions
 * and results arrays which should be treated as a cancellation.
 * </p>
 *
 * @param requestCode The request code passed in {@link #requestPermissions(String[], int)}.
 * @param permissions The requested permissions. Never null.
 * @param grantResults The grant results for the corresponding permissions
 *     which is either {@link android.content.pm.PackageManager#PERMISSION_GRANTED}
 *     or {@link android.content.pm.PackageManager#PERMISSION_DENIED}. Never null.
 *
 * @see #requestPermissions(String[], int)
 *
 * @deprecated use
 * {@link #registerForActivityResult(ActivityResultContract, ActivityResultCallback)} passing
 * in a {@link RequestMultiplePermissions} object for the {@link ActivityResultContract} and
 * handling the result in the {@link ActivityResultCallback#onActivityResult(Object) callback}.
 */
@SuppressWarnings({"DeprecatedIsStillUsed", "unused"})
@Deprecated
public void onRequestPermissionsResult(int requestCode, @NonNull String[] permissions,
        @NonNull int[] grantResults) {
    /* callback - do nothing */
}
override fun onRequestPermissionsResult(
    requestCode: Int,
    permissions: Array<out String>,
    grantResults: IntArray
) {
    super.onRequestPermissionsResult(requestCode, permissions, grantResults)
    EasyPermissions.onRequestPermissionsResult(requestCode, permissions, grantResults, this)
}
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant