Every question the Phone Sensors pages answer
The 10 phone sensors pages answer 40 named questions between them. Every one is listed below, and every link lands on the paragraph that answers it rather than the top of the page.
CMPedometer: steps, distance, floors and cadence from the phone itself
- How far back can CMPedometer queryPedometerData return steps?Seven days. Apple's documentation for queryPedometerData(from:to:withHandler:) says only the past seven days worth of data is stored and…
- Why does my app crash the first time it calls CMPedometer?Almost always a missing NSMotionUsageDescription key. Apple's CMPedometer page says you must include that key in Info.plist with a usage…
- Is CMPedometer startUpdates data cumulative or per interval?Cumulative. Apple states that the data passed to your handler represents the cumulative data starting at the specified start date and…
- Why is currentCadence nil in a CMPedometer historical query?Because Apple defines it that way. The documentation for currentCadence and currentPace says the value is nil when you are performing a…
CMMotionActivityManager: walking, running, driving or still
- Can a CMMotionActivity have more than one activity flag set?Yes. Apple's CMMotionActivity documentation says the motion-related properties aren't mutually exclusive, and gives the example of a car…
- Why does queryActivityStarting return an error instead of an empty array?Because that is how Apple reports an empty range. The documentation for queryActivityStarting(from:to:to:withHandler:) says that if there…
- Does CMMotionActivityManager deliver activity changes while my app is suspended?No. Apple says the handler passed to startActivityUpdates(to:withHandler:) runs on a best-effort basis and updates are not delivered while…
- What do the CMMotionActivityConfidence levels actually mean?Apple documents three values and very little else: low is described as confidence is low, medium as confidence is good, and high as…
CMAltimeter: relative and absolute altitude on iPhone and Apple Watch
- Which iPhones support CMAltimeter absolute altitude?Apple's documentation says absolute altitude is only available on iPhone 12 and later and Apple Watch 6 or SE and later. The API itself…
- Why does CMAltimeter relativeAltitude start at zero?Because it measures change since your stream began. Apple says the first altitude event delivered to your altimeter object has a…
- What unit is CMAltitudeData pressure reported in?Kilopascals. Apple documents the pressure property of CMAltitudeData as the recorded pressure, in kilopascals, delivered alongside…
- Should I use CMAltimeter or CMPedometer floorsAscended to count stairs?For a simple floors figure, CMPedometer is less work. Apple documents floorsAscended as counting only floors climbed while walking or…
CMHeadphoneMotionManager: head motion from AirPods
- Which AirPods work with CMHeadphoneMotionManager?Apple does not publish a list on the class page. CMHeadphoneMotionManager's documentation refers only to motion-capable Apple headphones.…
- Does CMHeadphoneMotionManager work on Apple Watch?Apple's pages give two signals. The class documentation lists watchOS 7.0 as its introduction. Apple's Core Motion updates page, under June…
- How do I know when AirPods connect for head tracking?Adopt CMHeadphoneMotionManagerDelegate and set it as the manager's delegate. Apple documents headphoneMotionManagerDidConnect(_:) as a…
- What is the difference between CMHeadphoneMotionManager and CMHeadphoneActivityManager?CMHeadphoneMotionManager streams raw head motion as CMDeviceMotion: attitude, rotation rate, gravity and user acceleration, from iOS 14.0.…
CMBatchedSensorManager: high-frequency motion batches during workouts
- Is CMBatchedSensorManager available on iPhone?Apple's documentation does not say clearly. The class page lists watchOS 10.0, and also lists iOS and iPadOS 4.0, which is the same version…
- What sampling rate does CMBatchedSensorManager deliver?Apple does not publish one. The class exposes accelerometerDataFrequency and deviceMotionDataFrequency as read-only integers, but their…
- Does CMBatchedSensorManager need an active workout session?Could not verify. Apple's Core Motion update note describes the class as giving access to high-frequency data during workouts, with a golf…
- Why does CMBatchedSensorManager deliver arrays instead of single samples?Because batching is its job. The handler for startAccelerometerUpdates(handler:) receives an optional array of CMAccelerometerData, and the…
Sensor.TYPE_STEP_COUNTER vs TYPE_STEP_DETECTOR on Android
- Why does TYPE_STEP_COUNTER return a huge number on the first reading?Because it counts from the last reboot, not from when your app started. Google's Sensor reference says the step counter returns the number…
- Does TYPE_STEP_COUNTER keep counting after my app unregisters the listener?Not on the strength of your registration. Google's reference says an application needs to stay registered for this sensor because the step…
- Which Android permission does the step counter sensor need?android.permission.ACTIVITY_RECOGNITION, a dangerous permission added in API level 29. Google's motion sensors guide says you must declare…
- How long can the Android step counter take to report a step?Up to 10 seconds, according to Google's motion sensors guide, which says the step counter has more latency (up to 10 seconds) but more…
The Activity Recognition Transition API and the ACTIVITY_RECOGNITION permission
- Which activities can the Activity Recognition Transition API detect?Five, according to Google's transitions guide: IN_VEHICLE, ON_BICYCLE, RUNNING, STILL and WALKING, all expressed as DetectedActivity…
- Do I need both ACTIVITY_RECOGNITION permissions for the Transition API?On a current target, the one that matters is android.permission.ACTIVITY_RECOGNITION, granted at runtime. Google's Android 10 privacy page…
- Why does requestActivityTransitionUpdates succeed but no transitions ever arrive?The documented cause to check first is the runtime permission: Google's Android 10 privacy page says Play services activity recognition…
- How do I stop activity transition updates on Android?Call removeActivityTransitionUpdates() on the ActivityRecognitionClient, passing the same PendingIntent you registered with. Google's…
The Recording API on mobile: steps without Health Connect
- Does the Recording API on mobile need a Google Account?No. Google's Recording API guide describes it as accountless, meaning it does not require a Google Account to use the service, and says the…
- How many days of step data does the Recording API keep?Up to 10 days. Google's guide says that once the recording subscription starts or is renewed, data since the latest subscription, for up to…
- What happens to recorded steps if I unsubscribe from the Recording API?You lose access to them. Google's guide says data is only available when there is an active subscription, and that if a subscription is…
- Should I use the Recording API or Health Connect for Android steps?Google's Recording API guide frames it this way: if your app needs other health and fitness data from various sources in addition to…
foregroundServiceType="health": permissions, prerequisites and exceptions
- What exception does Android throw when a health foreground service has no type in the manifest?MissingForegroundServiceTypeException. Google's Android 14 foreground service page says that if an app targeting Android 14 doesn't define…
- Is FOREGROUND_SERVICE_HEALTH a runtime permission?No. The Manifest.permission reference lists FOREGROUND_SERVICE_HEALTH with protection level normal, added in API level 34, and Google's…
- Can a step-tracking app run a health foreground service with only ACTIVITY_RECOGNITION?Google's documentation says yes. ACTIVITY_RECOGNITION appears both in the foreground service types page's list of runtime prerequisites for…
- Can I start a health foreground service while my app is in the background?Usually not. Google's launch guide says apps targeting Android 12 or higher are not allowed to start a foreground service from the…
Android 16: BODY_SENSORS gives way to android.permission.health
- What replaces BODY_SENSORS_BACKGROUND on Android 16?READ_HEALTH_DATA_IN_BACKGROUND, whose constant string is android.permission.health.READ_HEALTH_DATA_IN_BACKGROUND. Google's Android 16…
- Does the Android 16 health permission change affect the step counter sensor?Google's list does not name it. The Android 16 behaviour-changes page lists Health Services HEART_RATE_BPM, Sensor.TYPE_HEART_RATE, two…
- Why was my app's READ_HEART_RATE permission revoked on Android 16?The documented cause is a missing privacy policy activity. Google's Android 16 page says mobile apps migrating to READ_HEART_RATE and the…
- Which permission does Sensor.TYPE_HEART_RATE need on Android 16?For apps targeting Android 16 (API level 36) or higher, Google lists Sensor.TYPE_HEART_RATE among the APIs that now require the…
Back to the Phone Sensors hub, or see every question this site answers.