Device Orientation

Some devices may include a hardware sensor that determines the orientation of the device. If the sensors are magnetic, the orientation is given as magnetic angles to the application. In practice, this means that if the application needs to use True North instead of Magnetic North (see section, "Geographic Coordinate System"), the application must perform the conversion task. The sensor type can be checked by using the isOrientationMagnetic() method of the Orientation class. Orientation information can be obtained from the API's Orientation class. Code sample 11 demonstrates how to obtain the orientation support information of a device.

Code sample 11: Obtaining orientation support information (TouristRoute's ConfigurationProvider.java class)

try

    orientation = Orientation.getOrientation();
    return true;

catch (LocationException e)

    return false;

If the access of Orientation.getOrientation() does not cause LocationException, the device supports at least the obtaining of compass azimuth.