Soru & Cevap

Android Konum Bilgisi (il, ilçe adı) ...

25.10.2017 - 03:15

Merhabalar, Bir android projesi için konum bilgisine ihtiyacım var. longitude ve latitude yani koordinatları çekebiliyorum ama koordinatların hangi il ve ilçeye ait olduğu bilgisini çekemedim. Bulunduğum konumun hangi il ve ilçe olduğunu verecek kodları paylaşmanızı rica ediyorum.

98 Görüntülenme

1 Cevap

Sitedeki sorulara cevap verebilmek için giriş yapın ya da üye olun.

picture-84564-1548924191.jpg
emrekaplan606
25.10.2017 - 09:02

Merhabalar,

Geocoder işinizi görecektir.

Geocoder geocoder;
List<Address> addresses;
geocoder = new Geocoder(this, Locale.getDefault());

addresses = geocoder.getFromLocation(latitude, longitude, 1); // Here 1 represent max location result to returned, by documents it recommended 1 to 5

String address = addresses.get(0).getAddressLine(0); // If any additional address line present than only, check with max available address lines by getMaxAddressLineIndex()
String city = addresses.get(0).getLocality();
String state = addresses.get(0).getAdminArea();
String country = addresses.get(0).getCountryName();
String postalCode = addresses.get(0).getPostalCode();
String knownName = addresses.get(0).getFeatureName();

kolay gelsin..