Application In the background stop



  • Hi,
    my application stop after a long time when i press home button and lock the phone. Does anyone knows why is this happens?
    Also any suggestions about how i can stop this annoying behaviour?

    Thanks in advance!


  • Moderators

    @NickV said in Application In the background stop:

    Also any suggestions about how i can stop this annoying behaviour?

    If you talk about Android there is no way, since this is intended to behavior. The Android system manages the lifecycle of the app.
    If you depend on background functionality you should take a look at Android services.



  • Have you ever worked with postgres triggers and services?
    In order to make triggers work you should always be connected with the database and subscribed to the notifications.


  • Moderators

    @NickV
    as i said. If you have this requirement you need to use Android services (rather than App). The App then communicates with the Android Service.

    If you are working on Android afterall, since you didn't answer that question yet.

    But anyway, if it is all about a DB connection. Why do you need to be connected even if your app is in the background? Why don't you simple resetup the connection everytime the app comes back to the foreground, than drowning the device's battery with functionality which isn't necessary while the app is in the background?!



  • Yes i work with Android.
    I need to be all the time connected because i use notification manager in order to notify the user about incoming data. The problem is that if i use services i need to make the service reconnect to the database if i loose internet connection and subscribe again to the notifications. I don't even know if this is possible with the postgres driver because i've tested postegres to be opened in another thread for example and triggers not work. So i don't know if postgres works with services.


  • Moderators

    @NickV said in Application In the background stop:

    So i don't know if postgres works with services.

    There is not much difference between an App and a Service. A service runs permanently in the background and has no UI.
    From Qt point of view the difference is even less. So i don't see why it shouldn't work.

    1. create a Android service
    2. in the service setup your DB connection
    3. create an Android app
    4. use IPC to communicate with the service (e.g. you can use QtRemoteObjects for that)
    5. when the service triggers a notification message let the app display it

Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.