Qt
Internal/Contributor docs for the Qt SDK. Note: These are NOT official API docs; those are found at https://doc.qt.io/
Toggle main menu visibility
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
Starting from Qt 6.13, the preferred altitude type can also be configured with
58
\l QGeoPositionInfoSource::setPreferredAltitudeType(). If an altitude type other
59
than \l {QGeoCoordinate::}{AltitudeType::Unknown} is passed to that method, it
60
overrides the plugin parameter.
61
62
\section1 Examples
63
64
The following examples show how to create an \b android \l PositionSource from
65
C++ and QML.
66
67
\section2 QML
68
69
The following snippet creates a \l PositionSource with no parameters. The
70
altitude will be reported in WGS84 format.
71
72
\qml
73
PositionSource {
74
name: "android"
75
}
76
\endqml
77
78
The next snippet explicitly adds the \c {useMslAltitude} \l PluginParameter
79
and sets its value to \c true. This \l PositionSource will report the altitude
80
in MSL format.
81
82
\qml
83
PositionSource {
84
name: "android"
85
PluginParameter {
86
name: "useMslAltitude"
87
value: true
88
}
89
}
90
\endqml
91
92
\section2 C++
93
94
The following snippet shows how to use C++ to create a
95
\l {QGeoPositionInfoSource}{position source} which reports the altitude in MSL
96
format.
97
98
\code
99
QVariantMap params;
100
params["useMslAltitude"] = true;
101
QGeoPositionInfoSource *positionSource = QGeoPositionInfoSource::createSource("android", params, this);
102
\endcode
103
104
*/
qtpositioning
src
positioning
doc
src
plugins
android.qdoc
Generated on
for Qt by
1.18.0