我在使用 Location Api 时遇到问题。我正在尝试使用以下代码从任何可用的提供商获取位置:
//Définir ma localisation
final LocationManager manag = (LocationManager) ActivityRechercheConcession.this.getSystemService(Context.LOCATION_SERVICE);
//Choix du service de localisation en fonction de critères
Criteria crit = new Criteria();
crit.setCostAllowed(false);
crit.setAccuracy(1000); //précis à au moins 1km pret
final String choix_source = manag.getBestProvider(crit, true);
//demander la position courante
manag.requestLocationUpdates(choix_source, 10000, 0, new LocationListener(){
//Lors de la capture de la position
public void onLocationChanged(Location location) {
Log.i("LocationListener","New position from "+choix_source+": ("+location.getLatitude()+","+location.getLongitude()+")");
}
}
但是当我使用模拟器控件发送坐标时(如 long:7.745304,lat:48.589326),我只得到位置数据中的整数部分(如 long 7.0,lat 48.0)所以这些值的计算方法是完全错误的.
为什么我会丢失这些数据的小数部分?