blob: f35db6436a344a6b41f54b5529737143c2c578bf (
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
49
50
51
52
53
54
55
56
57
58
|
// 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 {
private final QtServiceDelegate m_delegate = new QtServiceDelegate(this);
QtServiceLoader m_loader = new QtServiceLoader(this);
protected void onCreateHook() {
// the application has already started
// do not reload everything again
if (QtNative.isStarted()) {
m_loader = null;
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.");
} else {
m_loader.onCreate();
}
}
@Override
public void onCreate()
{
super.onCreate();
onCreateHook();
}
@Override
public void onDestroy()
{
super.onDestroy();
QtNative.quitQtCoreApplication();
QtNative.terminateQt();
QtNative.setService(null, null);
QtNative.m_qtThread.exit();
System.exit(0);
}
@Override
public IBinder onBind(Intent intent) {
synchronized (this) {
return QtNative.onBind(intent);
}
}
QtServiceDelegate getServiceDelegate()
{
return m_delegate;
}
}
|