Android sensor Overview (III)

Source: Internet
Author: User

Sensor framework

By using the android framework, you can access these sensors and obtain raw sensor data. The sensor framework is part of the android. hardware package and includes the following classes and interfaces:

1. sensormanager

Use this class to create a sensor service instance. This class provides a variety of methods for accessing and listening to sensors. It also provides several sensor constants for reporting the accuracy of the sensor, setting the data acquisition rate, and calibration the sensor.

2. Sensor

Use this class to create an instance of a special sensor. It provides various methods for determining the sensor capability.

3. sensorevent

The system uses this class to create a sensor event object, which provides information about sensor events. A sensor event object contains the following information:

A. Raw sensor data;

B. types of sensors that generate events;

C. Data accuracy;

D. Event timestamp.

4. sensoreventlistener

Use this interface to create two callback methods, which receive notifications (sensor events) when the sensor value or accuracy changes ).

In typical applications, you use sensor-related APIs to perform two basic tasks:

1. Identify sensors and sensor capabilities

Identifying sensors and sensor capabilities during operation is helpful for determining whether your application has functionality dependent on special sensor types and capabilities. For example, you may want to identify all the sensors on the current device and disable all functions that are not supported by the dependent sensors. Similarly, you may want to identify all the sensors of the given type so that you can select the sensors suitable for your application.

2. Monitor sensor events

Monitoring sensor events is a way to obtain raw sensor data. A sensor event occurs every time it detects a change in its measurement parameters. Sensor events provide four types of information:

A. Name of the sensor that triggered the event;

B. Event timestamp;

C. Event precision;

D. Raw sensor data that triggers the event.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.