本文整理汇总了C#中Android.Locations.LocationManager类的典型用法代码示例。如果您正苦于以下问题:C# LocationManager类的具体用法?C# LocationManager怎么用?C# LocationManager使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
LocationManager类属于Android.Locations命名空间,在下文中一共展示了LocationManager类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: OnCreate
protected override void OnCreate(Bundle bundle)
{
base.OnCreate(bundle);
// use location service directly
_locMgr = GetSystemService(LocationService) as LocationManager;
}
示例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)));
}
示例3: GeoLocationService
public GeoLocationService(LocationManager locationManager, IMarshalInvokeService marshalService)
{
manager = locationManager;
marshal = marshalService;
timer = new Timer(SEVEN_SECONDS);
timer.Elapsed += OnTimeout;
}
示例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);
}
示例5: OnResume
protected override void OnResume ()
{
base.OnResume ();
// initialize location manager
locMgr = GetSystemService (Context.LocationService) as LocationManager;
}
示例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;
}
示例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);
}
示例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);
}
示例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;
}
}
示例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);
}
};
}
示例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;
}
示例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;
}
示例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 ();
}
示例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);
}
示例15: Geolocation
public Geolocation(LocationManager locationManager)
{
_locationManager = locationManager;
_success = position => { };
_error = error => { };
_options= new GeolocationOptions();
_watchId = Guid.NewGuid().ToString();
}