如何获得当前位置(经度和纬度)中采用了Android图形页面模拟器? [英] How to get current location (latitude and longitude) in emulator using Android mapview?

查看:126
本文介绍了如何获得当前位置(经度和纬度)中采用了Android图形页面模拟器?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想创建一个图形页面应用程序,它显示了我的当前位置的经度和纬度。得到的当前位置之后,得到的位置的名称。任何帮助吗?

I want to create a MapView application which shows my current location's latitude and longitude. After getting the current location, get the name of the location. Any help please?

推荐答案

与Android其实是pretty的方便,以获得从GPS服务的位置。使用 LocationManager 最简单的方法来做到这一点。

With android it is actually pretty easy in order to get the location from the GPS Service. Use the LocationManager the easiest way to do it

locationManager = (LocationManager)getSystemService(Context.LOCATION_SERVICE);

customLocationListener = new CustomLocationListener();

locationManager.requestLocationUpdates(
        LocationManager.GPS_PROVIDER,
        0,
        0,
        ll);

.....一个Spagehtti code GOES HERE .....

.....A Spagehtti CODE GOES HERE.....

class CustomLocationListener implements LocationListener{ ............
      public void onLocationChanged(Location argLocation) { 
         if(location != null) {     
        int latitude=(int)(argLocation.getLatitude()*1E6);
        int longitude=(int)(argLocation.getLongitude()*1E6);
              }
       } ........ }

也可以检查位置的Andr​​oid API 和的 Android的发展

这篇关于如何获得当前位置(经度和纬度)中采用了Android图形页面模拟器?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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