Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.

Rajab Davudov - Android Sensors


Published on

Rajab Davudov - Android Sensors

  • Be the first to comment

  • Be the first to like this

Rajab Davudov - Android Sensors

  1. 1. Rajab Davudov
  2. 2. IntroductionMost Android devices are powered withbuilt-in sensors of high accuracy.• Motion Sensors• Environmental Sensors• Position Sensors
  3. 3. Motion SensorsThese sensors measure acceleration forcesand rotational forces along three axes.This category includes• accelerometers• gravity sensors• gyroscopes• …
  4. 4. Environmental SensorsThese sensors measure variousenvironmental parameters:• temperature• pressure• illumination• humidity
  5. 5. Position SensorsThese sensors measure the physicalposition of a device. This category includes:• orientation sensors• magnetometers• proximity
  6. 6. Sensor Table Android 4.0 Android 2.3 Android 2.2 Android 1.5Sensor (API Level 14) (API Level 9) (API Level 8) (API Level 3)TYPE_ACCELEROMETER Yes Yes Yes YesTYPE_AMBIENT_TEMPERATURE Yes n/a n/a n/aTYPE_GRAVITY Yes Yes n/a n/aTYPE_GYROSCOPE Yes Yes n/a1 n/a1TYPE_LIGHT Yes Yes Yes YesTYPE_LINEAR_ACCELERATION Yes Yes n/a n/aTYPE_MAGNETIC_FIELD Yes Yes Yes YesTYPE_ORIENTATION Yes2 Yes2 Yes2 YesTYPE_PRESSURE Yes Yes n/a1 n/a1TYPE_PROXIMITY Yes Yes Yes YesTYPE_RELATIVE_HUMIDITY Yes n/a n/a n/aTYPE_ROTATION_VECTOR Yes Yes n/a n/aTYPE_TEMPERATURE Yes2 Yes Yes Yes
  7. 7. android.hardware• Sensor• SensorEvent• SensorListener• SensorManager
  8. 8. SensorManagerSensorManager mSensorManager = (SensorManager)getSystemService(Context.SENSOR_SERVICE);List<Sensor> deviceSensors =mSensorManager.getSensorList(Sensor.TYPE_ALL);
  9. 9. SensorListeneronAccuracyChanged()new accuracy of the sensor.onSensorChanged()new data from the sensor
  10. 10. SensorListeneronAccuracyChanged()new accuracy of the sensor.onSensorChanged()new data from the sensor
  11. 11. Tips• Unregister sensors listeners• Don’t block onSensorChanged()• Verify sensors before using them• Choose sensor delays carefully
  12. 12. Ready, Steady, Code !!!
  13. 13. Rajab Davudov Senior Developer at Azerfon radjab@gmail.com Market QR Code