java如何在Android中获取纬度和经度 1 年,4 月 Questions & Answers 3069 如果GPS不可用,如何从移动设备获取纬度和经度。。。我的手机通过wifi和gprs连接连接互联网。。。。我们能从中得到时间和长度吗
# 1 楼答案 编辑: Network and also GPS Provider Location 是的,我们可以。。。试试这个 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()); } 希望有帮助
# 2 楼答案 是的,你可以。看看documentation 当你从系统中找到一个位置时。您可以使用getLongitude()和getLatitude()方法 有关完整示例,请查看this code——第122-124行设置接收更新,第201-209行获取位置
# 1 楼答案
编辑: Network and also GPS Provider Location
是的,我们可以。。。试试这个
在locationlistener中可以使用的位置之后
希望有帮助
# 2 楼答案
是的,你可以。看看documentation
当你从系统中找到一个位置时。您可以使用getLongitude()和getLatitude()方法
有关完整示例,请查看this code——第122-124行设置接收更新,第201-209行获取位置