How to Declare a Sensor object

Sensor was added in API Level 3
Class representing a sensor. Use getSensorList(int) to get the list of available Sensors.

1. Set the Minimum and Target SDK version to 3, or greater. 

2. In the MainActivity.java file, add the below line to the imports section. 

import android.hardware.Sensor;
3. Add the below line to the onCreate method. This will declare a Sensor object named mySensor.

Sensor mySensor; 

4. Compile and run