【发布时间】:2016-09-08 08:15:31
【问题描述】:
我正在使用 xamarin 表单开发 android 应用程序。这是我用于获取纬度和经度的代码。但是当我尝试使用模拟器时,它每次都有效,但移动设备有时有效,有时无效。请帮我。
var locator = Geolocator.Plugin.CrossGeolocator.Current;
locator.DesiredAccuracy = 50;
try
{
var locator2 = Geolocator.Plugin.CrossGeolocator.Current;
locator2.DesiredAccuracy = 50;
var position = await locator.GetPositionAsync(timeoutMilliseconds: 10000);
if (position == null)
{
return;
}
}
catch (Exception ex)
{
}
【问题讨论】:
-
每次我没有得到位置时,我都试图获取大厅的经纬度,但是当我尝试在大厅的一侧时,纬度和经度就会出现。有人有解决这个问题的办法吗?
-
这些权限:ACCESS_COARSE_LOCATION 和 ACCESS_FINE_LOCATION 已经启用。
标签: c# geolocation xamarin.forms