calculate accurate distance of user using android accelerometer
<p>I am trying to develop an Android application to calculate accurate distances covered by a user using the devices accelerometer.</p>

<p>I have two vectors in each 5 seconds, one contains the acceleration values and the other contains the timeStamp.</p>

<p>First, I calculate the cumulative for acceleration values which represent the speed and I calculate distance as below:</p>

<pre><code>float calcDistance(Vector&lt;Float&gt; samples, Vector&lt;Float&gt; times) {
    float distance = 0;
    for (int i = 1; i &lt; samples.size(); i++)
   samples.set(i, samples.get(i) + samples.get(i - 1));
    for (int i = 0; i &lt; samples.size() - 1; i++)
   distance += samples.get(i) * (times.get(i + 1) - times.get(i));
return distance;
 }
</code></pre>

<p>But it's not giving accurate distances. Is there any way to calculate accurate distance?  </p>
