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);
展开
 我来答
匿名用户
2012-04-20
展开全部
你是用手机还是用模拟器? 模拟器要去申请一个key才能用
推荐律师服务: 若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询

为你推荐:

下载百度知道APP,抢鲜体验
使用百度知道APP,立即抢鲜体验。你的手机镜头里或许有别人想知道的答案。
扫描二维码下载
×

类别

我们会通过消息、邮箱等方式尽快将举报结果通知您。

说明

0/200

提交
取消

辅 助

模 式