如何在后台更新Windows Phone中的位置数据? [英] How can you update location data in Windows Phone in the background?

查看:82
本文介绍了如何在后台更新Windows Phone中的位置数据?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我刚刚读到,虽然Windows Phone 7.5后台任务可以轮询某个位置,但是它们实际上并不从GPS实时轮询,而是通过位置API调用返回系统缓存的位置,该位置每15分钟更新一次

I just read that while Windows Phone 7.5 background tasks can poll for a location, they don't actually poll real-time from the GPS but rather the location API calls return a system-cached position that's only updated once every fifteen minutes.

当然,这种限制使在后台运行导航的尝试完全无效,因为您可能在十五分钟之内就偏离了轨道,更不用说后台任务每三十分钟左右只能运行一次!

That limitation of course completely invalidates any attempt at having navigation run in the background as you can get pretty damn far off-track in fifteen minutes, let alone that a background task can only run once every thirty minutes or so!

也就是说,诺基亚的导航应用程序以及据报道的Runtastic的应用程序在后台(即不仅在锁定屏幕下方)而且都在市场中时仍会继续跟踪,这意味着它们已经被批准,所以有人知道他们如何做到的吗?该SDK可能不支持什么?

That said, Nokia's navigation app and reportedly Runtastic's app do continue tracking when in the background (i.e. not just under the lock screen) and both are in the marketplace meaning they have been approved, so does anyone know how they managed to do what the SDK supposedly doesn't support?

作为参考,我们实际上不需要实时跟踪……也许每分钟大约一次,并且我们不需要那么多的准确性……也许是100英尺左右……但我们确实需要比我们得到的更多.我们只是不知道他们在批准的应用程序中的表现如何.

For reference, we don't actually need real-time tracking... maybe once a minuted or so, and we don't need that much accuracy... maybe 100 feet or so... but we do need more than we have been given. We just don't know how they're doing it in approved apps.

推荐答案

您只能在执行PeriodicTask时(大约每30分钟一次,具体取决于操作系统计划)来检索位置.它从GeoCoordinateWatcher获取的位置数据将来自操作系统的缓存,而不是直接来自GPS硬件.如果没有任何运行,则操作系统将大约每15分钟使用粗粒度数据更新一次.但是,如果应用程序已执行并检索了细粒度的GPS硬件数据,则将是您将在PeriodicTask中检索到的数据.您可以通过在前景应用程序中访问GPS并用ScheduledActionService.LaunchForTest强制调度PeriodicTask来查看示例.

You'll only be able to retrieve the location when your PeriodicTask executes (Approximately every ~30 minutes, depending on OS scheduling). The location data it fetches from GeoCoordinateWatcher will be from the OS's cache rather than directly from the GPS hardware. If nothing is running the OS will update this with coarse-grained data approximately every 15 minutes. However if an application has executed and retrieved fine-grained GPS hardware data than this will be the data you'll retrieve in your PeriodicTask. You can see examples of this by accessing the GPS in your foreground app and force-scheduling your PeriodicTask with ScheduledActionService.LaunchForTest.

这篇关于如何在后台更新Windows Phone中的位置数据?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