【问题标题】:Error with Geolocator Windows Phone地理定位器 Windows Phone 错误
【发布时间】:2013-10-18 23:30:39
【问题描述】:

任何人都知道为什么当我将应用程序提交到商店时,我的代码总是出错。一切都在开发设备上运行得很好。应用能力:LOCATION、MAP、IDENTITY_DEVICE、IDENTITY_USER、CAMERA、AUDIO、PHOTO、NETWORKING、PROXIMITY、PUSH_NOTIFICATION、SENSORS

private readonly Geolocator _geolocator = new Geolocator { DesiredAccuracy = PositionAccuracy.Default, MovementThreshold = 100 };

private async Task GetCurrentPosition()
    {
        //Get current location
        try
        {
            _done.WaitOne();
            var position = await _geolocator.GetGeopositionAsync();
            if (position != null)
            {
                // Get detail address
                var query = new ReverseGeocodeQuery { GeoCoordinate = new GeoCoordinate(position.Coordinate.Latitude, position.Coordinate.Longitude) };
                query.QueryCompleted += OnQueryCompleted;
                _done.Reset();
                query.QueryAsync();
            }
        }
        catch (Exception ex)
        {
            if (ex.Message.Contains("Operation aborted"))
            {
                if (MessageBox.Show(AppResources.LocationServiceErrorMsg, AppResources.ApplicationTitle, MessageBoxButton.OKCancel) == MessageBoxResult.OK)
                {
                    Windows.System.Launcher.LaunchUriAsync(new Uri("ms-settings-location:"));
                    Application.Current.Terminate();
                }
                else
                {
                    Application.Current.Terminate();
                }
            }
        }
    }

private void OnQueryCompleted(object sender, QueryCompletedEventArgs<System.Collections.Generic.IList<MapLocation>> e)
    {
        _done.Set();
        if (e.Result != null && e.Result.Count > 0)
        {
            App.AppData.CurrentCountry = e.Result[0].Information.Address.Country;
            App.AppData.CurrentCity = e.Result[0].Information.Address.City;
            App.AppData.CurrentStreet = e.Result[0].Information.Address.Street;

            App.CurrentPosition = e.Result[0].GeoCoordinate;

            Helper.SaveAppSetting(App.AppData);

            if (string.IsNullOrEmpty(App.AppData.UserId))
            {
                NavigationService.Navigate(MessageBox.Show(AppResources.UserIdEmptyMsg, AppResources.ApplicationTitle, MessageBoxButton.OKCancel) == MessageBoxResult.OK
                        ? new Uri("/Views/SettingPage.xaml?navCode=userId", UriKind.Relative)
                        : new Uri("/Views/MainPage.xaml", UriKind.Relative));
            }
            else
            {
                NavigationService.Navigate(new Uri("/Views/MainPage.xaml", UriKind.Relative));
            }
        }
    }

【问题讨论】:

  • 提供一些关于你得到的错误的信息。

标签: windows-phone-8


【解决方案1】:

如果您可以提供测试报告中给出的信息,那么我们可能会提供更好的帮助,尽管他们的文件通常是不言自明的。

MSDN 上的文档中有认证要求,与使用位置的应用相关的要求在第 2.7 节中介绍。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2013-05-21
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多