Skip to content

Latest commit

 

History

History
29 lines (23 loc) · 918 Bytes

README.md

File metadata and controls

29 lines (23 loc) · 918 Bytes

NDK Sensor

This is an example of reading Android sensor data via native c++ API, and a simple implementation from JNI.

Pre-requisites

NDK

Example

 // declare your own SensorEventListener
 class MyListener: public NdkSensorEventListener{
 public:
      void onSensorChanged(ASensorEvent *event) override{ // do something }
 }

 NdkSensorManager* manager = NdkSensorManager();
 manager->setListener(new MyListener());
 // register accelerometer with 50 Hz.
 manager->registerSensor({ASENSOR_TYPE_ACCELEROMETER}, 20000);

 // unregister sensors
 manager->unregister();

Reference

NDK Sensor NDK sample

License

License