Qt Positioning Android plugin

Overview

The Qt Positioning Android plugin wraps native Android APIs and provides access to positioning and satellite information.

The plugin can be loaded by using the provider name android.

Parameters

The following table lists parameters that can be passed to the Android plugin.

ParameterDescription
useMslAltitudeThe parameter is introduced in Qt 6.8. It determines if the plugin will try to provide an altitude above Mean Sea Level (MSL). The default value is false, which means that it provides the altitude in WGS84 format. This parameter is only relevant for Android 14 and later. See Altitude Conversion section for more details.

Altitude conversion

Android traditionally provides altitude above the World Geodetic System 1984 (WGS84) reference ellipsoid. However, starting from Android 14, a new AltitudeConverter class was introduced. This class allows to convert the WGS84 altitude into altitude above Mean Sea Level (MSL) format.

If the useMslAltitude plugin parameter is set to true, and the application is running on Android 14 or later, the QGeoCoordinate::altitude component of QGeoPositionInfo objects retrieved during position updates will contain the MSL altitude.

Note: According to the Android documentation, the conversion to the MSL altitude may take several seconds. It means that lastKnownPosition() requests may execute longer when this feature is enabled, because the method is synchronous. Other position update requests are not affected.

Examples

The following examples show how to create an android PositionSource from C++ and QML.

QML

The following snippet creates a PositionSource with no parameters. The altitude will be reported in WGS84 format.

PositionSource {
    name: "android"
}

The next snippet explicitly adds the useMslAltitude PluginParameter and sets its value to true. This PositionSource will report the altitude in MSL format.

PositionSource {
    name: "android"
    PluginParameter {
        name: "useMslAltitude"
        value: true
    }
}

C++

The following snippet shows how to use C++ to create a position source which reports the altitude in MSL format.

QVariantMap params;
params["useMslAltitude"] = true;
QGeoPositionInfoSource *positionSource = QGeoPositionInfoSource::createSource("android", params, this);

© 2024 The Qt Company Ltd. Documentation contributions included herein are the copyrights of their respective owners. The documentation provided herein is licensed under the terms of the GNU Free Documentation License version 1.3 as published by the Free Software Foundation. Qt and respective logos are trademarks of The Qt Company Ltd. in Finland and/or other countries worldwide. All other trademarks are property of their respective owners.