Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Mobile and Embedded
  4. How do I prompt the launch of an Android Service in the background (Qt5.7)?
Forum Updated to NodeBB v4.3 + New Features

How do I prompt the launch of an Android Service in the background (Qt5.7)?

Scheduled Pinned Locked Moved Unsolved Mobile and Embedded
5.7androidservice
12 Posts 5 Posters 10.4k Views 4 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • S Schluchti
    28 Jun 2016, 19:20

    @refaQtor Could you make it work? I am currently facing the same problem. I uploaded my progress to github: https://github.com/bbernhard/qtandroidservices_example

    Any help is really appreciated!

    R Offline
    R Offline
    refaQtor
    wrote on 29 Jun 2016, 19:23 last edited by
    #3

    @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!

    S 1 Reply Last reply 29 Jun 2016, 21:02
    0
    • R refaQtor
      29 Jun 2016, 19:23

      @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!

      S Offline
      S Offline
      Schluchti
      wrote on 29 Jun 2016, 21:02 last edited by Schluchti
      #4

      @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?

      Want to read more about Qt?

      https://gympulsr.com/blog/qt/

      Latest Article: https://gympulsr.com/blog/qt/2017/06/14/ios-background-music-qt.html

      R 1 Reply Last reply 30 Jun 2016, 01:44
      0
      • S Schluchti
        29 Jun 2016, 21:02

        @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?

        R Offline
        R Offline
        refaQtor
        wrote on 30 Jun 2016, 01:44 last edited by
        #5

        @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.

        1 Reply Last reply
        0
        • S Offline
          S Offline
          Schluchti
          wrote on 1 Jul 2016, 15:03 last edited by
          #6

          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. :)

          Want to read more about Qt?

          https://gympulsr.com/blog/qt/

          Latest Article: https://gympulsr.com/blog/qt/2017/06/14/ios-background-music-qt.html

          1 Reply Last reply
          0
          • E Offline
            E Offline
            eiriham
            wrote on 27 Jul 2016, 11:13 last edited by
            #7

            This may be a bit off topic, but dont know where else to ask since QtService posts dont really seem to be getting answered.
            Using QtService, will only java code be run in the background or is it possible to run Qt/c++ code as well?

            D 1 Reply Last reply 9 Oct 2019, 18:58
            0
            • M Offline
              M Offline
              Mena
              wrote on 31 May 2017, 14:56 last edited by
              #8

              Can you please show us how to make this service run on booting the android phone?

              S 1 Reply Last reply 31 May 2017, 15:31
              1
              • M Mena
                31 May 2017, 14:56

                Can you please show us how to make this service run on booting the android phone?

                S Offline
                S Offline
                Schluchti
                wrote on 31 May 2017, 15:31 last edited by
                #9

                @Mena have a look at this article: https://www.kdab.com/qt-android-create-android-service-using-qt/

                Want to read more about Qt?

                https://gympulsr.com/blog/qt/

                Latest Article: https://gympulsr.com/blog/qt/2017/06/14/ios-background-music-qt.html

                M 1 Reply Last reply 1 Jun 2017, 07:54
                2
                • S Schluchti
                  31 May 2017, 15:31

                  @Mena have a look at this article: https://www.kdab.com/qt-android-create-android-service-using-qt/

                  M Offline
                  M Offline
                  Mena
                  wrote on 1 Jun 2017, 07:54 last edited by
                  #10

                  @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_example

                  It 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

                  1 Reply Last reply
                  1
                  • M Offline
                    M Offline
                    Mena
                    wrote on 4 Jun 2017, 11:24 last edited by
                    #11

                    ok, I was able to make the service run at boot time. Here's the solution:
                    https://stackoverflow.com/a/44353506/8086424

                    1 Reply Last reply
                    0
                    • E eiriham
                      27 Jul 2016, 11:13

                      This may be a bit off topic, but dont know where else to ask since QtService posts dont really seem to be getting answered.
                      Using QtService, will only java code be run in the background or is it possible to run Qt/c++ code as well?

                      D Offline
                      D Offline
                      donp
                      wrote on 9 Oct 2019, 18:58 last edited by
                      #12

                      @eiriham Were you able to get this question answered? My application is using QAndroidService and I would like to run code from Qt/c++? Thanks

                      1 Reply Last reply
                      0

                      • Login

                      • Login or register to search.
                      • First post
                        Last post
                      0
                      • Categories
                      • Recent
                      • Tags
                      • Popular
                      • Users
                      • Groups
                      • Search
                      • Get Qt Extensions
                      • Unsolved