我有以下代码:
private LocationManager _locMgr;
public static String speed_1;
public static String speed_2;
public static String speed_3;
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
_locMgr = (LocationManager) getSystemService(Context.LOCATION_SERVICE);
_locMgr.requestLocationUpdates(LocationManager.GPS_PROVIDER, 2000, 2, this);
}
public void onLocationChanged(Location location) {
speed_1 = String.valueOf(location.getSpeed());
Thread.sleep(1500);//delay
speed_2 = String.valueOf(location.getSpeed()));
Thread.sleep(1500);
speed_3 = String.valueOf(location.getSpeed()));
//then viewing the three different speeds
}
问题是,当我查看三种速度时,我得到它们都一样,我需要在onLocationChanged()方法的当前调用中获得3种不同的速度
请帮忙。