如何获取经度和纬度的Andr​​oid [英] How to Obtain Latitude and Longitude in Android

查看:135
本文介绍了如何获取经度和纬度的Andr​​oid的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何获取经纬度来自移动设备,如果GPS不可用......我的手机已经通过WiFi和GPRS连接互联网连接....我们可以得到背阔肌和长期的呢?

How to obtain Latitude and longitude from the mobile device if GPS is not available... My mobile has internet Connection through wifi and gprs connection.... Can we get the lats and long from this?

推荐答案

修改:<一href="http://stackoverflow.com/questions/3145089/what-is-the-simplest-and-most-robust-way-to-get-the-users-current-location-in-an">网络也提供GPS位置

是的,我们凸轮...试试这个

Yes we cam...try this

LocationManager manager = (LocationManager) Context.getSystemService(Context.LOCATION_SERVICE);
manager.getLastKnownLocation(LocationManager.NETWORK_PROVIDER);

// additionally (you have to implement LocationListener)
manager.requestLocationUpdates(LocationManager.NETWORK_PROVIDER, 0, 0.0f, new LocationListener() ...)

在位置,你可以使用LocationListener的...

After location you can use in locationlistener...

 @Override
    public void onLocationChanged(Location location) {                          
         Log.d("a","onLocationChanged: lat="+location.getLatitude());
         Log.d("a","onLocationChanged: lat="+location.getLongitude());                 
    }

希望它帮助。

hope it helps..

这篇关于如何获取经度和纬度的Andr​​oid的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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