I develop a new application in android studio. I want to find user's city. I tried with Geocoder but some times it returns null. Is there any way that i can find user's city? I already know his latitude and longitude
Asked
Active
Viewed 249 times
0
-
Are you in an online state? If so - https://stackoverflow.com/questions/10913870/get-city-name-from-gps-co-ordinates – Kingsley Jan 07 '19 at 21:35
1 Answers
1
If you know the lat and long, you can do this.
https://developers.google.com/maps/documentation/geocoding/start?csw=1#ReverseGeocoding
You will use this API like so... you would have have to parse out the JSON http://maps.googleapis.com/maps/api/geocode/json?latlng=LAT,LONG&key=ENTER_API_KEY

letsCode
- 2,774
- 1
- 13
- 37
-
I have already found this api BUT it returns me a large json file with huge information in "results" array. I just want the city name and this will be a very time consuming solution i thing.. – kostas poimenidhs Jan 07 '19 at 21:28
-
"i think". do you expect there to be a soution that says, 23424,423424 = new york new york? the time to call this or ANY api would be similar. the time to parse an array would be more time consuming. but I bet you would have a response back within a second – letsCode Jan 07 '19 at 21:29
-
yes but user will download the entire file every time only to find just a name. Thank you for your respond! I am just looking for a better solution for my problem if it exists (not only an api). – kostas poimenidhs Jan 07 '19 at 21:42
-
My app works only with user's city... So user should download the api every time that he opens the app with his gps. – kostas poimenidhs Jan 08 '19 at 09:22
-
-
i can't because i have low reputation :P. It will help me your thumbs up though. :) – kostas poimenidhs Jan 10 '19 at 16:13
-