---
title: "Phone Sensors"
canonical: "https://aifitnessapi.com/phone-sensors"
type: "cluster-index"
pages: "10"
last_reviewed: "2026-10-03"
publisher: "AIFitnessAPI"
---

# Phone Sensors

> 10 pages. Each entry below shows the question the page owns, followed by its answer capsule.

## CMPedometer: steps, distance, floors and cadence from the phone itself

- Question: CMPedometer
- HTML: https://aifitnessapi.com/phone-sensors/cmpedometer
- Markdown: https://aifitnessapi.com/phone-sensors/cmpedometer.md
- Last reviewed: 2026-10-03

CMPedometer is Core Motion's class for what Apple calls system-generated live walking data: step counts, estimated distance, floors ascended and descended, pace and cadence, available from iOS 8.0 and watchOS 2.0. It has two ways in: queryPedometerData(from:to:withHandler:) reads history, and Apple says only the past seven days worth of data is stored, while startUpdates(from:withHandler:) streams running totals from a start date you choose. Your Info.plist must carry NSMotionUsageDescription, because Apple states that without it your app crashes when you call this API. authorizationStatus(), added in iOS 11.0, tells you whether the user allowed motion access.

## CMMotionActivityManager: walking, running, driving or still

- Question: CMMotionActivityManager
- HTML: https://aifitnessapi.com/phone-sensors/cmmotionactivitymanager
- Markdown: https://aifitnessapi.com/phone-sensors/cmmotionactivitymanager.md
- Last reviewed: 2026-10-03

CMMotionActivityManager is the Core Motion class that tells your app whether the device is on someone walking, running, cycling, in a vehicle or stationary, delivered as CMMotionActivity objects with a confidence of low, medium or high. It is available from iOS 7.0 and watchOS 2.0, with the cycling flag from iOS 8.0. Live changes come from startActivityUpdates(to:withHandler:), which reports the current state and then only changes, and history comes from queryActivityStarting(from:to:to:withHandler:), which Apple limits to the last seven days and warns can lag by up to several minutes. Apple also says the motion flags are not mutually exclusive, so a single update can be both automotive and stationary.

## CMAltimeter: relative and absolute altitude on iPhone and Apple Watch

- Question: CMAltimeter
- HTML: https://aifitnessapi.com/phone-sensors/cmaltimeter
- Markdown: https://aifitnessapi.com/phone-sensors/cmaltimeter.md
- Last reviewed: 2026-10-03

CMAltimeter is Core Motion's class for altitude changes, and it reports two different things. Relative altitude, from iOS 8.0 and watchOS 2.0, is the change in meters since the first event your app received, alongside barometric pressure in kilopascals. Absolute altitude, from iOS 15.0 and watchOS 8.0, is the device's height relative to sea level with an accuracy estimate, and Apple states it is only available on iPhone 12 and later and Apple Watch 6 or SE and later. Both need NSMotionUsageDescription in Info.plist, and Apple tells you to check isRelativeAltitudeAvailable() or isAbsoluteAltitudeAvailable() before starting either stream.

## CMHeadphoneMotionManager: head motion from AirPods

- Question: CMHeadphoneMotionManager
- HTML: https://aifitnessapi.com/phone-sensors/cmheadphonemotionmanager
- Markdown: https://aifitnessapi.com/phone-sensors/cmheadphonemotionmanager.md
- Last reviewed: 2026-10-03

CMHeadphoneMotionManager is the Core Motion class that streams device motion from motion-capable Apple headphones, meaning head attitude, rotation rate, gravity and user acceleration as CMDeviceMotion, from iOS 14.0, macOS 14.0 and watchOS 7.0 according to its documentation page. Apple's class page does not list headphone models; it refers to motion-capable Apple headphones, and Apple's headphone activity sample names AirPods Pro 2 or AirPods 4 as examples of headphones that support motion updates. Check isDeviceMotionAvailable, adopt CMHeadphoneMotionManagerDelegate to learn when headphones connect and disconnect, and include NSMotionUsageDescription, because Apple says the system crashes your app on iOS and macOS when you start updates without it.

## CMBatchedSensorManager: high-frequency motion batches during workouts

- Question: CMBatchedSensorManager
- HTML: https://aifitnessapi.com/phone-sensors/cmbatchedsensormanager
- Markdown: https://aifitnessapi.com/phone-sensors/cmbatchedsensormanager.md
- Last reviewed: 2026-10-03

CMBatchedSensorManager is the Core Motion class Apple introduced, per its June 2023 update notes, to access batches of high-frequency accelerometer and device motion data during workouts, such as a golf swing or a baseball bat swing. It delivers arrays of CMAccelerometerData or CMDeviceMotion samples through start methods with handlers, plus async sequences that Apple lists for watchOS 10.0 only. The class page carries no overview text, no documented sample rate and no statement about whether a workout session must be running, so those details could not be verified from Apple's documentation. Its class-level iOS stamp of 4.0 is the same number Apple gives the Core Motion framework itself, so do not read it as an iPhone introduction date.

## Sensor.TYPE_STEP_COUNTER vs TYPE_STEP_DETECTOR on Android

