Accessing sensors at Android NDK
Many Android devices have built-in sensors to detect and measure motion, orientation, and other environmental conditions. It is possible to access sensors in Android NDK. This recipe will discuss how to do it in detail.
Getting ready
The example provided in this recipe is based on the sample code in the previous two recipes. Readers are recommended to read them first:
- Managing native windows at Android NDK
- Detecting and handling input events at Android NDK
How to do it…
The following steps develop the sample Android application, which demonstrates how to access sensors from Android NDK:
- Create an Android application named
nativesensors
. Set the package name ascookbook.chapter5.nativesensors
. Please refer to the Loading ...
Get Android Native Development Kit Cookbook now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.