当前位置: 首页>>代码示例>>C#>>正文


C# LocationManager.GetProviders方法代码示例

本文整理汇总了C#中Android.Locations.LocationManager.GetProviders方法的典型用法代码示例。如果您正苦于以下问题:C# LocationManager.GetProviders方法的具体用法?C# LocationManager.GetProviders怎么用?C# LocationManager.GetProviders使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Android.Locations.LocationManager的用法示例。


在下文中一共展示了LocationManager.GetProviders方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: start

        public void start()
        {
            if (_tracking) return;

            var ls = (LocationManager) _context.GetSystemService(Context.LocationService);
            //var aproviders = ls.AllProviders.ToArray();
            //var hasGPS = ls.IsProviderEnabled(LocationManager.GpsProvider);
            //var hasNET = ls.IsProviderEnabled(LocationManager.NetworkProvider);

            //if (!hasGPS || !hasNET)
            {
                //throw new Exception("Must have both GPS and Net location providers");
            }

            _locationManager = ls;

            var lastLocation = _locationManager.GetLastKnownLocation(LocationManager.PassiveProvider);
            Location = createGeoLocation(lastLocation);

            var criteria = new Criteria();
            criteria.Accuracy = Accuracy.Fine;
            criteria.AltitudeRequired = true;

            var providers = _locationManager.GetProviders(criteria, true).ToArray();
            foreach (var provider in providers)
            {
                _locationManager.RequestLocationUpdates(provider, 1000, 5, _listener, Looper.MainLooper);
            }

            _tracking = true;
        }
开发者ID:42Spikes,项目名称:F2S,代码行数:31,代码来源:LocationManagerFacade.cs

示例2: LocationTracker

        /// <summary>
        /// コンストラクタ
        /// </summary>
        /// <param name="context"></param>
        public LocationTracker(Context context, string provider = LocationManager.GpsProvider)
        {
            locationMan = (LocationManager)context.GetSystemService(Service.LocationService);

            if(locationMan.GetProviders(true).Contains(provider))
            {
                Provider = provider;
            }
            else if (locationMan.IsProviderEnabled(LocationManager.GpsProvider))
            {
                Provider = LocationManager.GpsProvider;
            }
            else if (locationMan.IsProviderEnabled(LocationManager.NetworkProvider))
            {
                Provider = LocationManager.NetworkProvider;
            }
            else
            {
                Criteria crit = new Criteria();
                crit.Accuracy = Accuracy.Fine;
                Provider = locationMan.GetBestProvider(crit, true);
            }

            LastGPSReceived = DateTime.MinValue;
        }
开发者ID:butaman,项目名称:AutoSendPic,代码行数:29,代码来源:LocationTracker.cs

示例3: InitializeLocationManager

 private void InitializeLocationManager()
 {
     _locationManager = (LocationManager)GetSystemService(LocationService);
     var kriteria = new Criteria { Accuracy = Accuracy.Fine };
     var accepatbleLocationProvs = _locationManager.GetProviders(kriteria, true);
     _locationProvider = accepatbleLocationProvs.Any() ? accepatbleLocationProvs.First() : string.Empty;
     Log.Debug(TAG, "using : " + _locationProvider + ".");
 }
开发者ID:ibnuda,项目名称:LainLadangLainBelalang,代码行数:8,代码来源:DevXamActivity.cs

示例4: Geolocator

      public Geolocator( Context context )
      {
         if(context == null)
         {
            throw new ArgumentNullException( "context" );
         }

         manager = (LocationManager)context.GetSystemService( Context.LocationService );
         providers =
            manager.GetProviders( enabledOnly: false ).Where( s => s != LocationManager.PassiveProvider ).ToArray();
      }
开发者ID:nexussays,项目名称:Xamarin.Mobile,代码行数:11,代码来源:Geolocator.cs

示例5: LocationTestService

        public LocationTestService(Context context)
        {
            locationManager = (LocationManager)context.GetSystemService(Context.LocationService);
            var criteriaForLocationService = new Criteria { Accuracy = Accuracy.Fine };
            var acceptableLocationProviders = locationManager.GetProviders(criteriaForLocationService, true);

            if (acceptableLocationProviders.Any())
            {
                locationProvider = acceptableLocationProviders.First();
            }
        }
开发者ID:pgrzmil,项目名称:XamarinResearch,代码行数:11,代码来源:LocationTestService.cs

