How do I prompt the launch of an Android Service in the background (Qt5.7)?
-
@Schluchti I'm just getting back to it now. I've had a few exchanges with BogDan Vatra regarding this (on his KDAB article https://www.kdab.com/qt-android-episode-7/ ) search for "Shannon on June 3, 2016 at 11:17 pm said:" to see the discussion.
I'll take a look through your repo, and see if it will all become clear. good luck!
-
@refaQtor I just commited another change to the github repository. The strange thing is, that I am still not seeing the debug output, but when I go to "settings" on my Android phone to list all running applications I see that "qt_androidservicesexample" (application + service) is running. My assumption is, that the service is up and running but the debug output somehow isn't showing up.
I am currently trying to extend the example with something similar to the thing you did (the "netcat" thing) to confirm my theory.edit: okay, with the netcat trick, I clearly see that the service gets started. This raises the following question: Is this a bug or is it technically not possible to use qDebug() in an android service?
-
@Schluchti I came up with the netcat thing simply because I didn't figure that the debugger, which launched and connected with the main application would be able to pick up and connect to what, to the qt debugger, appear as android launching another application. I mean, when I used AndroidStudio directly to look at its debugger I see gobs of stuff from other applications. The QtCreator debugger setup, thankfully, seems only to show pertinent messages to the single application under test.
So, I'm glad my code snips helped you. I'm hopeful that you could see that your service did actually get launched. I'll open my whole sample repo to share, so others don't have this grief. -
The netcat thing was really a clever trick, thanks for sharing that ;). I really like the "logging over TCP" approach and I think that this maybe is convenient way to add debugging output from the service part. I think I will spend some time and create a more generalized logging routine based on your idea. :)
-
@Schluchti Thank you for your attention.
I did check this article and for three days i can't get it to work. I even downloaded the code itself but it is not working too! It doesn't issue any errors at all. However, I cannot see a service running on my android phone.I also downloaded this code:
https://github.com/bbernhard/qtandroidservices_exampleIt worked! But, i can not make the service run on boot time.
I asked this in the forum here:
https://forum.qt.io/topic/79801/can-t-listen-to-android-os-intents-ex-receive_boot_completed -
ok, I was able to make the service run at boot time. Here's the solution:
https://stackoverflow.com/a/44353506/8086424