gpt4 book ai didi

windows - 是否可以在 PositionChanged 事件处理程序中更改 Geolocator 的 DesiredAccuracy 和 ReportInterval?

转载 作者:可可西里 更新时间:2023-11-01 11:35:02 25 4
gpt4 key购买 nike

我想更改 PositionChanged 事件处理程序中的 DesiredAccuracy 和 ReportInterval,以便我可以动态更改不同位置的位置更新频率。

我做了这样的事情,

void geolocator_PositionChanged(Geolocator sender, PositionChangedEventArgs args)
{
geolocator.StatusChanged -= geolocator_StatusChanged;
geolocator.PositionChanged -= geolocator_PositionChanged;
geolocator.DesiredAccuracy = PositionAccuracy.High;
geolocator.ReportInterval = 5 * 1000;
geolocator.StatusChanged += geolocator_StatusChanged;
geolocator.PositionChanged += geolocator_PositionChanged;
}

但问题是我得到了

$exception {System.Exception: Operation aborted (Exception from HRESULT: 0x80004004 (E_ABORT))

Windows.Devices.Geolocation.Geolocator.put_DesiredAccuracy(PositionAccuracy value)

我不明白这个异常,因为它没有说明原因。

我怎样才能做到这一点(动态更改准确性和报告间隔)?

谢谢。

最佳答案

根据 this Microsoft article ,您的异常表明您已从手机设置中禁用定位服务:

catch (Exception ex)
{
if ((uint)ex.HResult == 0x80004004)
{
// the application does not have the right capability or the location master switch is off
StatusTextBlock.Text = "location is disabled in phone settings.";
}
//else
{
// something else happened acquring the location
}
}

关于windows - 是否可以在 PositionChanged 事件处理程序中更改 Geolocator 的 DesiredAccuracy 和 ReportInterval?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13720945/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com