示例6: OnCreate

		protected override void OnCreate(Bundle bundle)
		{
			base.OnCreate(bundle);
			SetContentView(Resource.Layout.Main);
			ConnectivityManager connectivityManager = (ConnectivityManager) GetSystemService(ConnectivityService);
			NetworkInfo activeConnection = connectivityManager.ActiveNetworkInfo;


			Button loginButton = FindViewById<Button>(Resource.Id.loginButton);
			Button filteButton = FindViewById<Button> (Resource.Id.button1);
 			prefs = PreferenceManager.GetDefaultSharedPreferences(this);
			_locationManager = GetSystemService (Context.LocationService) as LocationManager;
			Criteria criteriaForLocationService = new Criteria
			{
				Accuracy = Accuracy.Fine
			};
			acceptableLocationProviders = _locationManager.GetProviders(criteriaForLocationService, true);

				
				filteButton.Click += (object sender, EventArgs e) => {
					Intent intent = new Intent (this, typeof(FilterActivity));
					StartActivityForResult (intent, 0);
				};

				loginButton.Click += (object sender, EventArgs e) => {
				bool isOnline = (activeConnection != null) && activeConnection.IsConnected;
				bool wifiIsOnline = (connectivityManager.GetNetworkInfo(ConnectivityType.Wifi)).IsConnected;
				if (isOnline || wifiIsOnline) {
					
					if (!string.IsNullOrEmpty (prefs.GetString ("token", ""))) {
						Intent intent = new Intent (this, typeof(SearchActivity));
						StartActivityForResult (intent, 0);
					} else {
						auth = Global.LogIn ();
						auth.Completed += auth_Completed;
						StartActivity (auth.GetUI (this));
					}
				}
				else 
				{
					AlertDialog.Builder alert = new AlertDialog.Builder (this);
					alert.SetTitle ("Internet connection error");
					alert.SetMessage ("Turn wifi or mobile data on");
					alert.SetPositiveButton ("Ok", (senderAlert, args) => {

					});
					Dialog dialog = alert.Create();
					dialog.Show();
				}
			};
		
			} 
开发者ID:YourmumisEZ,项目名称:WTG,代码行数:52,代码来源:MainActivity.cs

示例7: OnCreate

        public override void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate (savedInstanceState);

            // Create your fragment here
            string lp = string.Empty;
            _lm = (LocationManager) GetSystemService(LocationService);
            Criteria cr = new Criteria { Accuracy = Accuracy.Fine };
            IList<string> alp = _lm.GetProviders (cr, true);

            if (alp.Any ()) {
                lp = alp.First ();
                _lm.RequestLocationUpdates (lp, this);
            }
        }
开发者ID:sudo-wrestlers,项目名称:hackathon,代码行数:15,代码来源:EventManagerFragment.cs

示例8: StartLocationManager

        public void StartLocationManager(Action<MyLocation> callBack)
        {
            manager = (LocationManager) Android.App.Application.Context.GetSystemService (Context.LocationService);

            _callBack = callBack;

            Criteria criteriaForLocationService = new Criteria { Accuracy = Accuracy.Coarse };

            IList<string> acceptableLocationProviders = manager.GetProviders(criteriaForLocationService, true);

            if (acceptableLocationProviders.Any())
                manager.RequestLocationUpdates (acceptableLocationProviders.First (), 0, 0, this);
            else
                throw new LocationServiceNotRunningException ();
        }
开发者ID:arctouch-kristofberge,项目名称:BrewBuddy,代码行数:15,代码来源:LocationManagerAndroid.cs

示例9: InitializeLocationManager

        void InitializeLocationManager()
        {
            _locationManager = (LocationManager)GetSystemService(LocationService);
            Criteria criteriaForLocationService = new Criteria
            {
                Accuracy = Accuracy.Fine
            };
            IList<string> acceptableLocationProviders = _locationManager.GetProviders(criteriaForLocationService, true);

            if (acceptableLocationProviders.Count != 0)
            {
                _locationProvider = acceptableLocationProviders[0];
            }
            else
            {
                _locationProvider = string.Empty;
            }
        }
开发者ID:CWConnor,项目名称:PogoTracker,代码行数:18,代码来源:MainActivity.cs

示例10: InitializeLocationManager

        void InitializeLocationManager()
        {
            _locationManager = (LocationManager)GetSystemService(LocationService);
            Criteria criteriaForLocationService = new Criteria
                                                  {
                                                      Accuracy = Accuracy.Fine
                                                  };
            IList<string> acceptableLocationProviders = _locationManager.GetProviders(criteriaForLocationService, true);

            if (acceptableLocationProviders.Any())
            {
                _locationProvider = acceptableLocationProviders.First();
            }
            else
            {
                _locationProvider = String.Empty;
            }
            Log.Debug(LogTag, "Using " + _locationProvider + ".");
        }
