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. Postgres and Threads
Forum Updated to NodeBB v4.3 + New Features

Postgres and Threads

Scheduled Pinned Locked Moved Unsolved Mobile and Embedded
10 Posts 3 Posters 2.1k Views
  • 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.
  • NickVN Offline
    NickVN Offline
    NickV
    wrote on last edited by
    #1

    Hi,
    i want to open a database connection to another thread and in this connection instance i want to subscribed into notifications. The problem is that notify not work in this case. When i open database in the main thread everything works good. But is necessary to open the database connection to another thread in order to be able to receive even when the app is in the background or when the screen of the mobile is off.

    Any ideas?

    1 Reply Last reply
    0
    • G Offline
      G Offline
      Gourmet
      wrote on last edited by
      #2

      How this is specific to Mobile and Embedded? You should ask in General and Desktop topic group.

      1 Reply Last reply
      0
      • NickVN Offline
        NickVN Offline
        NickV
        wrote on last edited by
        #3

        Because postgres driver for android has the problem with the threads.

        jsulmJ G 2 Replies Last reply
        0
        • NickVN NickV

          Because postgres driver for android has the problem with the threads.

          jsulmJ Offline
          jsulmJ Offline
          jsulm
          Lifetime Qt Champion
          wrote on last edited by
          #4

          @NickV How can a second thread help in case the app is in background? For that on Android (don't know about iOS) you need a background service.

          https://forum.qt.io/topic/113070/qt-code-of-conduct

          1 Reply Last reply
          0
          • NickVN NickV

            Because postgres driver for android has the problem with the threads.

            G Offline
            G Offline
            Gourmet
            wrote on last edited by Gourmet
            #5

            @NickV you need allow your application run in Android background. This does not relate to multithreading but to AndroidManifest.xml setting instead.

            <meta-data android:name="android.app.background_running" android:value="true"/>

            1 Reply Last reply
            1
            • NickVN Offline
              NickVN Offline
              NickV
              wrote on last edited by
              #6

              @Gourmet your solution is not completed. I've read that i should create a service and then run the service in the background. https://doc.qt.io/qt-5.10/androidservices.html
              But i don't know how to create a service in order to run it in the background. Any good tutorial will be great!
              Thanks in advance!

              1 Reply Last reply
              0
              • NickVN Offline
                NickVN Offline
                NickV
                wrote on last edited by
                #7

                @Gourmet my mistake! Now it works with your solution! I'll try some tests!

                1 Reply Last reply
                0
                • NickVN Offline
                  NickVN Offline
                  NickV
                  wrote on last edited by
                  #8

                  @Gourmet i've tested your solution. Everything worked for about one hour. But again the postgres notification signal stop working after a long time. This happens only when the app is in the background for a long time.

                  G 1 Reply Last reply
                  0
                  • NickVN NickV

                    @Gourmet i've tested your solution. Everything worked for about one hour. But again the postgres notification signal stop working after a long time. This happens only when the app is in the background for a long time.

                    G Offline
                    G Offline
                    Gourmet
                    wrote on last edited by
                    #9

                    @NickV check for the some apps dispatching application can kill this process for battery optimization.

                    1 Reply Last reply
                    0
                    • NickVN Offline
                      NickVN Offline
                      NickV
                      wrote on last edited by
                      #10

                      @Gourmet thanks again. I hope to figure out what is going wrong! I believe that the problem is with the postgres driver. I believe it stops subscriptions. I will check if i am correct with this and then i will think a possible solution. Thanks again!

                      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