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. Android service not running at device boot
Forum Updated to NodeBB v4.3 + New Features

Android service not running at device boot

Scheduled Pinned Locked Moved Solved Mobile and Embedded
7 Posts 2 Posters 1.9k Views 2 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 Offline
    S Offline
    software.it
    wrote on 11 Sept 2020, 09:40 last edited by
    #1

    Hello,
    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

    Thanks

    1 Reply Last reply
    0
    • K Offline
      K Offline
      KoneTaH
      wrote on 13 Sept 2020, 10:38 last edited by
      #2

      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.

      1 Reply Last reply
      1
      • S Offline
        S Offline
        software.it
        wrote on 16 Sept 2020, 12:30 last edited by
        #3

        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.

        K 1 Reply Last reply 16 Sept 2020, 12:36
        0
        • S software.it
          16 Sept 2020, 12:30

          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.

          K Offline
          K Offline
          KoneTaH
          wrote on 16 Sept 2020, 12:36 last edited by
          #4

          @software-it said in Android service not running at device boot:

          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.

          1 Reply Last reply
          0
          • S Offline
            S Offline
            software.it
            wrote on 16 Sept 2020, 12:51 last edited by
            #5

            I understand.
            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.

            Thanks

            K 1 Reply Last reply 16 Sept 2020, 12:54
            0
            • S software.it
              16 Sept 2020, 12:51

              I understand.
              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.

              Thanks

              K Offline
              K Offline
              KoneTaH
              wrote on 16 Sept 2020, 12:54 last edited by
              #6

              Here is an example of Qt app for Android with foreground service that starts on device boot:

              https://github.com/vkgeo/vkgeo-android

              1 Reply Last reply
              2
              • S Offline
                S Offline
                software.it
                wrote on 17 Sept 2020, 09:07 last edited by
                #7

                Thank you! It was useful to me

                1 Reply Last reply
                0

                1/7

                11 Sept 2020, 09:40

                • Login

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