예제 #1
0
        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);
        }
예제 #2
0
        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);
        }
예제 #3
0
 public static Native GetManager(this IAndroidContext context)
 => context.GetSystemService <Native>(Context.DownloadService);