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

Geo location is not working in xamarin android

$
0
0

Hi everyone, I am try to get the current geo location of the phone using 'plugin.geolocator' but it works fine in ios in android getting task cancellation exception. Here is the code I have tried. Please suggest any idea why I am getting this exception.

sample code:

            var locator = CrossGeolocator.Current;
            locator.DesiredAccuracy = -1;

            if (locator.IsGeolocationEnabled)
            {
                var position = await locator.GetPositionAsync(TimeSpan.FromMilliseconds(5000));
            }

These are the permissions I have gave in android manifest file.

     <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />

I am getting task cancellation exception while I am testing in emulator. I have tried with changing time span but no luck getting task cancellation exception only.


Viewing all articles
Browse latest Browse all 77050

Trending Articles



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