Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我正在尝试在应用程序中获取城市名称。就像如果 GPS 显示纽约,那么这个地方应该在文本视图中设置为纽约,如果 GPS 显示位置为印度,那么文本视图应该显示为印度
试试这个代码:
Geocoder geocoder; List<Address> addresses; geocoder = new Geocoder(this, Locale.getDefault()); addresses = geocoder.getFromLocation(latitude, longitude, 1); String city = addresses.get(0).getLocality();