I am new to Xamarin. I want to take a photo and write to console the latitude and longitude, where the photo was taken. I'm trying to get it with the following code:
var exif = new ExifInterface(picUri.Path);
var latLong = new float[2];
float? lat = null, lng = null;
if (exif.GetLatLong(latLong))
{
lat = latLong[0];
lng = latLong[1];
}
if(lat != null && lng != null)
{
Console.WriteLine("Latitue {0}, Longitude {1} ", lat, lng);
}
else
{
Console.WriteLine("Some value is equals to null");
}
And I've got Some value is equals to null
in the console. What am i missing?
You need to add also
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
<uses-permission android:name="android.permission.INTERNET" />
in the manifest
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.