Step Counter App With Android KitKat 4.4

Today I will write a simple app for you that utilizes the step counter. This is a sample app same like the pedometer app which will register the sensor events when it starts, and update the UI with the latest step count whenever a new event is detected by the app.

The code will specify SensorManager.SENSOR_DELAY_NORMAL as the update frequency.

I will be using TYPE_STEP_COUNTER Sensor, which dispatches an event with the total number of steps periodically when a new step is detected.

Make sure that You must check the code on a Nexus 5 running KitKat, because this API was added in KitKat and the Nexus 5 is the first device to ship with a dedicated low-power step detecting chip.

Now follow the steps below to implement the step detecting app.

Step1) Create a new androject in your android IDE.

Step2)  Write following code into main layout file:

 

 

 

Step3) Write following code into your main java file

 

 

 

Note

Run this app on a device supporting android 4.4 or higher version and you will see the counter increasing with every step you reach.

step1

Leave a Comment: