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
QtServiceBase.java
Go to the documentation of this file.
1
// Copyright (C) 2023 The Qt Company Ltd.
2
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
3
4
package
org.qtproject.qt.android;
5
6
import
android.app.Service;
7
import
android.content.Intent;
8
import
android.os.IBinder;
9
import
android.util.Log;
10
11
import
java.lang.IllegalArgumentException;
12
import
java.util.Objects;
13
14
public
class
QtServiceBase
extends
Service {
15
@Override
16
public
void
onCreate
()
17
{
18
super.onCreate();
19
20
// the application has already started, do not reload everything again
21
if
(
QtNative
.getStateDetails().isStarted) {
22
Log
.w(
QtNative
.QtTAG,
23
"A QtService tried to start in the same process as an initiated "
+
24
"QtActivity. That is not supported. This results in the service "
+
25
"functioning as an Android Service detached from Qt."
);
26
return
;
27
}
28
29
QtNative
.setService(
this
);
30
31
try
{
32
QtServiceLoader loader = QtServiceLoader.getServiceLoader(
this
);
33
QtLoader.LoadingResult
result
= loader.loadQtLibraries();
34
35
if
(
result
== QtLoader.LoadingResult.Failed) {
36
Log
.w(
QtNative
.QtTAG,
"QtServiceLoader: failed to load Qt libraries"
);
37
stopSelf();
38
return
;
39
}
40
41
if
(
result
== QtLoader.LoadingResult.Succeeded) {
42
final
String
params
= loader.getApplicationParameters();
43
QtNative
.startApplication(
params
, loader.getMainLibraryPath());
44
QtNative
.setApplicationState(
QtNative
.
ApplicationState
.ApplicationHidden);
45
}
46
}
catch
(IllegalArgumentException e) {
47
Log
.w(
QtNative
.QtTAG, Objects.requireNonNull(e.getMessage()));
48
stopSelf();
49
}
50
}
51
52
@Override
53
public
void
onDestroy
()
54
{
55
super.onDestroy();
56
if
(
QtNative
.getStateDetails().isStarted)
57
QtNative
.terminateQtNativeApplication();
58
QtNative
.setService(
null
);
59
System.exit(0);
60
}
61
62
@Override
63
public
IBinder
onBind
(Intent intent) {
64
synchronized
(
this
) {
65
return
QtNative
.onBind(intent);
66
}
67
}
68
}
org.qtproject.qt.android.QtNative.ApplicationState
Definition
QtNative.java:229
org.qtproject.qt.android.QtNative
Definition
QtNative.java:38
org.qtproject.qt.android.QtServiceBase
Definition
QtServiceBase.java:14
org.qtproject.qt.android.QtServiceBase.onCreate
void onCreate()
Definition
QtServiceBase.java:16
org.qtproject.qt.android.QtServiceBase.onDestroy
void onDestroy()
Definition
QtServiceBase.java:53
org.qtproject.qt.android.QtServiceBase.onBind
IBinder onBind(Intent intent)
Definition
QtServiceBase.java:63
org.qtproject.qt.android.QtLoader.LoadingResult
Definition
QtLoader.java:59
params
GLvoid ** params
Definition
qopengldebug.cpp:1034
result
GLuint64EXT * result
[6]
Definition
qopenglext.h:10932
Log
@ Log
Definition
qqmlbuiltinfunctions.cpp:2039
qtbase
src
android
jar
src
org
qtproject
qt
android
QtServiceBase.java
Generated on
for Qt by
1.18.0