• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C# Locations.LocationManager类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



LocationManager类属于Android.Locations命名空间,在下文中一共展示了LocationManager类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。

示例1: OnCreate

        protected override void OnCreate(Bundle bundle)
        {
            base.OnCreate(bundle);

            // use location service directly
            _locMgr = GetSystemService(LocationService) as LocationManager;
        }
开发者ID:peter-dangelo,项目名称:XamarinAndroidMapsAndPlaces,代码行数:7,代码来源:LocationActivity.cs


示例2: OnCreate

        protected override void OnCreate(Bundle bundle)
        {
            base.OnCreate(bundle);
            SetContentView(Resource.Layout.Main);

            locationManager = GetSystemService(Context.LocationService) as LocationManager;

            //set the user current location
            setlocation();

            //setup the map
            SetupMap();


            //set left drawer staff
            leftDrawerLayaout = FindViewById<DrawerLayout>(Resource.Id.myDrawer);
            leftDrawer = FindViewById<ListView>(Resource.Id.leftListView);

            //get users 
            populateUsersOnDrawer();

            leftDrawerToggle = new ActionBarDrawerToggle(this, leftDrawerLayaout, Resource.Drawable.menu, Resource.String.drawer_open, Resource.String.drawer_close);
            leftDrawerLayaout.SetDrawerListener(leftDrawerToggle);
            ActionBar.SetDisplayHomeAsUpEnabled(true);
            ActionBar.SetHomeButtonEnabled(true);
            ActionBar.SetDisplayShowTitleEnabled(true);
           
            //start message service 
            StartService(new Intent(this, typeof(MsgApiService)));

        }
开发者ID:DlerAhmad,项目名称:AndroidMessenger,代码行数:31,代码来源:MapActivity.cs


示例3: GeoLocationService

 public GeoLocationService(LocationManager locationManager, IMarshalInvokeService marshalService)
 {
     manager = locationManager;
     marshal = marshalService;
     timer = new Timer(SEVEN_SECONDS);
     timer.Elapsed += OnTimeout;
 }
开发者ID:AlexanderGrant1,项目名称:PropertyCross,代码行数:7,代码来源:GeoLocationService.cs


示例4: GetCurrentLocation

 protected override void GetCurrentLocation()
 {
     locationManager = context.GetSystemService(Context.LocationService) as LocationManager;
     if (locationManager.IsProviderEnabled(LocationManager.GpsProvider))
         locationManager.RequestLocationUpdates(LocationManager.GpsProvider, 2000, 1, this);
     
 }
开发者ID:szymid,项目名称:notificationsCross,代码行数:7,代码来源:GpsLocationAndroid.cs


示例5: OnResume

		protected override void OnResume ()
		{
			base.OnResume (); 

			// initialize location manager
			locMgr = GetSystemService (Context.LocationService) as LocationManager;
		}
开发者ID:stowjam,项目名称:Assignment6-gpsmaps,代码行数:7,代码来源:MainActivity.cs


示例6: 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


示例7: PlatformSpecificStart

        protected override void PlatformSpecificStart(MvxLocationOptions options)
        {
            if (_locationManager != null)
                throw new MvxException("You cannot start the MvxLocation service more than once");

            _locationManager = (LocationManager)Context.GetSystemService(Context.LocationService);
            if (_locationManager == null)
            {
                MvxTrace.Warning("Location Service Manager unavailable - returned null");
                SendError(MvxLocationErrorCode.ServiceUnavailable);
                return;
            }
            var criteria = new Criteria()
                {
                    Accuracy = options.Accuracy == MvxLocationAccuracy.Fine ? Accuracy.Fine : Accuracy.Coarse,
                };
            _bestProvider = _locationManager.GetBestProvider(criteria, true);
            if (_bestProvider == null)
            {
                MvxTrace.Warning("Location Service Provider unavailable - returned null");
                SendError(MvxLocationErrorCode.ServiceUnavailable);
                return;
            }

            _locationManager.RequestLocationUpdates(
                _bestProvider, 
                (long)options.TimeBetweenUpdates.TotalMilliseconds,
                options.MovementThresholdInM, 
                _locationListener);
        }
