Andriod phone accelerometer reading: native code vs. Android API

109 views
Skip to first unread message

Qingya Zhao

unread,
Mar 25, 2024, 2:45:40 PMMar 25
to android-ndk
0

I used the SensorManager.SENSOR_DELAY_FASTEST to get the phone (Google pixel 6a) accelerometer data and the sampling frequency is 440Hz. However, when I used the Android native code to read the phone accelerometer data, the minimum delay allowed between events is 5000 microseconds, which means the sampling frequency is 200 Hz. And I'm not be able to set the sampling frequency higher than 200 Hz. Why is the fast sampling frequency is lower when using Android native code? How do I set the sampling frequency as 440 Hz using native code?

Updates:

I installed the same app on Motorola G power 2021. The sampling frequency obtained from the SensorManager.SENSOR_DELAY_FASTEST is 500 Hz, and the minimum delay obtained from the Android native code (ASensor_getMinDelay(accelerometerSensor)) is 2000 microseconds. Which means on Motorola G Power, the fastest samping frequency obtained from the Android API and Android NDK are the same. It is at 500 Hz.

So my question is: why is the sampling frequency consistent on the Motorola G Power 2021 but not consistent on the Google Pixel 6a?

The Android native code:

Screen Shot 2024-03-25 at 1.46.48 PM.png



Reply all
Reply to author
Forward
0 new messages