少し問題があります。location.getSpeed()メソッド上にメソッドを配置しましたがonLocationChanged()、.getSpeed()通常、同じ場所にいると 0km/h に更新/変更されません。
location.getGpeed()その場にとどまっているときに更新が 0km/h を示した方法はどこにありますか?
そして別の質問です。これは私のlocationListenerです:
private final LocationListener locationListener = new LocationListener()
{public void onLocationChanged(Location location) {
boolean var = false;
float distance;
if (firstRun) { distance=0; firstRun=false; }
else
distance = location.distanceTo (startLocation);
Tspeed.setText("0km/h");
if (location.getSpeed()!=0)
{
Tspeed.setText(""+(location.getSpeed()*3600/1000 +"km/h"));
}
else
{
Tspeed.setText("0km/h");
}
sAllDistance += distance; //
startLocation=location;
Tdistance.setText(""+(int)SAllDistance+" m");
}
問題はLocationManager、修正を取得したとき、最初AllDistanceに返されるのlocation.distanceTo()が ±50 メートルであることです。
どうすれば修正できますか?