开发者ID:bmacadam,项目名称:recipes,代码行数:19,代码来源:Activity1.cs

示例11: InitializeLocationManager

		void InitializeLocationManager()
		{
			_locationManager = (LocationManager) Application.Context.GetSystemService(Application.LocationService);
			Criteria criteriaForLocationService = new Criteria
			{
				Accuracy = Accuracy.Fine
			};
			IList<string> acceptableLocationProviders = _locationManager.GetProviders(criteriaForLocationService, true);

			if (acceptableLocationProviders.Any())
			{
				_locationProvider = acceptableLocationProviders.First();
			}
			else
			{
				_locationProvider = string.Empty;
			}

		}
开发者ID:valtarakanov,项目名称:BluetoothNotify,代码行数:19,代码来源:NotificationProcessor.cs

示例12: LocListener

		public LocListener(LocationManager lm, SensorManager sm) : base()
		{
			// Get LocationManager
			locManager = lm;

			var locationCriteria = new Criteria ()
			{
				Accuracy = global::Android.Locations.Accuracy.Fine,
				AltitudeRequired = true,
				PowerRequirement = Power.Low
			};

			locationProvider = locManager.GetBestProvider(locationCriteria, true);

			if (locationProvider == null)
				throw new Exception("No location provider found");

			List<String> providers = locManager.GetProviders(true) as List<String>;

			// Loop over the array backwards, and if you get an accurate location, then break out the loop
			Location loc = null;

			if (providers != null) {
				for (int i = providers.Count - 1; i >= 0; i--) {
					loc = locManager.GetLastKnownLocation(providers[i]);
					if (loc != null) 
						break;
				}
			}

			if (loc != null)
			{
				lat = loc.Latitude;
				lon = loc.Longitude;
				alt = loc.Altitude;
				accuracy = loc.Accuracy;
			}

			sensorManager = sm;
			accelerometer = sensorManager.GetDefaultSensor(SensorType.Accelerometer);
			magnetometer = sensorManager.GetDefaultSensor(SensorType.MagneticField);
		}
开发者ID:jonny65,项目名称:WF.Player.Android,代码行数:42,代码来源:LocListener.cs

示例13: InitializeLocationManager

        private void InitializeLocationManager()
        {
            m_LocationManager = (LocationManager)GetSystemService(LocationService);
            Criteria criteriaForLocationService = new Criteria
            {
                Accuracy = Accuracy.Fine
            };
            IList<string> acceptableLocationProviders = m_LocationManager.GetProviders(criteriaForLocationService, true);

            if (acceptableLocationProviders.Any())
            {
                m_LocationProvider = acceptableLocationProviders.First();
            }
            else
            {
                m_LocationProvider = String.Empty;
            }

            m_LocationManager.RequestLocationUpdates(LocationManager.GpsProvider, 5000, 10, this);
        }
开发者ID:bleissem,项目名称:jogging,代码行数:20,代码来源:MainActivity.cs

示例14: InitLocationService

        public void InitLocationService()
        {
            var wrapper = new Android.Content.ContextWrapper(Forms.Context);

            _locationManager = (LocationManager) wrapper.GetSystemService(Context.LocationService);
            Criteria criteriaForLocationService = new Criteria
            {
                Accuracy = Accuracy.Fine
            };
            IList<string> acceptableLocationProviders = _locationManager.GetProviders(criteriaForLocationService, true);

            if (acceptableLocationProviders.Any())
            {
                _locationProvider = acceptableLocationProviders.First();
                _locationManager.RequestLocationUpdates(_locationProvider, 2000, 10, this);
            }
            else
            {
                _locationProvider = String.Empty;
            }
            Console.WriteLine("Using " + _locationProvider + ".");
        }
开发者ID:bernardoroll,项目名称:XamarinFormsDependencyService,代码行数:22,代码来源:GeoLocation_Android.cs

示例15: InitializeLocationManager

        void InitializeLocationManager()
        {
            _locationManager = (LocationManager)GetSystemService(LocationService);
            Criteria criteriaForLocationService = new Criteria
            {
                Accuracy = Accuracy.Fine
            };
            IList<string> acceptableLocationProviders = _locationManager.GetProviders(criteriaForLocationService, true);

            if (acceptableLocationProviders.Any())
            {
                _locationProvider = acceptableLocationProviders.First();
            }
            else
            {
                _locationProvider = String.Empty;
            }
            FindViewById<TextView> (Resource.Id.btnCheckIn).Enabled = true;
        }
开发者ID:jdrharding,项目名称:ROMPAndroid,代码行数:19,代码来源:CheckInActivity.cs


注:本文中的Android.Locations.LocationManager.GetProviders方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。