【发布时间】:2019-08-03 22:51:07
【问题描述】:
我正在尝试使用GetLocation 方法从Tizen.Location.Locator 中get location,但我将纬度和经度的值设置为0。
我正在使用:
- Visual Studio 2017
- 可穿戴4.0模拟器
- 已授予privileges 使用位置,还在清单文件中添加了位置功能。
这是我的代码:
private static Locator locator = new Locator(LocationType.Gps);
try
{
if (locator != null)
{
// Starts the Locator
locator.Start();
//Get Location
Tizen.Location.Location currentLocation = locator.GetLocation();
//Update xaml view
latitudeValue.Text = currentLocation.Latitude.ToString();
longitudeValue.Text = currentLocation.Longitude.ToString();
}
}
catch (InvalidOperationException exception)
{
// Exception handling here
}
没有关于变量currentLocation 的描述,因为它在那里被视为bool。当我尝试通过 Visual Studio 的快速监视功能(通过按 Shift + F9)获取描述时,我收到另一个与该 bool 变量转换相关的错误
成员引用基类型 'bool' 不是结构或联合
上面的代码没有显示任何注册的ServiceStateChanged事件,但我也使用sample code中显示的方式包含了它,但它对我不起作用。
现在想知道我在这里做错了什么。
【问题讨论】:
-
模拟器模拟位置。您是否已在模拟器的控制面板中更改为所需位置?如果未配置,它将返回 0,0
-
我真的忘记了 .. 非常感谢让我度过了愉快的一天 :) 现在它在模拟器中工作,但它也在真实设备上提供模拟值(因为我使用 @987654333 设置模拟值@方法)当我删除了模拟并开始调试时,它抛出了
locator.Start()方法上的异常。不幸的是,我在这里看不到异常的描述。
标签: .net xamarin xamarin.forms tizen xamarin.tizen