Lesson 1 (Mobile Sensors) Flashcards
What kind of mobile sensors are there? (10)
Temperature, GPS, Magnetic field, Accelerometer, Gyroscope, Proximity, Pressure, Pedometer, Light and (Microphone/camera)
What does the accelerometer do and how does it work?
Provides the total force applied on the device. Stationary gives +1g gravinational force. Used to determine device orientation. Accelerometer values minus gravity force gives acceleration in SI: m/s2 (acceleration m/s per time unit). Used on different axes (xyz)
What does the magentic field sensor do and how does it work?
Measures the ambient magnetic field on the xyz axes. Measured in Micro Tesla (uT). This can determine which way is north. Also called compass sensor..
What does the Gyroscope sensor do and how does it work?
Measures the rate of rotation around an axis (xyz). Pitch x, Roll y, Azimuth z. Used for example for games.
What does the pressure sensor do and how does it work?
Measures the barometric pressure. Used to measure altitude. Units in hPa (millibar)
What does the gravity sensor do and how does it work?
The gravity sensor is not separate. It removes the acceleration data from the accelerometer to measure the gravity power.
What does the light sensor do and how does it work?
Small dot on the front of the phone. Units in lux. Measures the amount of light in the front of the phone.
What does the proximity sensor do and how does it work?
Measures the distance between an object and the phone itself. Usually in centimeters. Used to put the screen off while calling.
What interface is implemented by various sensor classes and how do they run on the device?
They run as a background service. Implementing the Listener interface. You can register callbacks here to receive updates from the sensor. These are async callbacks.
Which two sensor manager classes are there in Android?
LocationManager (GPS) and SensorManager (accelerometer, gyroscope, proximity, light sensors). Th
How can you request a sensor manager from an Android app?
By calling getSystemService(SENSOR_SERVICE) in an activity.
What types of locations does the GPS location listener keep track of? What interface is used?
GPS location and network location. LocationListener interface. The location provider matters for power usage. GPS uses more power than network location. Its possible to register passivly, which means that if another app requests the location, you will get it as well to save battery.
What options can be set for requesting location updates and how is this method called?
calling: requestLocationUpdates(). Options are x meters distance, x time elapsed, x minimum accuracy. Accuracy is how many meters in a diameter from the returned position the phone can actually be.
What properties does the Location object have?
altitude, longitude, latitude, speed and time
How do you (un)register a listener?
Calling the getSystemService().getDefaultSensor(type) and registering a sensor listener class to this sensor manager. You can also unregister using this sensor manager
What method from the SensorListener interface is called for updates from the sensor?
onSensorChanged(SensorEvent evt). Contains values that came from the sensor.
How do services run?
In a different thread. Can’t run on the GUI thread. It’ll run in the background.
How is the thread-like way on the GUI thread called and used for?
Handler. Its a thread/task which is running on the current (usually GUI) thread.