Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct
Android service not running at device boot
I'm trying to create a service on android which must be automatically started at device boot.
I took a look here https://doc.qt.io/qt-5/android-services.html#service-in-separate-process and I used the servicebroadcast example (available here: https://code.qt.io/cgit/qt/qtandroidextras.git/tree/examples/androidextras/services/servicebroadcast?h=5.15) as a starting point. My problem is that I don't see
the service running.
I commented out what I tought were used to communicate with the service and
what is used to start the service on demand.
As you can see in service_main.cpp I have the service main() function which
defines and starts a QAndroidService. From what I know this should be called
by the Java class ActivityUtils once the BOOT_COMPLETED has been received
(as defined from line 17 to line 21 of the android manifest).
I commented out some code of the original example because I wanted to build
up a dummy project with an android service the starts up at device boot and
does nothing. What I'm doing wrong? Here is the project I'm using for
test purposes. https://we.tl/t-uHAqL8Nt0F
I also tried to keep the project intact and to modify only the manifest (https://we.tl/t-bpK5KTCW1O) but the service still won't start at device boot
You don't see that the service is running, or you don't see that it has started? There is a big difference. In modern Android versions non-foreground services don't live long without an activity, they will be quickly terminated by the system.
I don't see it running at each device boot (and so I think it hasn't started). What I want to achive is a service running at each device boot (without any "user application" opened) like system services/daemons on windows/linux.
I don't see it running at each device boot (and so I think it hasn't started).
As I already said, the absence of a running service doesn't mean anything on modern Android. You should add some logging and then look at the output of adb logcat to make sure that there was an attempt to start the service at boot.
What I want to achive is a service running at each device boot (without any "user application" opened) like system services/daemons on windows/linux.
Then you should use the foreground service instead of the regular service.
Do you know if there are any example of foreground services on qt available online?
I looked at https://doc.qt.io/qt-5/qtexamples.html#qt-android-extras but I didn't find any example of foreground services.
Here is an example of Qt app for Android with foreground service that starts on device boot:
Thank you! It was useful to me