【发布时间】:2013-11-25 22:19:27
【问题描述】:
我正在编写 android 代码来获取当前位置并将 lat、long 转换为地址,但我得到了错误的结果,
问题出在这里:
locationManager = (LocationManager) getSystemService(Context.LOCATION_SERVICE);
// Define the criteria how to select the locatioin provider -> use
// default
Criteria criteria = new Criteria();
provider = locationManager.getBestProvider(criteria, false);
Location location = locationManager.getLastKnownLocation(provider);
// Initialize the location fields
if (location != null) {
System.out.println("Provider " + provider + " has been selected.");
onLocationChanged(location);
Log.d("msgh","msgh");
} else {
System.out.println("location not available");
Log.d("msg","msg");
}
代码总是进入else语句
【问题讨论】:
标签: android