Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can i get the current city name in android?

Tags:

android

maps

gps

I need to get the user current city name. If getting the city name with AGPS or anything is good. I need the method or code for getting the current city in android. Please share if you know.

like image 888
arnp Avatar asked Nov 29 '22 03:11

arnp


1 Answers

This one is for getting location name from current lat,long

Geocoder gcd = new Geocoder(context, Locale.getDefault());
List<Address> addresses = gcd.getFromLocation(lat, lng, 1);
if (addresses.size() > 0) 
    System.out.println(addresses.get(0).getLocality());
like image 68
user370305 Avatar answered Dec 04 '22 08:12

user370305