How do you make an android application wait?
<p>I'm trying to make a pedometer application with Android using only the accelerometer to gather data. I gathered a lot of raw data from the phone and found certain patterns to constituted a step from my gait and created 3 booleans to model how one step would look like to an accelerometer.</p>

<pre><code>public boolean beforeStep(float y)
    {
        if(y &gt; 1.5 &amp;&amp; y &lt; 3){
        return true;
    }
        else
        {
        return false;
        }
    }

public boolean duringStep(float y)
{
    if(y &gt; 3 &amp;&amp; y &lt; 5){
        return true;
    }
    else
    {
        return false;
    }
}

public boolean afterStep(float y)
{
    if(y &gt; 1.5 &amp;&amp; y &lt; 3){
        return true;
    }
    else
    {
        return false;
    }
}

if(beforeStep(accel)){
    if(duringStep(accel)){
        if(afterStep(accel)){
            stepCount++;
        }
    }
}
</code></pre>

<p>At first I had run these booleans in my onSensorChanged() method, but I realized that this meant that it would pass the same acceleration value to all three booleans, so the program would never recognize a step. How do I make Android wait, say 10ms, between each boolean check so that the acceleration value updates?</p>

<p>Also, if there is a more accurate/efficient way to go about counting steps using raw acceleration data, please let me know!</p>
