internal static AccessState GetLocationManagerStatus(this AndroidContext context, bool gpsRequired) { //var hasGps = locationManager.IsProviderEnabled(LocationManager.GpsProvider); var lm = context.GetSystemService <LocationManager>(Context.LocationService); if (Android.OS.Build.VERSION.SdkInt >= Android.OS.BuildVersionCodes.P) { if (!lm.IsLocationEnabled) { return(AccessState.Disabled); } } else { if (!lm.IsProviderEnabled(LocationManager.NetworkProvider) && !lm.IsProviderEnabled(LocationManager.GpsProvider)) { return(AccessState.Disabled); } } if (gpsRequired && !lm.IsProviderEnabled(LocationManager.GpsProvider)) { return(AccessState.Disabled); } return(AccessState.Available); }
protected internal void ShowKeyboard(AView inputView) { AObject temp = AndroidContext.GetSystemService(AContext.InputMethodService) ?? throw new NullReferenceException(nameof(Context.InputMethodService)); using InputMethodManager inputMethodManager = (InputMethodManager)temp; inputMethodManager.ShowSoftInput(inputView, ShowFlags.Forced); inputMethodManager.ToggleSoftInput(ShowFlags.Forced, HideSoftInputFlags.ImplicitOnly); }
protected internal void HideKeyboard(AView inputView) { AObject temp = AndroidContext.GetSystemService(AContext.InputMethodService) ?? throw new NullReferenceException(nameof(Context.InputMethodService)); using InputMethodManager inputMethodManager = (InputMethodManager)temp; IBinder?windowToken = inputView.WindowToken; if (windowToken != null) { inputMethodManager.HideSoftInputFromWindow(windowToken, HideSoftInputFlags.None); } }
internal static AccessState GetLocationManagerStatus(this AndroidContext context, bool gpsRequired) { //var hasGps = locationManager.IsProviderEnabled(LocationManager.GpsProvider); var lm = context.GetSystemService <LocationManager>(Context.LocationService); if (!lm.IsLocationEnabled) { return(AccessState.Disabled); } if (gpsRequired && !lm.IsProviderEnabled(LocationManager.GpsProvider)) { return(AccessState.Disabled); } return(AccessState.Available); }
internal static AccessState GetLocationManagerStatus(this AndroidContext 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); }
public static Native GetManager(this AndroidContext context) => context.GetSystemService <Native>(Context.DownloadService);