Access Android sensors via NDK

Example from google https://github.com/googlesamples/android-ndk/tree/master/sensor-graph.Their code allow you controll SENSOR_REFRESH_RATE_HZ for the accelerometer.Written on c++ and connected to java code through the NDK.


I have taken a look at sensor.h, and the API looks very promising; however, a little howto on how to deal with the ASensorEventQueue and ASensorEventQueue_hasEvents and so forth would be -extremely- useful.

Ha! Update:

This looks a code example for what you want to do.

http://developer.android.com/reference/android/app/NativeActivity.html


Since Android SDK version 9 (for Android > 2.2) it seems to be possible to use the sensors via NDK.

See the STABLE_APIS.html file included in the docs. (Search for "sensor.h"). A mirror of that file is here.


I have recently worked on a pure C sensor application for android. Using NDK, you can access the sensors on the device without using Java. Check : https://github.com/PromiseMasango/sensor. Check : https://github.com/PromiseMasango/Android-NDK-sensor-example.