Qt 6.x
The Qt SDK
Loading...
Searching...
No Matches
QtService.java
Go to the documentation of this file.
1// Copyright (C) 2022 The Qt Company Ltd.
2// Copyright (c) 2016, BogDan Vatra <bogdan@kde.org>
3// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
4
5package org.qtproject.qt.android.bindings;
6
7import android.app.Service;
8import android.util.Log;
9import android.content.Intent;
10import android.content.res.Configuration;
11import android.os.Bundle;
12import android.os.IBinder;
13
15
16public class QtService extends Service
17{
18 QtServiceLoader m_loader = new QtServiceLoader(this);
19
20
25 protected void onCreateHook() {
26 // the application has already started
27 // do not reload everything again
28 if (QtNative.isStarted()) {
29 m_loader = null;
31 "A QtService tried to start in the same process as an initiated " +
32 "QtActivity. That is not supported. This results in the service " +
33 "functioning as an Android Service detached from Qt.");
34 } else {
35 m_loader.onCreate();
36 }
37 }
38 @Override
39 public void onCreate()
40 {
41 super.onCreate();
43 }
44 //---------------------------------------------------------------------------
45
46 @Override
47 public void onDestroy()
48 {
49 super.onDestroy();
51 }
52 //---------------------------------------------------------------------------
53
54 @Override
55 public IBinder onBind(Intent intent)
56 {
57 QtApplication.InvokeResult res = QtApplication.invokeDelegate(intent);
58 if (res.invoked)
59 return (IBinder)res.methodReturns;
60 else
61 return null;
62 }
63 //---------------------------------------------------------------------------
64
65 @Override
66 public void onConfigurationChanged(Configuration newConfig)
67 {
68 if (!QtApplication.invokeDelegate(newConfig).invoked)
69 super.onConfigurationChanged(newConfig);
70 }
71 public void super_onConfigurationChanged(Configuration newConfig)
72 {
73 super.onConfigurationChanged(newConfig);
74 }
75 //---------------------------------------------------------------------------
76
77 @Override
78 public void onLowMemory()
79 {
81 super.onLowMemory();
82 }
83 //---------------------------------------------------------------------------
84
85 @Override
86 public int onStartCommand(Intent intent, int flags, int startId)
87 {
88 QtApplication.InvokeResult res = QtApplication.invokeDelegate(intent, flags, startId);
89 if (res.invoked)
90 return (Integer) res.methodReturns;
91 else
92 return super.onStartCommand(intent, flags, startId);
93 }
94 public int super_onStartCommand(Intent intent, int flags, int startId)
95 {
96 return super.onStartCommand(intent, flags, startId);
97 }
98 //---------------------------------------------------------------------------
99
100 @Override
101 public void onTaskRemoved(Intent rootIntent)
102 {
103 if (!QtApplication.invokeDelegate(rootIntent).invoked)
104 super.onTaskRemoved(rootIntent);
105 }
106 public void super_onTaskRemoved(Intent rootIntent)
107 {
108 super.onTaskRemoved(rootIntent);
109 }
110 //---------------------------------------------------------------------------
111
112 @Override
113 public void onTrimMemory(int level)
114 {
116 super.onTrimMemory(level);
117 }
118 public void super_onTrimMemory(int level)
119 {
120 super.onTrimMemory(level);
121 }
122 //---------------------------------------------------------------------------
123
124 @Override
125 public boolean onUnbind(Intent intent)
126 {
127 QtApplication.InvokeResult res = QtApplication.invokeDelegate(intent);
128 if (res.invoked)
129 return (Boolean) res.methodReturns;
130 else
131 return super.onUnbind(intent);
132 }
133 public boolean super_onUnbind(Intent intent)
134 {
135 return super.onUnbind(intent);
136 }
137 //---------------------------------------------------------------------------
138
139 public boolean loadApplication(Service service, ClassLoader classLoader, Bundle loaderParams)
140 {
141 return QtNative.serviceDelegate().loadApplication(service, classLoader, loaderParams);
142 }
143
144 public boolean startApplication()
145 {
147 }
148}
static QtServiceDelegate serviceDelegate()
boolean loadApplication(Service service, ClassLoader classLoader, Bundle loaderParams)
static InvokeResult invokeDelegate(Object... args)
void super_onTaskRemoved(Intent rootIntent)
void onConfigurationChanged(Configuration newConfig)
int super_onStartCommand(Intent intent, int flags, int startId)
boolean loadApplication(Service service, ClassLoader classLoader, Bundle loaderParams)
void super_onConfigurationChanged(Configuration newConfig)
int onStartCommand(Intent intent, int flags, int startId)
GLenum GLuint GLint level
GLbitfield flags
GLuint res