如何获得在android的当前位置的拉链code或区域code? [英] How to get zip code or area code of the current location in android?

查看:119
本文介绍了如何获得在android的当前位置的拉链code或区域code?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想获得当前位置的Andr​​oid设备的zip code我的应用程序,任何例子或者说片段上定位了。我试图地理codeR它给纬度和放大器;多头只。

I would like to get the zip code of the current location in android device for my app,any example or snippet on locating it. I have tried geocoder it gives lat & long position only.

推荐答案

您显然不使用它的权利,然后...

You are clearly not using it right then...

Geocoder geocoder = new Geocoder(this, Locale.getDefault());
// lat,lng, your current location
List<Address> addresses = geocoder.getFromLocation(lat, lng, 1); 

现在的地址列表包含最接近的已知领域。该地址对象具有 getPostal code()功能。抓斗的第一个对象,并发现它是邮政code。

Now the list of Address contains the closest known areas. The Address object has the getPostalCode() function. Grab the first object and find it's Postal code.

你去那里。

这篇关于如何获得在android的当前位置的拉链code或区域code?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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