开发者ID:Everbridge,项目名称:sm-MvvmCross,代码行数:30,代码来源:MvxAndroidLocationWatcher.cs


示例8: OnCreate

		protected override void OnCreate (Bundle bundle)
		{
			base.OnCreate (bundle);

			AppDomain.CurrentDomain.UnhandledException += UnhandledExceptionLocal;
			AndroidEnvironment.UnhandledExceptionRaiser +=  HandleAndroidException;
			Xamarin.Forms.Forms.Init (this, bundle);

			Forms.Init(this, bundle);
			FormsMaps.Init(this, bundle);

			_locationManager = GetSystemService (Context.LocationService) as LocationManager;
			Criteria locationCriteria = new Criteria();
			locationCriteria.Accuracy = Accuracy.Coarse;
			locationCriteria.PowerRequirement = Power.Medium;
			var locationProvider = _locationManager.GetBestProvider(locationCriteria, true);
			if(locationProvider != null)
			{
				_locationManager.RequestLocationUpdates (locationProvider, 500, 1, this);
			}

			var pclApp = App.Portable.App.Instance;
			var setup = new AppSetup () {
				CreateConnectionPool = this.CreateConnnectionPool,
				DbPath = Path.Combine (System.Environment.GetFolderPath (System.Environment.SpecialFolder.Personal),"RF12G5td864.db3")
			};
			pclApp.Setup (setup);
			#if DEBUG
			//pclApp.DeleteUser ();
			#endif
			LoadApplication (pclApp);
		}
开发者ID:Painyjames,项目名称:Pilarometro.App,代码行数:32,代码来源:MainActivity.cs


示例9: OnCreate

        protected override void OnCreate (Bundle bundle)
		{
			base.OnCreate (bundle);

			// Set our view from the "main" layout resource
			SetContentView (Resource.Layout.Main);

            // Get our button from the layout resource,
            // and attach an event to it
            nameEditText = FindViewById<EditText>(Resource.Id.firstNameTextField);
            surnameEditText = FindViewById<EditText>(Resource.Id.surNameTextField);

            locM = GetSystemService(Context.LocationService) as LocationManager;
            if (locM.IsProviderEnabled(LocationManager.GpsProvider))
                locM.RequestLocationUpdates(LocationManager.GpsProvider, 2000, 1, this);


            Button notificationButton1 = FindViewById<Button>(Resource.Id.notificationButton1);
            Button notificationButton2 = FindViewById<Button>(Resource.Id.notificationbutton2);
            Button notificationButton3 = FindViewById<Button>(Resource.Id.notificationbutton3);
            Button notificationButton4 = FindViewById<Button>(Resource.Id.notificationbutton4);
            Button notificationButton5 = FindViewById<Button>(Resource.Id.notificationbutton5);
            textView = FindViewById<TextView>(Resource.Id.textView2);


            notificationButtons = new Button[] { notificationButton1, notificationButton2, notificationButton3, notificationButton4, notificationButton5 };

            foreach (Button button in notificationButtons)
            {
                button.Enabled = false;
                button.Click += SendNotification;
            }            
		}
开发者ID:szymid,项目名称:notificationsCross,代码行数:33,代码来源:MainActivity.cs