- Question: Sensor.TYPE_STEP_COUNTER
- HTML: https://aifitnessapi.com/phone-sensors/android-step-counter-sensor
- Markdown: https://aifitnessapi.com/phone-sensors/android-step-counter-sensor.md
- Last reviewed: 2026-10-03

Sensor.TYPE_STEP_COUNTER returns the number of steps taken since the last reboot while the sensor was activated, as a float that resets to zero only on a reboot, and Android defines it as an on-change sensor with up to 10 seconds of latency but more accuracy than the detector. Sensor.TYPE_STEP_DETECTOR instead fires one event with the value 1.0 for every step, as a special-trigger sensor with latency expected below 2 seconds. Both arrived in API level 19, and both require the ACTIVITY_RECOGNITION runtime permission on Android 10 (API level 29) and higher. Google also warns that the counter does not count steps unless some app keeps it registered, so unregistering stops the count.

## The Activity Recognition Transition API and the ACTIVITY_RECOGNITION permission

- Question: Activity Recognition Transition API
- HTML: https://aifitnessapi.com/phone-sensors/android-activity-recognition-transition-api
- Markdown: https://aifitnessapi.com/phone-sensors/android-activity-recognition-transition-api.md
- Last reviewed: 2026-10-03

The Activity Recognition Transition API, part of Google Play services location, notifies your app when the user enters or exits one of five activities: IN_VEHICLE, ON_BICYCLE, RUNNING, STILL or WALKING. You build ActivityTransition objects with ACTIVITY_TRANSITION_ENTER or ACTIVITY_TRANSITION_EXIT, register them with requestActivityTransitionUpdates() and a PendingIntent, and read an ActivityTransitionResult from the Intent you receive. Google's setup page asks for play-services-location 12.0.0 or higher and the com.google.android.gms.permission.ACTIVITY_RECOGNITION permission, while Android 10's privacy changes add the android.permission.ACTIVITY_RECOGNITION runtime permission and say the Activity Recognition API doesn't provide results unless the user has granted it.

## The Recording API on mobile: steps without Health Connect

- Question: Recording API on mobile
- HTML: https://aifitnessapi.com/phone-sensors/android-recording-api
- Markdown: https://aifitnessapi.com/phone-sensors/android-recording-api.md
- Last reviewed: 2026-10-03

The Recording API on mobile is a Google Play services API that records fitness data from the phone in a battery-efficient way, with no Google Account, storing the data on the device. It records three data types, TYPE_STEP_COUNT_DELTA, TYPE_DISTANCE_DELTA and TYPE_CALORIES_EXPENDED, once your app subscribes, needs the android.permission.ACTIVITY_RECOGNITION permission, and makes up to 10 days of data since the latest subscription available. Google describes it as a replacement for the Google Fit Android API, and points apps that need health data from many sources to Health Connect instead.

## foregroundServiceType="health": permissions, prerequisites and exceptions

- Question: foregroundServiceType="health"
- HTML: https://aifitnessapi.com/phone-sensors/foreground-service-type-health
- Markdown: https://aifitnessapi.com/phone-sensors/foreground-service-type-health.md
- Last reviewed: 2026-10-03

From Android 14 (API level 34), a foreground service that tracks a workout declares android:foregroundServiceType="health" in the manifest, holds the FOREGROUND_SERVICE_HEALTH permission, and passes FOREGROUND_SERVICE_TYPE_HEALTH to startForeground(). Google's runtime prerequisite is that the app either declares HIGH_SAMPLING_RATE_SENSORS or has been granted at least one of BODY_SENSORS (API 35 and lower), READ_HEART_RATE, READ_SKIN_TEMPERATURE, READ_OXYGEN_SATURATION or ACTIVITY_RECOGNITION. Google documents what happens otherwise: a missing manifest type raises MissingForegroundServiceTypeException, a missing type permission or unmet runtime prerequisite throws SecurityException, and passing a type the manifest does not declare throws IllegalArgumentException.

## Android 16: BODY_SENSORS gives way to android.permission.health

- Question: Android 16 BODY_SENSORS
- HTML: https://aifitnessapi.com/phone-sensors/android-16-body-sensors-health-permissions
- Markdown: https://aifitnessapi.com/phone-sensors/android-16-body-sensors-health-permissions.md
- Last reviewed: 2026-10-03

For apps targeting Android 16 (API level 36) or higher, Google's behaviour-changes page says any API that previously required BODY_SENSORS or BODY_SENSORS_BACKGROUND now requires the corresponding granular health permission, the same permissions that guard Health Connect. The affected surfaces Google lists are HEART_RATE_BPM in Health Services on Wear OS, Sensor.TYPE_HEART_RATE, heartRateAccuracy and heartRateBpm in Wear OS ProtoLayout, and FOREGROUND_SERVICE_TYPE_HEALTH. Request READ_HEART_RATE (or the matching permission for SpO2 or skin temperature) instead of BODY_SENSORS for while-in-use access, and READ_HEALTH_DATA_IN_BACKGROUND instead of BODY_SENSORS_BACKGROUND. Phone apps that migrate must also declare an activity showing their privacy policy, and Google warns the permission is revoked if they do not.
