Android 通过LocationManager 怎么获取不到经纬度 代码如下,请高手指点 LocationManager locationManager;
LocationManagerlocationManager;StringserviceName=this.LOCATION_SERVICE;locationManage...
LocationManager locationManager;
String serviceName = this.LOCATION_SERVICE;
locationManager = (LocationManager) getSystemService(serviceName);
Criteria criteria = new Criteria();
criteria.setAccuracy(Criteria.ACCURACY_FINE);
criteria.setAltitudeRequired(false);
criteria.setBearingRequired(false);
criteria.setCostAllowed(true);
criteria.setPowerRequirement(Criteria.POWER_LOW);
String provider = locationManager.getBestProvider(criteria, true);
Location location = null; locationManager.getLastKnownLocation(provider);
ProgressDialog dialog = ProgressDialog.show(this, "Loading...", "Please wait...", true, false);
while(location == null){
location = locationManager.getLastKnownLocation(provider);
}
dialog.dismiss();
updateWithNewLocation(location);
locationManager.requestLocationUpdates(provider, 2000, 10, locationListener); 展开
String serviceName = this.LOCATION_SERVICE;
locationManager = (LocationManager) getSystemService(serviceName);
Criteria criteria = new Criteria();
criteria.setAccuracy(Criteria.ACCURACY_FINE);
criteria.setAltitudeRequired(false);
criteria.setBearingRequired(false);
criteria.setCostAllowed(true);
criteria.setPowerRequirement(Criteria.POWER_LOW);
String provider = locationManager.getBestProvider(criteria, true);
Location location = null; locationManager.getLastKnownLocation(provider);
ProgressDialog dialog = ProgressDialog.show(this, "Loading...", "Please wait...", true, false);
while(location == null){
location = locationManager.getLastKnownLocation(provider);
}
dialog.dismiss();
updateWithNewLocation(location);
locationManager.requestLocationUpdates(provider, 2000, 10, locationListener); 展开
1个回答
2012-04-20
展开全部
你是用手机还是用模拟器? 模拟器要去申请一个key才能用
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询