UWP后台任务位置跟踪 [英] UWP background task location tracking

查看:109
本文介绍了UWP后台任务位置跟踪的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试开发一个UWP应用,该应用能够在正在进行的后台任务中持续跟踪用户的位置.我一直在查看GitHub上的Microsoft示例代码(geolocation/Secenario3_BackgroundTask),但是问题在于它基于TimeTrigger. TimeTrigger允许的最短间隔是15分钟,但是我需要更频繁地获取位置更新.假设每分钟至少一次.可能吗?

I'm trying to develop an UWP app that is able to continually track the user's location in an in-process background task. I've been looking at the Microsoft sample code on GitHub (geolocation / Secenario3_BackgroundTask) but the problem there is that it is based on a TimeTrigger. The shortest interval that TimeTrigger allows is 15 minutes, but I need to get location updates much more frequently. Let's say at least once per minute. Is that possible at all?

我已经看到有一个LocationTrigger,但是没有太多的文档.我不知道何时触发该触发器.在我的测试中,它从未被解雇.

I've seen that there is a LocationTrigger but there's not much documentation for it. I don't understand when this trigger gets fired. In my tests, it never got fired.

推荐答案

LocationTrigger用于 Geofencing ,当移动设备进入或离开特定区域时触发.

LocationTrigger is used for Geofencing, it is triggered when a mobile device enters or leaves a particular area.

如您所说,TimeTrigger不能满足您的要求,因为它的间隔最少为15分钟.

As you say, TimeTrigger is not good for your requirement because it has an interval of 15 minutes at the minimum.

Windows 10引入了一种称为扩展执行.位置跟踪是一种受支持的方案,在这种情况下,当另一个应用程序切换到前台时,您要求操作系统保持应用程序运行.

Windows 10 introduces a new mechanism called extended execution. Location tracking is one of the supported scenarios in which you ask the OS to keep your app running when another app is switched to the foreground.

这是样本.

这篇关于UWP后台任务位置跟踪的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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