internal static AccessState GetCurrentLocationAccess(this AndroidContext context, bool background, bool fineAccess) { var status = context.GetLocationManagerStatus(false); if (status != AccessState.Available) { return(status); } if (context.IsMinApiLevel(29) && background) { status = context.GetCurrentAccessState(ACCESS_BACKGROUND_LOCATION); if (status != AccessState.Available) { return(status); } } var next = fineAccess ? P.AccessFineLocation : P.AccessCoarseLocation; status = context.GetCurrentAccessState(next); return(status); }
internal static async Task <AccessState> RequestLocationAccess(this AndroidContext context, bool background, bool fineAccess) { var status = context.GetLocationManagerStatus(false); if (status != AccessState.Available) { return(status); } var locationPerm = fineAccess ? P.AccessFineLocation : P.AccessCoarseLocation; if (context.IsMinApiLevel(29) && background) { return(await context .RequestAccess ( ACCESS_BACKGROUND_LOCATION, locationPerm ) .ToTask()); } return(await context.RequestAccess(locationPerm).ToTask()); }