나는 위도와 경도로 사용자 위치를 취한 다음 API를 사용하여 결과를 돌려주는 날씨 앱을 가지고 있습니다. 위치 서비스가 꺼지면 앱이 열렸을 때 충돌이 발생하고 오류가 발생한 곳을 알 수있는 오류 도움말이 표시되지 않습니다. 위치 서비스가 하나인지 확인하기 위해 if 문을 작성하는 방법이 있습니까? 이 문제를 방지하려면 어떻게해야합니까? - https://dev.windowsphone.com/en-US/CrashReport ( 위치 서비스가 꺼져있을 때 Windows 8 전화 앱이 열렸을 때 오류가 발생합니다.
async private void GetLocation()
{
var geolocator = new Geolocator();
if (geolocator.LocationStatus == PositionStatus.Disabled)
{
//MessageBox.Show("We need your current location for the app to function properly, please set location services on in settings");
MessageBoxResult mRes = MessageBox.Show("We need your current location for the app to function properly, please set location services on in settings", "I understand", MessageBoxButton.OKCancel);
if (mRes == MessageBoxResult.OK)
{
Application.Current.Terminate();
}
if (mRes == MessageBoxResult.Cancel)
{
Application.Current.Terminate();
}
}
Geoposition position = await geolocator.GetGeopositionAsync();
Geocoordinate coordinate = position.Coordinate;
latitude = Convert.ToString(Math.Round(coordinate.Latitude, 2));
longitude = Convert.ToString(Math.Round(coordinate.Longitude, 2));
URL = "http://api.openweathermap.org/data/2.5/weather?lat=" + latitude + "&lon=" + longitude + "&units=metric";
Client(URL);
}
public void Client(string uri)
{
var clientToken = new WebClient();
clientToken.OpenReadCompleted += clientToken_OpenReadCompleted;
clientToken.OpenReadAsync(new Uri(uri));
}
오류가 Windows 개발자 센터에서 마이크로 소프트에 의해 기록 당신의 오류 스택 추적을 확인 발생하는 위치를