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. Background application in Android

Background application in Android

Scheduled Pinned Locked Moved Unsolved Mobile and Embedded
7 Posts 4 Posters 2.6k 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.
  • yuvaramY Offline
    yuvaramY Offline
    yuvaram
    wrote on last edited by
    #1

    How to develop background application in android using Qt

    Yuvaram Aligeti
    Embedded Qt Developer
    : )

    1 Reply Last reply
    0
    • M Offline
      M Offline
      mvuori
      wrote on last edited by
      #2

      When you ask Google "How to develop background application in android using Qt" you get a lot of links that mention "services". Could that be a hint of something?

      1 Reply Last reply
      2
      • S Offline
        S Offline
        Schluchti
        wrote on last edited by
        #3

        Here is a very good introduction to Qt Android services: 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

        1 Reply Last reply
        3
        • M Offline
          M Offline
          Marek
          wrote on last edited by
          #4

          Hi

          Have you created the Android Service ?
          Can you test my example
          I was following https://www.kdab.com/qt-android-create-android-service-using-qt/
          But I have a problem, on my Android phone 4.2.2 service runs only when I have USB cable attached to the phone and if I disconnect, background process stops afer some 20 seconds.

          Best Regards
          Marek

          1 Reply Last reply
          1
          • M Offline
            M Offline
            Marek
            wrote on last edited by
            #5

            Hi

            Have you tested my example ?
            Does it stop to work when phone is unplugged ?

            Best Regards
            Marek

            1 Reply Last reply
            0
            • S Offline
              S Offline
              Schluchti
              wrote on last edited by
              #6

              I haven't tried it yet, but how do you determine that the service stops?

              By the way: Even if the background service doesn't stop immediately, you can't really rely that a service, once started, is available forever. As far as I know, the Android operating system can kill a service at any time if it needs more resources. If you want to have the service only available when the application is also running you could probably (haven't tested it yet) periodically check if the service is still running and if not, start it again.

              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
              • M Offline
                M Offline
                Marek
                wrote on last edited by
                #7

                Hi,

                I have edited my example description which is now:
                Service has QTimer with 1 second interval that increments variable "counter" and sends it to the application. Second counter is QTime difference between time when "counter" was started and "now" time. If service is running in background two counters should have the same readings.
                Installl the app, start it, reset counter, disconnect usb cable from the phone, lock the phone, and after some 30 seconds unlock the screen and counters will have different readings indicating that service actually stopped working after some 20 seconds, it wasn't killed, just freezed.

                Android services are less likely to be killed by the operating system than the application. They are designed for long term data operations and in fact if you check your Android phone I sure you will find that it has quite a few applications running in background, apps like alarm clock, push notifications and others.

                In fact I have noticed that if for some reason service crashes it is automatically restarted by the operating system, so they are quite reliable.

                Best Regards
                Marek

                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