获取当前位置的地址Android应用当前位置、地址、Android

由网友(-゛小浩村一郎)分享简介:我并不需要显示的地图。不过,我需要使用GPS / 3G网络来定位我现在的位置地址(不长,土地增值税),这将被添加到一个自动短信应答,以通知的人,我现在着回答,和放大器;在包括我的当前位置的字符串地址。我有SMS的东西的工作,只需要搞清楚访问GPS和拉动地址的方法。我所看到的样品code为纬度/长。也许我需要转换纬度/...

我并不需要显示的地图。不过,我需要使用GPS / 3G网络来定位我现在的位置地址(不长,土地增值税),这将被添加到一个自动短信应答,以通知的人,我现在着回答,和放大器;在包括我的当前位置的字符串地址。 我有SMS的东西的工作,只需要搞清楚访问GPS和拉动地址的方法。我所看到的样品code为纬度/长。也许我需要转换纬度/经度到谷歌地图API中的地址?我不确定HOWTO去做。 任何意见/ code片段/类似的教程欢迎! 谢谢。 :)

I do not need to display a map. However, I need to use the gps/3g network to locate my current positions ADDRESS (not long and lat) this will then be added to a automated sms response to inform a person that I currently cant reply, & the include the string address of my current location. I have the sms stuff working, just need to figure out a method of accessing the gps and pulling an address. I have seen sample code for lat/long. Perhaps I need to convert lat/long into an address within the google maps API? I am unsure howto go about it. Any advice/code snippets/similar tutorials welcome! Thanks. :)

推荐答案

有两个步骤如下:

获取当前位置 - 纬度和放大器;经度,使用GPS,网络,最后已知位置等而Android 位置文档包括样品code。

使用了Android 地理codeR类以请求查找转换的纬度/长的地址(从中可以方便地提取城市,乡村,街道等)。具体来说,您需要使用getFromLocation()方法

Use the Android Geocoder class to request a lookup to convert the lat/long to an Address (from which you can easily extract city, country, street, etc). Specifically, you need to use the getFromLocation() method

请注意:

的getFromLocation()方法返回一个匹配的设置。在某些情况下,你可以向用户显示一组(如5),并让他们选择最好的一个,也可以只使用第一种,假设它是最好的。 请记住,这两个调用所花费的时间。全球定位系统/网络可能需要一段时间,以提供一个位置。同样,调用getFromLocation()可能需要一段时间,因为它会在网络上的谷歌地图API。因此,你使用大量的错误处理的各种情况,而这两个电话被移动到一个单独的线程,这样你就不会锁定应用程序的用户界面(考虑AsyncTask的)这是关键 在地缘codeR类后端只有在谷歌批准的设备present。因此,查找将基本上在任何设备上失败,它没有Gmail /市场/地图就可以了。
阅读全文

相关推荐

最新文章