[英]How to Obtain Latitude and Longitude in Android
如果无法使用GPS,如何从移动设备获取纬度和经度...我的手机通过wifi和gprs连接建立了互联网连接。...我们可以从中获取经度和纬度吗?
edited : Network and also GPS Provider Location 编辑 : 网络以及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() ...)
After location you can use in locationlistener... 定位后,您可以在locationlistener中使用...
@Override
public void onLocationChanged(Location location) {
Log.d("a","onLocationChanged: lat="+location.getLatitude());
Log.d("a","onLocationChanged: lat="+location.getLongitude());
}
hope it helps.. 希望能帮助到你..
Yes you can. 是的你可以。 Have a look at the documentation 看一下文档
When you have a Location from the system. 从系统中获得位置时。 you can use methods getLongitude() and getLatitude() 您可以使用方法getLongitude()和getLatitude()
For a full example have a look at this code - lines 122-124 to set up receiving updates and lines 201-209 to get the Location. 对于完整的示例,请查看以下代码 -设置接收更新的第122-124行和获取位置的第201-209行。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.