Android : Displaying the averaged values of the speedometer android

on Saturday, April 18, 2015


I have written a code for a speedometer in eclipse. It is working fine. I am trying to display the averaged values of the speed that the speedometer is measuring and while i try to do that i am failing because i am not finding the right approach on how to do it.


Here is my code:



LocationManager lm = (LocationManager) this
.getSystemService(Context.LOCATION_SERVICE);
lm.requestLocationUpdates(LocationManager.GPS_PROVIDER, 0, 0, this);

this.onLocationChanged(null);

}

@Override
public void onLocationChanged(Location location) {
TextView tv = (TextView) findViewById(R.id.textView1);


if (location == null) {

tv.setText("0.0");
} else {

float nCurrentSpeed = location.getSpeed();
tv.setText(nCurrentSpeed + "");


}

}


How can i do it? Thanks in advance.


0 comments:

Post a Comment