手机
当前位置:查字典教程网 >编程开发 >安卓软件开发 >android通过Location API显示地址信息的实现方法
android通过Location API显示地址信息的实现方法
摘要:本文实例讲述了android通过LocationAPI显示地址信息的实现方法。分享给大家供大家参考。具体如下:android的Locatin...

本文实例讲述了android通过Location API显示地址信息的实现方法。分享给大家供大家参考。具体如下:

android的Locatin API,可以通过Geocoder类,显示具体经纬度的地址信息。如:

通过Geocoder的方法getFromLocation()可以得到Address对象的List。我只取一个Address结果,可以取多个,但是意义不大。

StringBuilder builder = new StringBuilder(); builder.append("北纬:").append(this.location.getLatitude()).append("n"); builder.append("东经:").append(this.location.getLongitude()).append("n"); try { List<Address> addresses = new Geocoder(this).getFromLocation( this.location.getLatitude(), this.location.getLongitude(), 3); if (addresses.size() > 0) { Address address = addresses.get(0); // for (Address address : addresses) { for (int i = 0; i < address.getMaxAddressLineIndex(); i++) { builder.append(address.getAddressLine(i)).append("n"); // builder.append(address.getLocality()).append("n"); // builder.append(address.getPostalCode()).append("n"); // builder.append(address.getCountryName()); } // } }

运行效果如下图所示:

android通过Location API显示地址信息的实现方法1

希望本文所述对大家的Android程序设计有所帮助。

【android通过Location API显示地址信息的实现方法】相关文章:

Android中使用Toast.cancel()方法优化toast内容显示的解决方法

android RadioGroup的使用方法

android 加载本地联系人实现方法

Android 网络图片查看显示的实现方法

android为按钮添加事件的三种方法

android全屏去掉title栏的多种实现方法

Android中使用Gson解析JSON数据的两种方法

Android 自定义标题栏 显示网页加载进度的方法实例

android开发中获取手机分辨率大小的方法

Android Intent启动别的应用实现方法

精品推荐
分类导航