Sensors and Weather Service | Tips
Cell phone evolution
Remember the good old days when we used to carry mobile phones which looked like bricks in size, and simply trying to get a phone call. But the services available now couldn’t be even imagined by most of us 10 years ago. With the improvements in technology, mobile phone consumers are expecting it to function as an all-in-one device with all the services they use in their daily life. This demand has changed the mobile phone from a mere call receiver to a MP3 player, Digital Camera, E-Book reader, Wifi connectivity, Motion Controller with good storage capacity, which transformed it into a PC in hand.
Out of these, Sensors in mobile phone are used in our daily life for different aspects like GPS Location updates, Weather reports, counting the steps while you are on walk, capturing the orientation of mobile phone to readjust the screen etc., bada has support for these features with its various physical sensors and weather service.
Sensors in bada
bada supports Acceleration, GPS, Magnetic, Proximity, Tilt sensors. Sensor Manager supports access of built-in sensors in a device; it checks the availability of the sensor and sets the interval at which we need to get the data. The sensors automatically send data at the interval specified in the listener.
Since all sensors are not supported by all devices, bada provides a method to check for the available sensors. Using IsAvailable method, we can check if a device supports a particular sensor type and also we can check its allowable interval ranges and measurement range by using GetMax(Min)Interval and GetMeasurementRange, respectively.
bada supports the sensor types described below.
Listeners to receive Sensor data:
Application needs to implement ISensorEventListener interface and add listener for a sensor type to the Sensor Manager in order to receive the updated data asynchronously. OnDataReceived() method is called when sensor data is sensed at every sensor interval or when sensor data is changed from previous interval. Based on the sensor type, the sensor data can be queried to get the values for different sensors and their data.
The following code snippet shows how to implement listener interface, adding the listener to SensorManager.
Acceleration Sensor:
The acceleration sensor measures the device’s acceleration vector in 3 axes relative to its body frame. To detect the device movement we need to compensate for the gravitational pull of the Earth by deducting the gravity offset by 1g.
The following piece of code shows how to query the required data for Acceleration Sensor.
