Android通过Location获取Address的使用!
A大家好,上一节我讲了一下如何通过LocationManager来获取Location,没有看过上一节的同学,可以点击如下链接返回查看: Android 高手进阶教程十四之—Android Location的使用! 我们获取Location的目的之一肯定是有获取这个位置的详细地址,而我们有了Location在来获取Address就相对简单多了,因为 GoogleApi已经封装好了方法,我们只需呀通过Location获取GeoPoint,然后在通过GeoPoint来获取我们想要的 Address.下面是我做的一个简单的Demo. 第一步新建一个Android工程LocationDemo,注意这里选用的是(Google APIs),下面是文件目录结构: 第二步: 修改main.xml(相比第十四节增加了一个address的TextView),代码如下: ?View Code XML<?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:orientation="vertical" android:layout_width="fill_parent" android:layout_height="fill_parent" > <TextView android:id="@+id/longitude" android:layout_width="fill_parent" android:layout_height="wrap_content" android:text="longitude:" /> <TextView android:id="@+id/latitude" android:layout_width="fill_parent" android:layout_height="wrap_content" android:text="latitude:" /> <TextView android:id="@+id/address" android:layout_width="fill_parent" android:layout_height="wrap_content" /> </LinearLayout> 第三步:修改LocationDemo.java(增加了两个方法)代码如下: ?View Code JAVApackage com.android.tutor; import java.util.List; import java.util.Locale; import com.google.android.maps.GeoPoint; import [...]