【发布时间】:2014-10-24 13:04:22
【问题描述】:
我需要使用 gps 计算当前位置到给定位置之间的时间和距离。
哪位大侠给点意见
final TextView speedView = (TextView) findViewById(R.id.speedtxt);
locationManager = (LocationManager) getSystemService(Context.LOCATION_SERVICE);
locationListener = new LocationListener() {
public void onLocationChanged(Location location) {
if (location.hasSpeed()) {
float speed = location.getSpeed() * 3.6f;// km/h
speedView.setText(String.format("%.0f km/h", speed));
}
}
public void onProviderDisabled(String provider) {
}
public void onProviderEnabled(String provider) {
}
public void onStatusChanged(String provider, int status, Bundle extras) {
}
};
【问题讨论】:
标签: android gps geolocation