我怎样才能得到当前城市名的Andr​​oid? [英] How can i get the current city name in android?

查看:128
本文介绍了我怎样才能得到当前城市名的Andr​​oid?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要获取用户当前所在的城市名称。 如果让这个城市的名字与AGPS或任何东西是好的。 我需要的方法或code获取当前城市的android。 请分享,如果你知道了。

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.

推荐答案

这一个是从当前的纬度越来越位置名称,长

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());

这篇关于我怎样才能得到当前城市名的Andr​​oid?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