14

Is there any documentation around Android 4.4 KitKat's (well specifically Nexus 5 for now) step detector and counter APIs? I tried to search a lot but did not find anything.

I am planning to try my hands on these new concepts and want to use the API but there's nothing around it on the Internet.

Manfred Moser
  • 29,539
  • 13
  • 92
  • 123
Harshad Kale
  • 17,446
  • 7
  • 30
  • 44

2 Answers2

17

I found an example for you, hope it helps in someway, the sensor explanation on the API page is pretty straight forward too..

API Page: http://developer.android.com/about/versions/android-4.4.html#UserInput

Blog Post: http://theelfismike.wordpress.com/2013/11/10/android-4-4-kitkat-step-detector-code/ Github Project referenced in the blog: https://github.com/theelfismike/android-step-counter

Rejinderi
  • 11,694
  • 2
  • 31
  • 40
  • 2
    I have been looking into this too. One thing i am still unclear on is whether its a piece of hardware or rather an algorithm applied to the accelerometer? Some links refer to it as only being available in Nexus 5 but the documentation makes it sound like it would be available to any device running kitkat that has an accelerometer – erik Jun 23 '14 at 17:16
  • It's a piece of hardware. The API is there on all KitKat devices, but you'll need to check if the device in question actually has a stepcount sensor. – edovino Jul 28 '14 at 19:14
  • I found out the accuracy to be very questionable; if you simply shake the phone, it registers it as a step. The Google sample app is not better than this simple app at the fact that it suffers from the same accuracy issues. – The_Martian Aug 24 '19 at 22:32
3

Official example

In Android SDK 23 under samples/android-23/sensors/BatchStepSensor, run with:

./gradlew clean
./gradlew assembleDebug
./gradlew installDebug

Then turn on the app, enable one of the step sensors, and walk around with your phone to see the counter increment.

Source at: https://github.com/googlesamples/android-BatchStepSensor

Ciro Santilli OurBigBook.com
  • 347,512
  • 102
  • 1,199
  • 985