Posts

Showing posts with the label Android - Sensors Tutorial

Android - Sensors Tutorial

Image
Most of the android devices have built-in sensors that measure motion, orientation, and various environmental condition. The android platform supports three broad categories of sensors. Motion Sensors Environmental sensors Position sensors Some of the sensors are hardware based and some are software based sensors. Whatever the sensor is, android allows us to get the raw data from these sensors and use it in our application. For this android provides us with some classes. Android provides SensorManager and Sensor classes to use the sensors in our application. In order to use sensors , first thing you need to do is to instantiate the object of SensorManager class. It can be achieved as follows. SensorManager sMgr ; sMgr = ( SensorManager ) this . getSystemService ( SENSOR_SERVICE ); The next thing you need to do is to instantiate the object of Sensor class by calling the getDefaultSensor() method of the SensorManager class. Its syntax is given below − Sensor light ; l...