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. Multiple QT Applications (activities) in one APK
Forum Updated to NodeBB v4.3 + New Features

Multiple QT Applications (activities) in one APK

Scheduled Pinned Locked Moved Mobile and Embedded
android
5 Posts 2 Posters 2.7k Views 3 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.
  • P Offline
    P Offline
    PeJo
    wrote on last edited by
    #1

    I am wondering if it is somehow possible to have multiple QT (QML) applications (activities) in one APK?

    First let me explain a little about how my application is partitioned on Windows where everything now is working as it should.

    • I have one service that is always running in the background and doing the job.
    • I have one management application used to configure everything. This app uses QT.
    • I have one user application that is unique for each user and displays notifications and information relevant to this user. This app uses QT and has a tray icon.

    On Andorid I would like to do something similar. I therfore would like to have all three parts in on APK. I have the management application (Android Activity via QtActivity) and service (Android Service via JNI) working but I have not been able to add the user application. If I add the shared library that contains the user application in the APK, without even adding it to the manifest, the Managemen application does not work anymore. I am guessing there is a problem with multiple symbols in the libraries.
    So I am wondering if there is any way around it?

    Btw, I build everything with CMake (bulds all c++ and generates grandle build files for the APK via androiddeployqt).

    Perhaps my only option is to build the GUI for the user application in Java, if I need it to have only one APK. This gui is not that extensive so perhaps it is the easiest way.

    1 Reply Last reply
    0
    • P Offline
      P Offline
      PeJo
      wrote on last edited by
      #2

      I now have it working somewhat. I had the libraries for my service and the user app specified as "android-extra-libs" in the file qt-deploy.json. This added the libraries to the package wich I wanted but it also loaded the libraries when starting the activity. So instead a made sure the libraries are copied into the libs folder after androiddeployqt has run but before the gradle build.
      So my my cmake project now first builds all my C++ code, runs androiddeployqt, copies my own shared libraries to libs and then start the gradle build, so that seems quite nice! I put both activities in their own process and thought that I had solved it.

      But......
      It is still not really working. I can launch one application at a time but if I launch one application and then put it in the background and launch the other application, then the first application is displayed. I think it is because the QtActivity code calls static method QtApplication.invokeDelegate and since it is static it will send it to the wrong place.
      So is there a way around this? I think I maybe can solve it if I start to change the QtActivity and QtApplication classes but I don't really like this.

      1 Reply Last reply
      0
      • P Offline
        P Offline
        PeJo
        wrote on last edited by
        #3

        Now It works, I had to have different taskAffinity on the two activities. So it had nothing to do with QT.

        1 Reply Last reply
        0
        • SGaistS Offline
          SGaistS Offline
          SGaist
          Lifetime Qt Champion
          wrote on last edited by
          #4

          Hi and welcome to devnet,

          Glad you found a solution !

          Your project setup looks like something more users might encounter or like to do, would mind sharing how you did that ? e.g. through a wiki article

          Interested in AI ? www.idiap.ch
          Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

          1 Reply Last reply
          0
          • P Offline
            P Offline
            PeJo
            wrote on last edited by
            #5

            So much to do and so little time....
            For CMake build for android I used the following: https://github.com/LaurentGomila/qt-android-cmake.

            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