-
Book Overview & Buying
-
Table Of Contents
Android 9 Development Cookbook - Third Edition
By :
Android includes support for hardware sensors using the Android Sensor Framework. The framework includes the following classes and interfaces:
SensorManagerSensorSensorEventListenerSensorEventMost Android devices include hardware sensors, but they vary greatly between different manufacturers and models. If your application utilizes sensors, you have two choices:
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"/>
If your application utilizes the compass, but does not require it to function, you should set android:required="false" instead; otherwise your application will not be available to install from Google Play.
Sensors are grouped into...