Created
February 25, 2014 11:45
-
-
Save guilhermecarvalhocarneiro/9207435 to your computer and use it in GitHub Desktop.
Chamando método Async no OnNavegatedTo
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
protected override async void OnNavigatedTo(NavigationEventArgs e) | |
{ | |
LoadCity(); | |
await StartGeoLocation(); | |
base.OnNavigatedTo(e); | |
} | |
private async Task StartGeoLocation() | |
{ | |
try | |
{ | |
City city = new City(); | |
if (city.GetCurrencyCity() == null) | |
{ | |
//TODO Preciso verificar o load da localizacao | |
Geolocator geolocator = new Geolocator(); | |
//geolocator.DesiredAccuracyInMeters = 50; | |
geolocator.DesiredAccuracy = PositionAccuracy.High; | |
Geoposition geoposition = await geolocator.GetGeopositionAsync( | |
maximumAge: TimeSpan.FromMinutes(5), | |
timeout: TimeSpan.FromSeconds(10) | |
); | |
SetCurrentLocation(geoposition.Coordinate.Latitude, geoposition.Coordinate.Longitude); | |
} | |
} | |
catch (Exception ErroStartLocation) | |
{ | |
System.Diagnostics.Debug.WriteLine("Error load"); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment