Listing available sensors – an introduction to the Android Sensor Framework
Android includes support for hardware sensors using the Android Sensor Framework. The framework includes the following classes and interfaces:
Most Android devices include hardware sensors, but they vary greatly between different manufacturers and models. If your application utilizes sensors, you have two choices:
- Specify the sensor in the Android Manifest
- Check for the sensor at runtime
To specify your application uses a sensor, include the
<uses-feature> declaration in the Android Manifest. Here is an example requiring a compass to be available:
<uses-feature android:name="android.hardware.sensor.compass" android:required="true"/> ...