[英]How can i get current location in my android app using GPS..?
I want to create an app to get a user location like city name, country, etc. .I want to city name by current location but I have latitude and longitude.我想创建一个应用程序来获取用户位置,如城市名称、国家等。我想按当前位置命名城市,但我有纬度和经度。 how to get it?如何得到它?
Geocoder geocoder = new Geocoder(this, Locale.getDefault());
List<Address> addresses = geocoder.getFromLocation(MyLat, MyLong, 1);
String cityName = addresses.get(0).getAddressLine(0);
String stateName = addresses.get(0).getAddressLine(1);
String countryName = addresses.get(0).getAddressLine(2);
replace MyLat,My Long with your lat long用你的 lat long 替换 MyLat,My Long
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.