Geography Reference
In-Depth Information
differently. It is necessary to fine tune this application to each phone, which may
be done programmatically in the future.
7.6 Finding the Device Orientation
To find the device orientation the Android system libraries provide some useful
tools. This means it is a matter of passing the right values through a set of functions
to figure out the orientation in radians. The last step is then to convert that into
degrees and use the gathered information to determine if the phone is pointing in
the right direction to pick up a sticky. The following list describes the process of
calculating the device's orientation.
1. Getting the raw values from the sensor listener
2. Passing the values to the 'getRotationMatrix()'
3. Passing the answers to 'remapCoordinateSystem()'
4. Passing the results to 'getOrientation()'
5. Now we convert the values calculated above from radians to degrees.
7.6.1 Sensor Listener
Because of hardware differences in mobile devices there are several sensors that
might be available. Relevant to us are the gyroscope, accelerometer and magnetic
field sensor.
Usually most phones have the accelerometer and magnetic field sensor, how-
ever not the gyroscope. It has higher power consumption, but also delivers more
accurate information than the accelerometer. Due to these accuracy benefits
inaccuracies the gyroscope is the preferred sensor.
Since the accelerometer can be found in a wide variety of mobile phones it
makes an application more accessible to wider range of users. As a result of this
the accelerometer was the sensor chosen for the purpose of this research.
7.6.2 Orientation Discovery
Initially a sensor listener is used to collect raw information on two sensors of the
phone, the Accelerometer and the Magnetic Field sensor. The listing below shows
a code snippet of this process.