Qt
Internal/Contributor docs for the Qt SDK. <b>Note:</b> These are NOT official API docs; those are found <a href='https://doc.qt.io/'>here</a>.
Loading...
Searching...
No Matches
qtpositioning-android.qdoc
Go to the documentation of this file.
1// Copyright (C) 2021 The Qt Company Ltd.
2// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GFDL-1.3-no-invariants-only
3
4/*!
5\page qtpositioning-android.html
6\inmodule QtPositioning
7\title Qt Positioning on Android
8\brief Notes on using Qt Positioning on Android
9
10\section1 Using Qt Positioning from Android Services
11
12Using Qt Positioning from a service requires several extra actions to be taken,
13depending on the Android version. The sections below give more details on
14these actions.
15
16\note Since Android 8 (API level 26), the OS limits how frequently an
17application can retrieve the user's current location while running in the
18background. The application will normally be able to receive location updates
19only a few times each hour. For more information, see
20\l {Background Location Limits}.
21
22\section2 Using Foreground Service
23
24Since Android 8 (API level 26), the background service can be killed by the
25Android OS when the application goes to the background. This normally happens
26after around a minute of running in the background. To keep the location service
27running, the service should be implemented as a \l {Foreground Service}. Such
28service shows a status bar notification, which cannot be dismissed until the
29service is stopped or removed from the foreground. This allows the user to be
30always aware of the important background activities.
31
32\note Since Android 9 (API level 28), foreground services require a special
33\c FOREGROUND_SERVICE permission. See the Android documentation for more
34details on implementing foreground services.
35
36\section2 Use Background Location Permission
37
38Since Android 10 (API level 29), the service \e must request the
39\l {ACCESS_BACKGROUND_LOCATION} permission. It should be added to the
40\c AndroidManifest.xml file as follows:
41
42\badcode
43<uses-permission android:name="android.permission.ACCESS_BACKGROUND_LOCATION" />
44\endcode
45
46\note Once the permission is added to \c {AndroidManifest.xml}, it is still
47required to explicitly allow the constant access to the location services
48for the application. To do it, one should navigate to \uicontrol Settings ->
49\uicontrol {Apps}, select a proper application, open its permissions, and
50specify the \uicontrol {Allow all the time} permission for Location
51(see the screenshot below).
52
53\image permissions.png
54
55Check \l {Access Location in the Background} Android documentation for more
56details.
57
58*/