A pedometer on a smartphone is not only a fashionable fitness gadget, but also a useful tool for tracking activity, monitoring health and motivating movement. Modern Android devices equipped with built-in sensors (accelerometer, gyroscope, low-power pedometer), which allow you to count steps with high accuracy. However, not all manufacturers enable this feature by default, and standard applications are often limited in capabilities.
In this article we will look all ways to create a pedometer on Android from using ready-made applications to writing your own code from scratch. You will learn how to configure the built-in step counter, which apps offer advanced analytics, and how to develop a unique solution using Android SDK i Google Fit API. We will pay special attention to the issues of accuracy, power consumption and compatibility with different versions Android (from 8.0 Oreo to 15).
1. Built-in pedometer in Android: how to enable and configure
Many users do not suspect that their smartphone can already count steps without additional applications. Starting from Android 4.4 KitKat, the system integrates Hardware Step Counter a hardware step counter that operates at the hardware level and consumes minimal energy. However, access to it depends on the manufacturer and model of the device.
To check for a built-in pedometer:
- ๐ฑ Open
Settings โ Google โ Google services โ Fit(the path may differ by Samsung, Xiaomi or Huawei). - ๐ Check the "Fitness" or "Activity" section - if there is step data there, the sensor is working.
- ๐ On some devices (for example, Pixel or OnePlus) steps are displayed in
Google Fitautomatically.
โ ๏ธ Attention: On budget smartphones (for example, Redmi 9A or Samsung Galaxy A03) there may be no hardware pedometer. In this case, the system uses accelerometer data, which is less accurate and consumes more battery.
If the built-in counter is inactive, try:
- Update
Google Play ServicesiGoogle Fitin Play Market. - Give permission to access physical activity sensors in
Settings โ Applications โ Google Fit โ Permissions. - Reboot the device - sometimes this resets sensor errors.
2. TOP 5 applications for pedometer: comparison of capabilities
If the built-in tools are not satisfactory, install one of the specialized applications. We tested 15 apps and selected the best ones in terms of accuracy, functionality and energy efficiency. They are all free (with a premium subscription option) and support the Russian language.
| Application | Accuracy | Energy consumption | Unique features | Cons |
|---|---|---|---|---|
| Google Fit | โญโญโญโญ | Low | Integration with Wear OS, synchronization with Strava, automatic recognition of types of activity | Limited analytics, no calorie goals |
| Pedometer (by ITO Technologies) | โญโญโญโญโญ | Average | Sensitivity correction, home screen widget, 30-day history | Advertising in free versions |
| Accupedo | โญโญโญโญ | Low | Algorithm for filtering false steps, voice alerts | Paid themes |
| StepCounter (by Leap Fitness) | โญโญโญ | High | Activity graphs by hour, data export to CSV | Lots of advertising, sometimes resets the counter |
| S Health (Samsung Health) | โญโญโญโญโญ | Low | Support Galaxy Watch, training tips, sleep monitoring | Only for devices Samsung |
For maximum accuracy, we recommend combining data from Google Fit i Pedometer. The first synchronizes with other fitness services, and the second allows you to fine-tune the sensitivity of the sensor. For example, if you are working at a computer and the phone is on the table, Accupedo automatically ignores vibrations, while a standard counter can count them as steps.
To reduce battery consumption, turn off the background activity of unnecessary applications in Settings โ Battery โ Optimization. The pedometer will work more accurately if you carry the phone in your pants pocket or on your belt, rather than in a bag or backpack.
3. How to create a pedometer without programming: application designers
If you want own pedometer application, but do not have coding skills, use online constructors. They allow you to assemble a working prototype in 10โ15 minutes using ready-made blocks. The best platforms for this task:
- ๐ ๏ธ Appy Pie โdrag-and-drop editor with templates for fitness applications. Supports integration with
Google Fit API. - ๐ฑ Thunkable โa visual environment based on MIT App Inventor, where you can add blocks for working with sensors.
- ๐ Glide โsuitable for creating a simple activity tracker based on Google Sheets (data is entered manually).
Example of step-by-step assembly in Thunkable:
- Create a new project and select a template
Blank App. - Add a component
Pedometer Sensorfrom the "Sensors" section. - Customize the interface: add a label (
Label) to display the number of steps and a reset button. - In the block
When Pedometer.Step โ Dospecify the action: update the label with the current value of steps. - Export the APK and install it on your phone.
โ ๏ธ Warning: Applications built in constructors may have limitations in accuracy. For example, Glide cannot automatically read data from sensors - manual input will be required. For a full-fledged pedometer, it is better to use Google Fit API (more on this below).
How to bypass the 1000 steps limit in free constructors?
Some platforms (for example, Appy Pie) limit the functionality in the free version. To remove the limit, export the project to APK, then decompile it using JADX and manually change the counter parameters in the code. However, this requires knowledge Java/Kotlin and may violate the license agreement.
4. Developing a pedometer from scratch: a guide for programmers
To create a professional pedometer with high accuracy and minimal battery consumption, you will need to write code in Java or Kotlin. We will consider two approaches: using Step Counter API (for hardware sensors) and Accelerometer API (for software counting).
Before you start, make sure that the file AndroidManifest.xml has the necessary permissions:
<uses-permission android:name="android.permission.ACTIVITY_RECOGNITION" /><uses-feature android:name="android.hardware.sensor.stepcounter" />
<uses-feature android:name="android.hardware.sensor.accelerometer" />
Method 1: Step Counter API (recommended)
This method uses the built-in hardware step counter, which ensures high accuracy and minimal battery consumption. Code for Kotlin:
class StepCounterService : Service() {private lateinit var sensorManager: SensorManager
private var stepSensor: Sensor? = null
private var stepCount = 0
override fun onCreate() {
super.onCreate()
sensorManager = getSystemService(SENSOR_SERVICE) as SensorManager
stepSensor = sensorManager.getDefaultSensor(Sensor.TYPE_STEP_COUNTER)
stepSensor?.also { sensor ->
sensorManager.registerListener(
stepDetectorListener,
sensor,
SensorManager.SENSOR_DELAY_UI
)
}
}
private val stepDetectorListener = object : SensorEventListener {
override fun onSensorChanged(event: SensorEvent) {
if (event.sensor.type == Sensor.TYPE_STEP_COUNTER) {
stepCount = event.values[0].toInt()
// Send data to the main thread to update the UI
sendBroadcast(Intent("STEP_COUNT_UPDATE").putExtra("count", stepCount))
}
}
override fun onAccuracyChanged(sensor: Sensor, accuracy: Int) {}
}
override fun onBind(intent: Intent?): IBinder? = null
}
Method 2: Accelerometer API (for devices without a hardware sensor)
If your phone does not have TYPE_STEP_COUNTER, you can use an accelerometer. However, this method is less accurate and requires additional data processing to filter out false positives:
class AccelerometerStepCounter : Service() {private lateinit var sensorManager: SensorManager
private var accelerometer: Sensor? = null
private var lastStepTime: Long = 0
private var stepCount = 0
private val threshold = 12.0f // Threshold value for step registration
override fun onCreate() {
super.onCreate()
sensorManager = getSystemService(SENSOR_SERVICE) as SensorManager
accelerometer = sensorManager.getDefaultSensor(Sensor.TYPE_ACCELEROMETER)
accelerometer?.also { sensor ->
sensorManager.registerListener(
accelerometerListener,
sensor,
SensorManager.SENSOR_DELAY_FASTEST
)
}
}
private val accelerometerListener = object : SensorEventListener {
override fun onSensorChanged(event: SensorEvent) {
val x = event.values[0]
val y = event.values[1]
val z = event.values[2]
val acceleration = sqrt(x x + y y + z * z)
if (acceleration > threshold) {
val currentTime = System.currentTimeMillis()
if (currentTime - lastStepTime > 300) { // Protection against double positives
stepCount++
lastStepTime = currentTime
}
}
}
override fun onAccuracyChanged(sensor: Sensor, accuracy: Int) {}
}
}
Critical feature: When using the accelerometer, the pedometer will only work when the screen is active or in the background with high priority, which significantly increases battery consumption. For optimization, add Foreground Service with a notification and use WorkManager to periodically record data.
Added permissions to AndroidManifest.xml|Tested on devices without a hardware sensor|Optimized battery consumption|Implemented background work via Foreground Service|Checked compatibility with Android 12+-->
5. Optimizing accuracy and power consumption
Even the most advanced pedometer app can show inaccurate data or quickly drain the battery. We have collected 7 proven ways to improve the performance of your step counter:
- ๐ Sensor calibration: Walk 50-100 steps manually and compare with phone readings. If the difference is more than 10%, adjust the coefficient in the code (for
Accelerometer API). - ๐ Management background processes: Use
JobSchedulerorWorkManagerto record data in batches rather than in real time. - ๐ฑ Phone positioning: Carry the device in your pants pocket or on your belt - this increases accuracy by 20-30% compared to a bag or hand.
- ๐ ๏ธ Noise filtering: To
Accelerometer APIadd a low-pass filter (for example,LowPassFilter) to smooth the data.
To test accuracy, use professional fitness trackers (for example, Garmin or Fitbit) as a reference. Compare readings over a distance of 1โ2 km at different walking speeds. Typical mistakes:
- ๐ถ False steps: Registered while driving a vehicle or working at a computer. The solution is to add a check for the amplitude and frequency of vibrations.
- ๐ Skipped steps: Occur when walking slowly or if the phone is lying motionless. The solution is to reduce the sensitivity threshold.
The best balance of accuracy and power consumption is achieved when using a hardware sensor (TYPE_STEP_COUNTER) paired with a false positive filtering algorithm. Software counting through the accelerometer is inferior in both parameters.
6. Integration with Google Fit and other services
To allow your pedometer to synchronize data with Google Fit, Apple Health (via export) or Strava, use Google Fit API. This will allow users to analyze activity in one place and compare data with other devices.
Example code for recording steps in Google Fit:
val fitnessOptions = FitnessOptions.builder().addDataType(DataType.TYPE_STEP_COUNT_DELTA, FitnessOptions.ACCESS_WRITE)
.build()
if (!GoogleSignIn.hasPermissions(GoogleSignIn.getLastSignedInAccount(this), fitnessOptions)) {
GoogleSignIn.requestPermissions(
this,
REQUEST_OAUTH_REQUEST_CODE,
GoogleSignIn.getLastSignedInAccount(this),
fitnessOptions
)
} else {
recordSteps()
}
private fun recordSteps() {
val dataSource = DataSource.Builder()
.setDataType(DataType.TYPE_STEP_COUNT_DELTA)
.setType(DataSource.TYPE_RAW)
.setAppPackageName("com.example.stepcounter")
.build()
val dataSet = DataSet.create(dataSource)
val dataPoint = dataSet.createDataPoint()
.setTimeInterval(startTime, endTime, TimeUnit.NANOSECONDS)
dataPoint.getValue(Field.FIELD_STEPS).setInt(steps)
dataSet.add(dataPoint)
Fitness.getHistoryClient(this, GoogleSignIn.getLastSignedInAccount(this)!!)
.insertData(dataSet)
.addOnSuccessListener { Log.d("StepCounter", "Steps recorded in Google Fit") }
}
To work with the API you will need:
- Create a project in Google Cloud Console and enable
Fitness API. - Generate
OAuth 2.0 Client IDfor Android. - Add dependency to
build.gradle:implementation 'com.google.android.gms:play-services-fitness:21.1.0'
โ ๏ธ Attention: From 2023 Google Fit API requires verification for applications that request access to physical activity data. If your application has not been moderated, users will see a warning about โunverified source.โ
7. Problems and solutions: why the pedometer does not work
If your step counter shows incorrect data or does not function at all, check the following points:
| Problem | Possible cause | Solution |
|---|---|---|
| Steps are not counted | No hardware sensor | Use Accelerometer API or an external fitness bracelet |
| Data is reset after reboot | State not saved in SharedPreferences or database |
Add saving the current step value in onPause() |
| Fast battery drain | Continuous polling of the accelerometer in the background | Switch to TYPE_STEP_COUNTER or reduce the polling frequency |
| False steps when driving a car | Incorrect vibration filtering | Add a check for the amplitude and frequency of vibrations (see section 5) |
If the problem persists, check logs via Logcat (filter by tag "StepCounter"). Typical errors:
Sensor not foundโ the sensor is missing on the device.Permission deniedโ there are not enough permissions (checkAndroidManifest.xml).GoogleApiExceptionโ authorization error in Google Fit API.
adb shell am startservice -a com.example.stepcounter.START
This will allow you to test background work without a physical device.-->
8. Alternative ways to track steps
If developing your own pedometer seems complicated, consider alternative options:
- ๐ฑ Fitness bracelets: Xiaomi Mi Band, Huawei Band or Amazfit synchronizes with Google Fit and is 15-20% more accurate than a smartphone.
- ๐ Smart sneakers: Models with built-in sensors (for example, Nike Adapt) transmit data directly to the application.
- ๐ป Web services: Strava or Endomondo allow you to manually enter the number of steps and build graphs activity.
- ๐ง Automation via Tasker: Set up a task that will read steps from Google Fit and send notifications when the goal is achieved.
For those who like experiments: you can assemble hardware pedometer on the base Arduino or Raspberry Pi with sensor MPU-6050. The cost of the components is about 500โ1000 rubles, and the accuracy is comparable to fitness bracelets. Example diagram:
Arduino Nano โ MPU-6050 (accelerometer/gyroscope) โ Bluetooth module HC-05 โ Android application
FAQ: Frequently asked questions about pedometers on Android
Is it possible to make a pedometer without access to the Internet?
Yes, all the methods discussed in the article (built-in counter, Step Counter API, Accelerometer API) work offline. The Internet is needed only for synchronization with Google Fit or other cloud services. For a completely autonomous solution, save data to a local database SQLite or Room.
How to transfer pedometer data to a new phone?
If you used Google Fit, the data is automatically linked to your account Google and will be transferred after authorization to new device. For local applications (for example Pedometer), use the export function to CSV or backup via adb backup:
adb backup -f steps.ab com.example.pedometer
Then restore the backup on a new phone.
Why does the pedometer on Samsung and Xiaomi show different data?
Manufacturers use different data processing algorithms with sensors For example, Samsung Health takes into account the user's step length (configurable in the profile), and Google Fit uses average values. To unify the readings:
- Indicate the same height and weight in both applications.
- Calibrate the sensor (walk 100 steps and compare readings).
- Use one application as the main one, and the others for cross-checking.
Is it possible to cheat a pedometer for competitions or bonuses?
Technically yes, but it violates the rules of most fitness platforms (for example Apple Fitness+ or corporate health apps). Ways to "cheat":
- Imitation of steps through
Accelerometer API(requires root access). - Use of simulator applications (for example, Fake Step Counter).
- Connecting an external device with a signal generator.
โ ๏ธ Attention: Many services (including Google Fit) detect suspicious activity and can block an account for fraud. For example, if 10,000 steps are registered in 5 minutes with zero movement using GPS.
How to make a pedometer for Android Wear (smart). hours)?summary>
For Wear OS use WearableRecorderApi or library Google Fit for Wearables. Example of minimal code for a watch:
class WearStepCounterService : WearableListenerService() {
override fun onDataChanged(dataEvents: DataEventBuffer) {
for (event in dataEvents) {
if (event.type == DataEvent.TYPE_CHANGED &&
event.dataItem.uri.path == "/steps") {
val dataMap = DataMapItem.fromDataItem(event.dataItem).dataMap
val steps = dataMap.getInt("count")
// Updating the UI on the watch
}
}
}
}
To synchronize with your phone, set up MessageApi or DataLayerApi. Detailed documentation: developer.android.com/wear.
WearableRecorderApi or library Google Fit for Wearables. Example of minimal code for a watch:
class WearStepCounterService : WearableListenerService() {
override fun onDataChanged(dataEvents: DataEventBuffer) {
for (event in dataEvents) {
if (event.type == DataEvent.TYPE_CHANGED &&
event.dataItem.uri.path == "/steps") {
val dataMap = DataMapItem.fromDataItem(event.dataItem).dataMap
val steps = dataMap.getInt("count")
// Updating the UI on the watch
}
}
}
}
MessageApi or DataLayerApi. Detailed documentation: developer.android.com/wear.