示例10: OnResume

        protected override void OnResume()
        {
            base.OnResume();

            // LocationManagerを初期化
            locMgr = GetSystemService(Context.LocationService) as LocationManager;

            button.Click += (sender, e) =>
            {
                if (locMgr.AllProviders.Contains(LocationManager.NetworkProvider)
                        && locMgr.IsProviderEnabled(LocationManager.NetworkProvider))
                {
                    // Network: Wifiと3Gで位置情報を取得します。電池使用量は少ないですが精度にばらつきがあります。
                    Log.Debug(tag, "Starting location updates with Network");
                    locMgr.RequestLocationUpdates(LocationManager.NetworkProvider, 10000, 10, this);
                }
                else
                {
                    // GetBestProviderで最適なProviderを利用できるようです。(NetworkがあればそれがBestProviderになるようです。)
                    var locationCriteria = new Criteria();
                    locationCriteria.Accuracy = Accuracy.Coarse;
                    locationCriteria.PowerRequirement = Power.Medium;
                    string locationProvider = locMgr.GetBestProvider(locationCriteria, true);

                    Log.Debug(tag, "Starting location updates with " + locationProvider.ToString());
                    locMgr.RequestLocationUpdates(locationProvider, 10000, 10, this);
                }
            };
        }
开发者ID:ytabuchi,项目名称:BuildInsider_Geolocator,代码行数:29,代码来源:MainActivity.cs


示例11: 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


示例12: OnResume

		protected override void OnResume ()
		{
			base.OnResume ();

			// Get a handle on the map element
			_mapFragment = FragmentManager.FindFragmentById(Resource.Id.map) as MapFragment;
			_map = _mapFragment.Map;

			// Set the map type 
			_map.MapType = GoogleMap.MapTypeNormal;

			// show user location
			_map.MyLocationEnabled = true;

			// setup a location manager
			_locationManager = GetSystemService(Context.LocationService) as LocationManager;

			// Add points on the map
			MarkerOptions marker1 = new MarkerOptions()
				.SetPosition(Location_Xamarin)
				.SetTitle("Xamarin")
				.InvokeIcon(BitmapDescriptorFactory.DefaultMarker(BitmapDescriptorFactory.HueBlue));
			_map.AddMarker(marker1);

			MarkerOptions marker2 = new MarkerOptions()
			    .SetPosition(Location_Atlanta)
			    .SetTitle("Atlanta, GA")
			    .InvokeIcon(BitmapDescriptorFactory.DefaultMarker(BitmapDescriptorFactory.HueRed));
			_map.AddMarker(marker2);

			// Add custom marker images on the map
			AddMonkeyMarkersToMap();

			// Add custom arrow callout on map
			AddInitialNewYorkBarToMap();

			// Add custom overlay image on the map
			PositionChicagoGroundOverlay(Location_Chicago);

			// use a generic location provider instead
			Criteria locationCriteria = new Criteria();
			locationCriteria.Accuracy = Accuracy.Coarse;
			locationCriteria.PowerRequirement = Power.Medium;

			var locationProvider = _locationManager.GetBestProvider(locationCriteria, true);
			if (locationProvider != null)
			{
				_locationManager.RequestLocationUpdates(locationProvider, 2000, 1, this);
			} else
			{
				Log.Info("error", "Best provider is not available. Does the device have location services enabled?");
			}

			// TODO: Step 4a - attach map handler for marker touch
//            _map.MarkerClick += MapOnMarkerClick;

			// TODO: Step 4c - attach map handler for info window touch
//			_map.InfoWindowClick += HandleInfoWindowClick;
		}
开发者ID:flolovebit,项目名称:xamarin-evolve-2014,代码行数:59,代码来源:MainActivity.cs


