intTypePromotion=1
zunia.vn Tuyển sinh 2024 dành cho Gen-Z zunia.vn zunia.vn
ADSENSE

Bài giảng Lập trình cho thiết bị di động: Chương 7 - ĐH Công nghệ Đồng Nai

Chia sẻ: Na Na | Ngày: | Loại File: PPTX | Số trang:35

124
lượt xem
12
download
 
  Download Vui lòng tải xuống để xem tài liệu đầy đủ

Bài giảng Lập trình cho thiết bị di động: Chương 7 - Thao tác với thiết bị cảm ứng có nội dung trình bày về Sensors và Monitoring the Battery. Tham khảo nội dung bài giảng để hiểu rõ hơn về các nội dung trên.

Chủ đề:
Lưu

Nội dung Text: Bài giảng Lập trình cho thiết bị di động: Chương 7 - ĐH Công nghệ Đồng Nai

  1. DONG NAI UNIVERSITY OF TECHNOLOGY 1. Sensors 2. Monitoring the Battery 1
  2. DONG NAI UNIVERSITY OF TECHNOLOGY 1. Sensors The emulator does not provide any sensor data. All sensor testing must be done on a physical device. Alternatively, OpenIntents.org also provides a handy Sensor Simulator: http://code.google.com/p/openintents/wiki/SensorSimulator This tool simulates accelerometer, compass, and temperature sensors, and it transmits data to the emulator. Android devices have a variety of sensors : 2
  3. DONG NAI UNIVERSITY OF TECHNOLOGY 1. Sensors TYPE_ACCELEROMETER: Measures acceleration in three directions; values are in SI units (m/s2). TYPE_GYROSCOPE: Measures angular orientation in three directions; values are angles in degrees. TYPE_LIGHT: Measures ambient light; values are in SI lux units. TYPE_MAGNETIC_FIELD: Measures magnetism in three directions; the compass values are in micro-Tesla (uT). TYPE_PRESSURE: Measures barometric pressure. TYPE_PROXIMITY: Measures the distance to an object; values are in centimeters, or “near” versus “far.” TYPE_RELATIVE_HUMIDITY: Measures the relative humidity. TYPE_AMBIENT_TEMPERATURE: Measures temperature. 3
  4. DONG NAI UNIVERSITY OF TECHNOLOGY 1. Sensors Ø Here are the major classes related to sensor. Class Comment Sensor Class representing a sensor. Use getSensorList(int) to get the list of available Sensors. SensorEve This class represents a Sensor event and nt holds informations such as the sensor's type, the time-stamp, accuracy and of course the sensor's data. SensorEventListe An interface: Used for receiving notifications ner from the SensorManager when sensor values have changed. SensorManag SensorManager lets you access the device's er sensors. Get an instance of this class by calling Context.getSystemService() with the 4
  5. DONG NAI UNIVERSITY OF TECHNOLOGY 1. Sensors Ø Working with Sensor ü To get a Sensor, you need to use SensorManager. 5
  6. DONG NAI UNIVERSITY OF TECHNOLOGY 1. Sensors Ø Working with Sensor ü Register EventListener to it. 6
  7. DONG NAI UNIVERSITY OF TECHNOLOGY 1. Sensors Ø Working with Sensor ü UnRegister EventListener. Register in the onResume method and Unregister in the onPause method 7
  8. DONG NAI UNIVERSITY OF TECHNOLOGY 1. Sensors Ø SensorManager.SENSOR_DELAY Frequence Comment SENSOR_DELAY_FASTE get sensor data as fast as ST possible SENSOR_DELAY_NORM rate (default) suitable for AL screen orientation changes SENSOR_DELAY_GAME rate suitable for games SENSOR_DELAY_UI rate suitable for the user interface 8
  9. DONG NAI UNIVERSITY OF TECHNOLOGY 1. Sensors Ø Receive SensorEvent Normally, onSensorChanged is the method in which we need to put your sensor handle logic. 9
  10. DONG NAI UNIVERSITY OF TECHNOLOGY 1. Sensors Ø SensorEvent Type Name Comment public int accuracy The accuracy of this event. public Sensor sensor The sensor that generated this event. public long timestamp The time in nanosecond at which the event happened public final float[] values The length and contents of the values array depends on which sensor type is being monitored. 10
  11. DONG NAI UNIVERSITY OF TECHNOLOGY 1. Sensors Ø Sensor.TYPE_TEMPERATU RE 11
  12. DONG NAI UNIVERSITY OF TECHNOLOGY 1. Sensors Ø Sensor.TYPE_TEMPERATU RE 12
  13. DONG NAI UNIVERSITY OF TECHNOLOGY 1. Sensors Ø Sensor.TYPE_LIGHT 13
  14. DONG NAI UNIVERSITY OF TECHNOLOGY 1. Sensors Ø Sensor.TYPE_LIGHT 14
  15. DONG NAI UNIVERSITY OF TECHNOLOGY 1. Sensors Ø Sensor.TYPE_PRESSURE 15
  16. DONG NAI UNIVERSITY OF TECHNOLOGY 1. Sensors Ø Sensor.TYPE_PRESSURE 16
  17. DONG NAI UNIVERSITY OF TECHNOLOGY 1. Sensors Ø Sensor. TYPE_PROXIMITY 17
  18. DONG NAI UNIVERSITY OF TECHNOLOGY 1. Sensors Ø Sensor. TYPE_PROXIMITY 18
  19. DONG NAI UNIVERSITY OF TECHNOLOGY 1. Sensors Ø Sensor. TYPE_PROXIMITY 19
  20. DONG NAI UNIVERSITY OF TECHNOLOGY 1. Sensors Ø Sensor.TYPE_ACCELEROM ETER The accelerometer values are represented in SI units (m/s2). The device at right has the bottom of the device screen pointing toward the center of gravity. Gravity on Earth is 9.80665 m/s2. All values are in SI units (m/s2) values[0]: Acceleration minus Gx on the x-axis values[1]: Acceleration minus Gy on the y-axis values[2]: Acceleration minus Gz on the z-axis 20
ADSENSE

CÓ THỂ BẠN MUỐN DOWNLOAD

 

Đồng bộ tài khoản
2=>2