[英]How to Obtain Latitude and Longitude in Android
如果无法使用GPS,如何从移动设备获取纬度和经度...我的手机通过wifi和gprs连接建立了互联网连接。...我们可以从中获取经度和纬度吗?
编辑 : 网络以及GPS提供商位置
是的,我们...尝试这个
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中使用...
@Override
public void onLocationChanged(Location location) {
Log.d("a","onLocationChanged: lat="+location.getLatitude());
Log.d("a","onLocationChanged: lat="+location.getLongitude());
}
希望能帮助到你..
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.