i need to count no of steps while walking. so that i am using accelerometer. in the above coding i get accelerometer sensor's x,y,z values. this is i have done so far. my problems is by the x,y,z how to count steps while walking?
i get the following code from the link
http://pedometer.googlecode.com/svn/trunk/src/name/bagi/levente/pedometer/Pedometer.java
my code:
import android.app.Activity;
import android.content.Context;
import android.os.Bundle;
import android.widget.TextView;
import android.widget.Toast;
public class Accelerometer extends Activity implements AccelerometerListener {
private static Context CONTEXT;
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
CONTEXT = this;
}
protected void onResume() {
super.onResume();
if (AccelerometerManager.isSupported()) {
AccelerometerManager.startListening(this);
}
}
protected void onDestroy() {
super.onDestroy();
if (AccelerometerManager.isListening()) {
AccelerometerManager.stopListening();
}
}
public static Context getContext() {
return CONTEXT;
}
/**
* onShake callback
*/
public void onShake(float force) {
Toast.makeText(this, "Phone shaked : " + force, 1000).show();
}
/**
* onAccelerationChanged callback
*/
public void onAccelerationChanged(float x, float y, float z) {
((TextView) findViewById(R.id.x)).setText(String.valueOf(x));
((TextView) findViewById(R.id.y)).setText(String.valueOf(y));
((TextView) findViewById(R.id.z)).setText(String.valueOf(z));
}
}
please help me.
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…