如何获取最近城市的名称
我有一些应用程序,可以时不时地向互联网发送一些信息,比如说白天的信息。我可以轻松发送一些坐标(使用 GPS 位置),但我不想要这样。 Android 手机始终通过 wifi 或移动网络连接到互联网。但并不总是启用 GPS。那么可以通过wifi或者移动网络获取位置吗?我用谷歌搜索这个东西,最终通过 GPS 找到位置,我不想这样做。
你能给我一些想法我能做什么吗?我见过一些网站,当我打开它们时,它们知道我在哪里,所以我想只需通过发出互联网请求并阅读响应或者使用某些服务就可以找到最近的城市名称。 。 。
谢谢
I have some app that sends some information to the internet from time to time let say ones at day. And I can easily send some coordinates (using the gps position) but I do not want that. The android phone is always connected to the internet via wifi or mobile network. But not always enabled the gps. So is it possible to get the location with wifi or mobile network ? I google this thing and I end up with finding location by gps, I do not want to do that.
Can you give me some ideas what can I do this. I have seen web sites that when I open them they know where am I, so I guess it is possible to find the nearest name of the city just by making a internet request and reading the response or maybe use some service . . .
Thanks
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
http://developer.android.com/reference/android/location/ package-summary.html
http://developer.android.com/reference/android/location/Address.html#getAddressLine(int)
getLocality 看起来它可以做你想做的事?
对于知道您所在位置的网站,他们要么使用您的源 IP 并进行查找(这对于很多事情来说不是很可靠),要么使用 javascript 地理定位 API,如下所述:
http://merged.ca/iphone/html5-geolocation
事实上,这是一个关于使用 google API 获取的堆栈溢出答案到城市name:
使用地理位置获取城市名称
http://developer.android.com/reference/android/location/package-summary.html
http://developer.android.com/reference/android/location/Address.html#getAddressLine(int)
getLocality looks like it may do what you want?
For websites that know where you are, they either use your source IP and look that up (which isn't very reliable for a lot of things), or they use the javascript geolocation APIs as described here:
http://merged.ca/iphone/html5-geolocation
In fact, here's a stack overflow answer on using google API to get to the city name:
Get city name using geolocation