blob: 3f2a82fd5efd0a030b221617cae1b02f6407bad0 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
|
// Copyright (C) 2023 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
package org.qtproject.qt.android;
import android.app.Service;
import android.content.Intent;
import android.os.IBinder;
import android.util.Log;
public class QtServiceBase extends Service {
@Override
public void onCreate()
{
super.onCreate();
// the application has already started, do not reload everything again
if (QtNative.isStarted()) {
Log.w(QtNative.QtTAG,
"A QtService tried to start in the same process as an initiated " +
"QtActivity. That is not supported. This results in the service " +
"functioning as an Android Service detached from Qt.");
return;
}
QtServiceLoader loader = new QtServiceLoader(this);
loader.loadQtLibraries();
QtNative.startApplication(loader.getApplicationParameters(), loader.getMainLibrary());
}
@Override
public void onDestroy()
{
super.onDestroy();
QtNative.quitQtCoreApplication();
QtNative.terminateQt();
QtNative.setService(null);
QtNative.getQtThread().exit();
System.exit(0);
}
@Override
public IBinder onBind(Intent intent) {
synchronized (this) {
return QtNative.onBind(intent);
}
}
}
|