use*_*349 1 c# location access-denied coordinates uwp
大家。
我正在尝试在 C# UWP 应用程序中获取当前用户的位置。
var geoLocator = new Geolocator();
geoLocator.DesiredAccuracy = PositionAccuracy.High;
var accessStatus = await Geolocator.RequestAccessAsync();
var pos = await geoLocator.GetGeopositionAsync();
var latitude = pos.Coordinate.Point.Position.Latitude;
var longitude = pos.Coordinate.Point.Position.Longitude;
Run Code Online (Sandbox Code Playgroud)
但我收到错误:
mscorlib.ni.dll 中出现“System.UnauthorizedAccessException”类型的异常,但未在用户代码 WinRT 信息中处理:您的应用无权访问位置数据。确保您已在应用程序清单中定义了 ID_CAP_LOCATION,并且在您的手机上,您已通过检查设置 > 位置来打开位置。附加信息:访问被拒绝。
在 Package.appxmanifest 中,我检查了以下项目:Internet(客户端和服务器) - 选中,Internet(客户端) - 选中,位置 - 选中。
如何在本地机器上设置权限?
| 归档时间: |
|
| 查看次数: |
1940 次 |
| 最近记录: |