Qt Positioning Android plugin | Qt Positioning | Qt 6.11.1
Description: Wraps Android positioning subsystem.

- Qt 6.11
- Qt Positioning
- Qt Positioning Plugins
- Qt Positioning Android plugin
- Qt 6.11.1 Reference Documentation

Plugins ◦ GeoClue v2 plugin

# 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.

Parameter | Description
--- | ---
useMslAltitude | The 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);

Plugins ◦ GeoClue v2 plugin