08A Sensors Flashcards

1
Q

Sensor Overview

A
  • Most Android-powered devices have built-in sensors that measure motion, orientation, and various environmental conditions
  • These sensors are capable of providing raw data with high precision and accuracy
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

Three Categories of Sensors

A

• Motion sensors: measure acceleration forces and rotational forces along three axes
• Environmental sensors: measure various
environmental parameters, such as ambient air temperature and pressure, illumination, and humidity
• Position sensors: measure the physical
position of a device

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

Using Sensors

A

• Access sensors available on the device and acquire raw sensor data by using the Android sensor framework
• The sensor framework provides several
classes and interfaces that help you perform a wide variety of sensor-related tasks

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

Using Sensors: You can …

A
  • Determine which sensors are available on a device
  • Determine an individual sensor’s capabilities, such as its maximum range, manufacturer, power requirements, and resolution
  • Acquire raw sensor data and define the minimum rate at which you acquire sensor data
  • Register and unregister sensor event listeners that monitor sensor changes
  • You can access these sensors and acquire raw sensor data by using the Android sensor framework. The sensor framework is part of the android.hardware package
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

SensorManager

A
  • Use this class to create an instance of the sensor service.
  • Provides various methods for accessing and listing sensors, registering and unregistering sensor event listeners, and acquiring orientation information.
  • Provides several sensor constants that are used to report sensor accuracy, set data acquisition rates, and calibrate sensors.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

Sensor class

A

• Use this class to create an instance of a
specific sensor.
• Provides various methods that let you
determine a sensor’s capabilities

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

SensorEventListener

A

• Use this interface to create two callback
methods that receive notifications (sensor
events) when sensor values change or when
sensor accuracy changes
• onSensorChanged(SensorEvent e)
• onAccuracyChanged(Sensor s, Accuracy a)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

Two Sensor Tasks

A
  • Identifying sensors and sensor capabilities

* Monitor sensor events

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

Sensor Availability

A
  • Different Android versions support different sensors
  • Not every device has all sensors. For example, my phone has a pressure sensor while my touchpad does not. Cheap devices tend to have fewer sensors
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

Using Sensors

A

• Use the getResolution() and
getMaximumRange() methods to obtain a
sensor’s resolution and maximum range of
measurement
• Use the getPower() method to obtain a
sensor’s power requirements
• The getVendor() and getVersion() let you look for a specific sensor.
• If it isn’t present, you can use a different one or tell the user your app can’t run
• Another useful method is getMinDelay(),
which returns the minimum time interval (in
microseconds) a sensor can use to sense data
• Any sensor that returns a non-zero value for getMinDelay() is a streaming sensor.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

Monitoring Sensor Events

A
• To monitor raw sensor data you need to
implement two callback methods that are
exposed through the SensorEventListener
interface: onAccuracyChanged() and
onSensorChanged().
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

Sensor Accuracy Changes

A
• The system invokes the onAccuracyChanged() method, providing you with a reference to the Sensor object that changed and the new accuracy of the sensor. Accuracy is represented by one of four status constants:
SENSOR_STATUS_ACCURACY_LOW,
SENSOR_STATUS_ACCURACY_MEDIUM,
SENSOR_STATUS_ACCURACY_HIGH, or
SENSOR_STATUS_UNRELIABLE.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

Sensor Value Changes

A
  • The system invokes the onSensorChanged() method, providing you with a SensorEvent object
  • A SensorEvent object contains information about the new sensor data, including: the accuracy of the data, the sensor that generated the data, the timestamp at which the data was generated, and the new data that the sensor recorded.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

Handling Pause and Resume

A

• The example uses the onResume() and
onPause() callback methods to register and
unregister the sensor event listener
• As a best practice you should always disable sensors you don’t need, especially when your activity is paused. Failing to do so can drain the battery in just a few hours The system will not disable sensors automatically when the
screen turns off.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

Sensor Coordinate System

A

• The sensor framework generally uses a standard 3-axis coordinate system to express data values

How well did you know this?
1
Not at all
2
3
4
5
Perfectly