Steve use the code in this app,
You dont want to use the shake event, you want to use the xyz values , the event fires much faster so this is good for response.
The trick is when your feet hit the ground and you push your body upwards you send a force slighly higher than the force of gravity (9.8m/s/s) through your phone, ( I've called this the initial_force_trigger_
and conversely before your next foot hits the ground your body falls slightly as it moves forward ( especially when running) , the forces become slightly lower than the force of gravity. ( I've called this relief force trigger)
because the accelerometer changed event fires almost continuously we need to filer out the values so that it responds to the initial_trigger_force ( i set this to 10.8 but you can play with it) , the force needs to reach at least this value in order to set the variable allow to true, which then means it can ( in my case iterate a counter and play a sound but you can modify this to record the gps etc) , then it's important it does not keep doing it, so we ignore all future readings until we see the relief_force trigger reach as low as 8 m/s/s. After this point, the next time we see a value greater than 10.8 again, ( which will be when my foot hits the ground) it fires again.
This means that if I was to have a long duration force greater than 9.8 it would not fire repeatedly, eg if I was walking up a set of stairs.
I also make sure that the interval between 2 reading is not less than 100ms, thats 10 steps a second, again you could play with that value.
The playsound procedure runs when your feet push into the ground and the forces through the phone increase, you could use this to count steps, capture the gps lat,lng or do what ever you wish.
Hope this helps you