Location permission android 12

Author: jackyhieu1211-hnCreated Oct 3, 2021Updated Nov 4, 2022
Labelscontributionwelcomeinquiry

Location permission android 12

-- Hello admin. I checking android 12 and have a problem: In android 12. App must request both permission ACCESS_FINE_LOCATION and ACCESS_COARSE_LOCATION

My code:

@NeedsPermission(
    Manifest.permission.ACCESS_FINE_LOCATION,
    Manifest.permission.ACCESS_COARSE_LOCATION
)
fun getLocation() {
    // Code here
 }
 
 @OnPermissionDenied(Manifest.permission.ACCESS_FINE_LOCATION, Manifest.permission.ACCESS_COARSE_LOCATION)
fun getLocationDenied() {
    // Code here
}

When I choose option Approximate -> While using the app

Actual results: OnPermissionDenied called. Expected results : getLocation() will call

=> Reason: method verifyPermissions in class PermissionUtils checking.

  • Checks all given permissions have been granted.
  • Params:
  • grantResults – results
  • Returns:
  • returns true if all permissions have been granted.

Please help me.

Screen Shot 2021-10-03 at 15 53 48

Source: permissions-dispatcher/PermissionsDispatcher