示例13: OnCreate

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

			logoImage = new UIImageView (this);
			logoImage.ImageResource = Resource.Drawable.esilehe_logo;
			logoImage.SetScaleType (ImageView.ScaleType.CenterInside);
			logoImage.LayoutParameters = LayoutUtils.GetRelativeMatchParent ();

			menuImageContainer = new UIView (this);
			menuImageContainer.Frame = new Frame (
				0,
				0,
				DeviceInfo.NavigationBarHeight + Sizes.ActionBarButtonSize,
				DeviceInfo.NavigationBarHeight
			);

			menuImage = new UIImageView (this);
			menuImage.ImageResource = Resource.Drawable.burger;
			menuImage.SetScaleType (ImageView.ScaleType.CenterInside);
			menuImage.Frame = new Frame (
				0,
				(menuImageContainer.Frame.H - Sizes.ActionBarButtonSize) / 2,
				Sizes.ActionBarButtonSize,
				Sizes.ActionBarButtonSize
			);

			menuImageContainer.AddView (menuImage);

			actionBarContainer = new UIView (this);
			actionBarContainer.Frame = new Frame (DeviceInfo.ScreenWidth, DeviceInfo.NavigationBarHeight);
			actionBarContainer.AddViews (
				logoImage,
				menuImageContainer
			);

			ActionBar.SetDisplayShowCustomEnabled (true);

			this.ActionBar.SetCustomView (
				actionBarContainer, 
				new ActionBar.LayoutParams (DeviceInfo.ScreenWidth, DeviceInfo.NavigationBarHeight)
			);




			locMgr = GetSystemService (Context.LocationService) as LocationManager;




			contentView = new MainView (this);
			SetContentView (contentView);

			menuPopup = new MenuPopupView (this, WindowManager);
			menuPopup.UpdateView ();

			menuImageContainer.Click += (object sender, System.EventArgs e) => ShowMenu ();
		}
开发者ID:Gerhic,项目名称:Need2Park,代码行数:59,代码来源:MainActivity.cs


示例14: LocationProvider

 public LocationProvider(Context context, ILocationListener locListener)
 {
     this.context = context;
     this.locationManager = LocationManager.FromContext (context);
     this.locationListener = locListener;
     this.gpsProviderEnabled = this.locationManager.IsProviderEnabled (LocationManager.GpsProvider);
     this.networkProviderEnabled = this.locationManager.IsProviderEnabled (LocationManager.NetworkProvider);
 }
开发者ID:ancchaimongkon,项目名称:wikitude-xamarin,代码行数:8,代码来源:LocationProvider.cs


示例15: Geolocation

 public Geolocation(LocationManager locationManager)
 {
     _locationManager = locationManager;
     _success = position => { };
     _error = error => { };
     _options= new GeolocationOptions();
     _watchId = Guid.NewGuid().ToString();
 }
开发者ID:anders-hammervold,项目名称:MonoMobile.Extensions,代码行数:8,代码来源:Geolocation.cs


示例16: Locator

 public Locator(Activity ctx)
 {
     this.ctx = ctx;
     locationManager = (LocationManager)ctx.GetSystemService (Context.LocationService);
     locationManager.RequestLocationUpdates (LocationManager.PassiveProvider, 5 * 60 * 1000, 2, this);
     if (Geocoder.IsPresent)
         geocoder = new Geocoder (ctx);
 }
开发者ID:Andrea,项目名称:FriendTab,代码行数:8,代码来源:Locator.cs


示例17: 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


示例18: OnCreate

        protected override void OnCreate(Bundle bundle)
        {
            base.OnCreate(bundle);

            SetContentView(Resource.Layout.LocationView);

            // use location service directly
            _locMgr = GetSystemService(LocationService) as LocationManager;
        }
开发者ID:hram,项目名称:monodroid-samples,代码行数:9,代码来源:LocationActivity.cs


示例19: OnCreate

        protected override void OnCreate(Bundle bundle)
        {
            base.OnCreate(bundle);

            global::Xamarin.Forms.Forms.Init(this, bundle);
            global::Xamarin.FormsMaps.Init(this, bundle);
            locationManager = GetSystemService(Context.LocationService) as LocationManager;

            LoadApplication(new App());
        }
开发者ID:nodoid,项目名称:GPSPush,代码行数:10,代码来源:MainActivity.cs


示例20: 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



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# Media.MediaPlayer类代码示例发布时间:2022-05-24
下一篇:
C# Locations.Location类代码示例发布时间:2022-05-24
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap