Sunday, 15 June 2014

java - How do you make an android application wait? -



java - How do you make an android application wait? -

i'm trying create pedometer application android using accelerometer gather data. gathered lot of raw info phone , found patterns constituted step gait , created 3 booleans model how 1 step accelerometer.

public boolean beforestep(float y) { if(y > 1.5 && y < 3){ homecoming true; } else { homecoming false; } } public boolean duringstep(float y) { if(y > 3 && y < 5){ homecoming true; } else { homecoming false; } } public boolean afterstep(float y) { if(y > 1.5 && y < 3){ homecoming true; } else { homecoming false; } } if(beforestep(accel)){ if(duringstep(accel)){ if(afterstep(accel)){ stepcount++; } } }

at first had run these booleans in onsensorchanged() method, realized meant pass same acceleration value 3 booleans, programme never recognize step. how create android wait, 10ms, between each boolean check acceleration value updates?

also, if there more accurate/efficient way go counting steps using raw acceleration data, please allow me know!

you store state in int , maintain track of part of step you're in (before = 1, during = 2, after = 3).

onsensorchanged(){ if(state == 1){ if(duringstep(accel)){ state = 2; ... return; } } else if(state == 2){ ... } }

java android

No comments:

Post a Comment