Quantcast
Channel: Xamarin.Forms — Xamarin Community Forums
Viewing all articles
Browse latest Browse all 77050

Xamarin.Forms - how can I get geo coordinates ?

$
0
0

I am trying to get current coordinates directly in Xamarin.Forms app in button click handler:
` LocationManager LocMgr = Android.App.Application.Context.GetSystemService("location") as LocationManager;
var locationCriteria = new Criteria();

        locationCriteria.Accuracy = Accuracy.High;
        locationCriteria.PowerRequirement = Power.High;
        var locationProvider = LocMgr.GetBestProvider(locationCriteria, true);
        var lastLocation = LocMgr.GetLastKnownLocation(locationProvider);

`

But it throws TimeoutException at locationCriteria.Accuracy = Accuracy.High. What am I doing wrong with my code and how to do this in a correct way?


Viewing all articles
Browse latest Browse all 77050

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>