2

I have this qml application:

Window {
    visible: true
    Timer {
        onTriggered: console.log("foo")
        interval: 100
        repeat: true
        running: true
    }
}

on my pc it works but when I run it on Android and I put the app into the background the Timer stops from triggering signals.

How can I make it work correctly on Android?

I'm using Qt 5.5 and I wish to run the app on Android >= 5.1.

lambdauser
  • 183
  • 1
  • 8
  • Possible dup of http://stackoverflow.com/questions/22752201/qml-timer-not-triggered-in-the-right-interval. – Prasanna Nov 30 '15 at 14:56
  • @Prasanna that question seems to be more related in how to show a timer (and for doing that you don't need to run code when the app is in the background). I've found this https://bugreports.qt.io/browse/QTBUG-45019 which seems to say that it's not possible to do this with qt but it must be done in another thread without using any qt stuff. – lambdauser Nov 30 '15 at 15:16
  • You can add `` to your manifest file to ensure that the app keeps running even when sent to background. Keep in mind that 1) crashes can occur due to unexpected drawing from the Qt thread, 2) even if the application runs and `Timer` expires correctly it is not guaranteed to run indefinitely, 3) your application can easily become a battery drainer. Consider the usage of a `Service`. It can be implemented in Java and interfaced with your Qt activity. Using a `Service` you avoid (almost) all the above poblems at once. – BaCaRoZzo Dec 01 '15 at 08:43

0 Answers0