在这种情况下,我使用 GPS 作为提供程序,我尝试在建筑物内走动,但似乎找不到位置。是的,在建筑物中 GPS 不起作用是有道理的。那么,为什么 isProviderEnabled 返回 true?无论如何,我应该以什么方式实现“搜索 GPS 信号”?
String context = Context.LOCATION_SERVICE;
locman = (LocationManager)getSystemService(context);
Criteria criteria = new Criteria();
criteria.setAccuracy(Criteria.ACCURACY_FINE);
criteria.setAltitudeRequired(false);
criteria.setBearingRequired(false);
criteria.setPowerRequirement(Criteria.POWER_LOW);
String provider = locman.getBestProvider(criteria, true);
if (locman.isProviderEnabled( LocationManager.GPS_PROVIDER )) {
// Change from 'Searching for GPS signal to Use GPS'
txtGPS.setText("Use GPS");
}
locman.requestLocationUpdates(
provider,MIN_TIME, MIN_DISTANCE, locationListener);