-1

我正在尝试“刷新”需要在后台进行位置跟踪的旧 Windows Phone 8.0 应用程序。无法将其“升级”到 Windows Phone 8.1(因为后台位置跟踪不起作用)。

我需要获取位置让我们说每分钟。如果我将应用程序迁移到 Windows 10 UAP,后台的位置跟踪会起作用吗?

4

1 回答 1

1

UAP 的后台跟踪方式由ExtendedExecutionSession处理(至少在 2015 年 3 月的技术预览中):

private ExtendedExecutionSession session;

private async void StartLocationExtensionSession()
{
   session = new ExtendedExecutionSession();
   session.Description = "Location Tracker";
   session.Reason = ExtendedExecutionReason.LocationTracking;
   session.Revoked += ExtendedExecutionSession_Revoked;
   var result = await session.RequestExtensionAsync();
   if (result == ExtendedExecutionResult.Denied)
   {
       //TODO: handle denied
   }
}

这个例子来自http://www.sharpgis.net/post/2015/03/29/Using-Windows-10s-Extended-Execution

于 2015-04-03T03:34:21.320 回答