androidxamaringpsgeolocationilist

Xamarin Android: Ilist<Address> does not contain a definition for 'Any'


I'm trying obtain adrress from Location using this steps. I obtain correctly latitude and longitude, but I need specific address too. If exist other tutorial to obtain this.

http://developer.xamarin.com/recipes/android/os_device_resources/gps/get_current_device_location/

void InitializeLocationManager()
{
    _locationManager = (LocationManager)GetSystemService(LocationService);
    Criteria criteriaForLocationService = new Criteria
                                            {
                                                Accuracy = Accuracy.Fine
                                            };
    IList<string> acceptableLocationProviders = _locationManager.GetProviders(criteriaForLocationService, true);

    if (acceptableLocationProviders.Any())
    {
        _locationProvider = acceptableLocationProviders.First();
    }
    else
    {
        _locationProvider = String.Empty;
    }
}

In this code the errors are:

System.Collection.Generic.Ilist does not contain a definition for 'Any'


Solution

  • Add using System.Linq; to the top to the source file. Any() is an extension method to IEnumerable within the System.Linq namespace.