I`m Trying to get city name in an application. Just like if the GPS shows New York so the place should set inside an text view as new York and if the GPS shows location as India so the text view should show as India
Asked
Active
Viewed 79 times
-3
-
Have a look at Geocoder: https://developer.android.com/reference/android/location/Geocoder.html Of course, first you will need the geoposition. – adalpari Jul 15 '16 at 12:43
-
It does not shows any code – Ashwani Sharma Jul 15 '16 at 12:50
-
visit this https://developer.android.com/training/location/display-address.html – Bharatesh Jul 15 '16 at 13:17
1 Answers
0
Try this code:
Geocoder geocoder;
List<Address> addresses;
geocoder = new Geocoder(this, Locale.getDefault());
addresses = geocoder.getFromLocation(latitude, longitude, 1);
String city = addresses.get(0).getLocality();

Manish
- 353
- 2
- 18
-
-
-
-
follow this link to get lat long http://stackoverflow.com/questions/36622586/show-my-current-location-in-the-google-map/36623078#36623078 – Manish Jul 15 '16 at 12:53
-
you havent understand my question.. i dont want to open map... Just like an fake gps we can set fake location through an app.. so if we set india from that app so that in my application if i search for it then it should automatically fetch india from that – Ashwani Sharma Jul 15 '16 at 13:04