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
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
4package org.qtproject.qt.android;
5
6import android.app.Service;
7import android.content.Intent;
8import android.os.IBinder;
9import android.util.Log;
10
11import java.lang.IllegalArgumentException;
12import java.util.Objects;
13
14public 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 QtNative.terminateQtNativeApplication();
57 QtNative.setService(null);
58 System.exit(0);
59 }
60
61 @Override
62 public IBinder onBind(Intent intent) {
63 synchronized (this) {
64 return QtNative.onBind(intent);
65 }
66 }
67}
void ** params
GLuint64EXT * result
[6]