public static AccessState GetLocationManagerStatus(this IAndroidContext context, bool gpsRequired, bool networkRequired) { var lm = context.GetSystemService <LocationManager>(Context.LocationService); if (context.IsMinApiLevel(28) && !lm.IsLocationEnabled) { return(AccessState.Disabled); } if (networkRequired && !lm.IsProviderEnabled(LocationManager.NetworkProvider)) { return(AccessState.Disabled); } if (gpsRequired && !lm.IsProviderEnabled(LocationManager.GpsProvider)) { return(AccessState.Disabled); } return(AccessState.Available); }
static bool IsLocationEnabled(IAndroidContext context, bool gpsRequired, bool networkRequired) { var lm = context.GetSystemService <LocationManager>(Context.LocationService); if (context.IsMinApiLevel(28) && !lm.IsLocationEnabled) { return(false); } if (networkRequired && !lm.IsProviderEnabled(LocationManager.NetworkProvider)) { return(false); } if (gpsRequired && !lm.IsProviderEnabled(LocationManager.GpsProvider)) { return(false); } return(true); }
public static Native GetManager(this IAndroidContext context) => context.GetSystemService <Native>(Context.DownloadService);