获取当前位置的地址Android应用 [英] Get current location address for android app

查看:128
本文介绍了获取当前位置的地址Android应用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我并不需要显示的地图。不过,我需要使用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. :)

推荐答案

有两个步骤如下:

  1. 获取当前位置 - 纬度和放大器;经度,使用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 /市场/地图就可以了。

这篇关于获取当前位置的地址Android应用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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