How to use Accelerometer to measure distance for Android Application Development
You get position by integrating the linear acceleration twice but the error is horrible. It is useless in practice.
Here is an explanation why (Google Tech Talk) at 23:20. I highly recommend this video.
Similar questions:
track small movements of iphone with no GPS
What is the real world accuracy of phone accelerometers when used for positioning?
how to calculate phone's movement in the vertical direction from rest?
iOS: Movement Precision in 3D Space
measure distance without network
It is not possible: due to the low sensitivity of the built-in accelerometers and the so weak accelerations that are created when a person walks.
Not having network does not mean that GPS does not work ...
how to calculate distance while walking in android?
One way to go about it is using the accelerometer data. Your app should continuously record the accelerometer data after the user presses the Start button. You will observe a peak in your data whenever the user takes a step. Apply a filter on this data, and you shall be able to detect the number of steps taken with reasonable accuracy. Multiply it by the step length and you should get an approximation of the distance travelled. Take height of the user as an input argument. Step length is around 0.45*Height of a person. Since this approach is independent of GPS, It will also work indoors.
EDIT:
You'll need to use the accelerometer values for all three axes to make it fairly independent of the device orientation.You can go with x^2 + y^2 + z^2
how to calculate phone's movement in the vertical direction from rest?
If you integrate the acceleration twice you get position but the error is horrible. It is useless in practice. Here is an explanation why (Google Tech Talk) at 23:20. I highly recommend this video.
Now, you do not need anything accurate and that is a different story. The linear acceleration is available after sensor fusion, as described in the video. See Sensor.TYPE_LINEAR_ACCELERATION
at SensorEvent. I would first try a high-pass filter to detect sudden increase in the linear acceleration along the vertical axis.
I have no idea whether it is good for your application.
calculate accumulated distance using GPS in android
The Google Distance Matrix API
Can't take credit for the answer, I got it from Another post
Related Topics
Textwatcher for More Than One Edittext
How to Rename the Android Package Name
Navigation Drawer: How to Set the Selected Item at Startup
Alert Dialog from Android Service
Android Eclipse Ddms - Can't Access Data/Data/ on Phone to Pull Files
Java.Lang.Noclassdeffounderror: Javax.Activation.Datahandler in Android
Use Tab with New Toolbar (Appcompat V7-21)
How to Call a Method in Another Activity from Activity
Android: Using Linear Gradient as Background Looks Banded
Location Service Gps Force Closed
Android - How to Download a File from a Webserver
Install an APK File from Command Prompt
How to Use Assert on Android Devices
Display Back Button on Action Bar
How to Programmatically Scroll a Scroll View to a Specific Edit Text