Qt
Internal/Contributor docs for the Qt SDK. Note: These are NOT official API docs; those are found at https://doc.qt.io/
Loading...
Searching...
No Matches
android.qdoc
Go to the documentation of this file.
1
// Copyright (C) 2024 The Qt Company Ltd.
2
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GFDL-1.3-no-invariants-only
3
4
/*!
5
6
\page position-plugin-android.html
7
\title Qt Positioning Android plugin
8
\ingroup QtPositioning-plugins
9
10
\brief Wraps Android positioning subsystem.
11
12
\section1 Overview
13
14
The Qt Positioning Android plugin wraps native Android APIs and provides
15
access to positioning and satellite information.
16
17
The plugin can be loaded by using the provider name \b android.
18
19
\section1 Parameters
20
21
The following table lists parameters that \e can be passed to the Android
22
plugin.
23
24
\table
25
\header
26
\li Parameter
27
\li Description
28
\row
29
\li useMslAltitude
30
\li The parameter is introduced in Qt 6.8. It determines if the plugin will
31
try to provide an altitude above Mean Sea Level (MSL). The default value
32
is \c false, which means that it provides the altitude in WGS84 format.
33
This parameter is only relevant for Android 14 and later. See
34
\l {Altitude Conversion} section for more details.
35
\endtable
36
37
\section2 Altitude conversion
38
39
Android traditionally provides altitude above the World Geodetic System 1984
40
(WGS84) reference ellipsoid. However, starting from Android 14, a new
41
\l {https://developer.android.com/reference/android/location/altitude/AltitudeConverter}
42
{AltitudeConverter} class was introduced. This class allows to convert the
43
WGS84 altitude into \e {altitude above Mean Sea Level (MSL)} format.
44
45
If the \c {useMslAltitude} plugin parameter is set to \c {true}, and the
46
application is running on \b {Android 14} or later, the
47
\l QGeoCoordinate::altitude component of \l QGeoPositionInfo objects retrieved
48
during position updates will contain the MSL altitude.
49
50
\note According to the Android
51
\l {https://developer.android.com/reference/android/location/altitude/AltitudeConverter#addMslAltitudeToLocation(android.content.Context,%20android.location.Location)}
52
{documentation}, the conversion to the MSL altitude \e may take several seconds.
53
It means that \l {QGeoPositionInfoSource::}{lastKnownPosition()} requests \e may
54
execute longer when this feature is enabled, because the method is synchronous.
55
Other position update requests are not affected.
56
57
\section1 Examples
58
59
The following examples show how to create an \b android \l PositionSource from
60
C++ and QML.
61
62
\section2 QML
63
64
The following snippet creates a \l PositionSource with no parameters. The
65
altitude will be reported in WGS84 format.
66
67
\qml
68
PositionSource {
69
name: "android"
70
}
71
\endqml
72
73
The next snippet explicitly adds the \c {useMslAltitude} \l PluginParameter
74
and sets its value to \c true. This \l PositionSource will report the altitude
75
in MSL format.
76
77
\qml
78
PositionSource {
79
name: "android"
80
PluginParameter {
81
name: "useMslAltitude"
82
value: true
83
}
84
}
85
\endqml
86
87
\section2 C++
88
89
The following snippet shows how to use C++ to create a
90
\l {QGeoPositionInfoSource}{position source} which reports the altitude in MSL
91
format.
92
93
\code
94
QVariantMap params;
95
params["useMslAltitude"] = true;
96
QGeoPositionInfoSource *positionSource = QGeoPositionInfoSource::createSource("android", params, this);
97
\endcode
98
99
*/
qtpositioning
src
positioning
doc
src
plugins
android.qdoc
Generated on Mon Mar 10 2025 01:10:56 for Qt by
1.13.2