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 if (result == QtLoader.LoadingResult.Succeeded) {
35 QtNative.startApplication(loader.getApplicationParameters(),
36 loader.getMainLibraryPath());
37 QtNative.setApplicationState(QtNative.ApplicationState.ApplicationHidden);
38 } else if (result == QtLoader.LoadingResult.Failed) {
39 Log.w(QtNative.QtTAG, "QtServiceLoader: failed to load Qt libraries");
40 stopSelf();
41 }
42 } catch (IllegalArgumentException e) {
43 Log.w(QtNative.QtTAG, Objects.requireNonNull(e.getMessage()));
44 stopSelf();
45 }
46 }
47
48 @Override
49 public void onDestroy()
50 {
51 super.onDestroy();
52 QtNative.terminateQtNativeApplication();
53 QtNative.setService(null);
54 System.exit(0);
55 }
56
57 @Override
58 public IBinder onBind(Intent intent) {
59 synchronized (this) {
60 return QtNative.onBind(intent);
61 }
62 }
63}
GLuint64EXT * result
[6]