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. HowTo run Android from QtC with --user
Forum Updated to NodeBB v4.3 + New Features

HowTo run Android from QtC with --user

Scheduled Pinned Locked Moved Solved Mobile and Embedded
androidandroidforwork
7 Posts 3 Posters 2.2k 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.
  • ekkescornerE Offline
    ekkescornerE Offline
    ekkescorner
    Qt Champions 2016
    wrote on last edited by ekkescorner
    #1

    Just doing my first AndroidForWork App for one of my customers.
    Will blog about the details later.

    With AndroidForWork (AfW) your Android device is managed by IT and there are private apps and work apps.
    I managed to deploy app to Android Device from QtC.
    Sideloading Apps to AfW devices the app will be installed as private and work app.
    https://developer.android.com/work/managed-profiles.html#testing_apps
    QtC does this well.
    But then QtC runs the private App. This is because QtC uses the default User.
    With AfW there are 2 users. You can list them:

    adb shell pm list users
    

    private user has always ID 0 and Work User will have another ID - I always have seen ID 10.
    I can run the Work App I deployed using QtC from this command:

    adb shell am start --user 10 -n my.package.name/org.qtproject.qt5.android.bindings.QtActivity
    

    So my question: HowTo tell QtC to use an extra argument '--user 10' while starting the APK ?
    As a mobile business app developer I don't have so much knowledge about QtC Android BuildProcess.
    From QtC developer list I got a hint to use a custom Run Configuration.
    So I entered:
    Executable: adb
    Arguments: shell am start --user 10 -n my.package.name/org.qtproject.qt5.android.bindings.QtActivity
    WorkingDir: %{buildDir}
    Tried with or without checking the 'Run in terminal box'
    but getting an error:

    Cannot find the androiddeploy Json file.
    Error while building/deploying project my_project (kit: Android for armeabi-v7a (GCC 4.9, Qt 5.7.0))
    When executing step "Deploy to Android device"
    

    curious: I did no changes to deployment. it's still saying 'Deploy to Android Device'

    would be cool to manage AndroidForWork completely from inside QtC.

    BTW: I'm on OSX and Device is connected via USB

    At the moment my workflow is something like this:

    • deploy and run from QtC (deploys private and work app and runs private app)
    • exit the private app on Android Device
    • run work app from my Mac (adb start --user10 - see above-
    • Terminal: adb start-server
    • Run OSX App LogRabbit (http://lograbbit.com/ ) to monitor the Android LogCat output

    Of course would be much easier to run the work app from QtC and to watch logs from ApplicationOutput Pane in QtC

    thx for any help

    ekke ... Qt Champion 2016 | 2024 ... mobile business apps
    5.15 --> 6.8 https://t1p.de/ekkeChecklist
    QMake --> CMake https://t1p.de/ekkeCMakeMobileApps

    1 Reply Last reply
    0
    • ekkescornerE Offline
      ekkescornerE Offline
      ekkescorner
      Qt Champions 2016
      wrote on last edited by
      #7

      cool: Qt Creator 4.4 will have run settings. So starting the Android Work App with --user 10 will be easy:
      https://bugreports.qt.io/browse/QTCREATORBUG-17862

      ekke ... Qt Champion 2016 | 2024 ... mobile business apps
      5.15 --> 6.8 https://t1p.de/ekkeChecklist
      QMake --> CMake https://t1p.de/ekkeCMakeMobileApps

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

        Hi,

        You should take a look at Qt Creator's AndroidRunner class, that might get you what you want.

        Hope it helps

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

        ekkescornerE 1 Reply Last reply
        1
        • tekojoT Offline
          tekojoT Offline
          tekojo
          wrote on last edited by
          #3

          Hi @ekkescorner
          I see you posted on the Android-development mailing list too, that is good.
          You could try the Interest list too.

          You might be among the first AfW Qt developers out there.

          ekkescornerE 1 Reply Last reply
          0
          • tekojoT tekojo

            Hi @ekkescorner
            I see you posted on the Android-development mailing list too, that is good.
            You could try the Interest list too.

            You might be among the first AfW Qt developers out there.

            ekkescornerE Offline
            ekkescornerE Offline
            ekkescorner
            Qt Champions 2016
            wrote on last edited by
            #4

            @tekojo said in HowTo run Android from QtC with --user:

            Hi @ekkescorner
            I see you posted on the Android-development mailing list too, that is good.
            You could try the Interest list too.

            You might be among the first AfW Qt developers out there.

            yep. there are not so many out there but it's an important topic for Google and Enterprise -
            and it will be a door-opener forr Qt @ enterprise if development-cycle is smooth

            ekke ... Qt Champion 2016 | 2024 ... mobile business apps
            5.15 --> 6.8 https://t1p.de/ekkeChecklist
            QMake --> CMake https://t1p.de/ekkeCMakeMobileApps

            1 Reply Last reply
            0
            • SGaistS SGaist

              Hi,

              You should take a look at Qt Creator's AndroidRunner class, that might get you what you want.

              Hope it helps

              ekkescornerE Offline
              ekkescornerE Offline
              ekkescorner
              Qt Champions 2016
              wrote on last edited by
              #5

              @SGaist said in HowTo run Android from QtC with --user:

              Hi,

              You should take a look at Qt Creator's AndroidRunner class, that might get you what you want.

              Hope it helps

              thx for the info, but I have no idea what to do
              have in mind I'm a mobile business app developer relying on IDE doing all the 'dirty' jobs for me ;-)

              perhaps I should open an Issue to put something like a AndroidUserId variable into .pro and QtC Android buildprocess includes --user nn into adb start if this var is set

              ekke ... Qt Champion 2016 | 2024 ... mobile business apps
              5.15 --> 6.8 https://t1p.de/ekkeChecklist
              QMake --> CMake https://t1p.de/ekkeCMakeMobileApps

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

                Sorry, you are right I didn't take that point into account. I was thinking about that class as a likely place to start looking at in order to modify Qt Creator to fit your needs.

                Personally, I think it would make more sense to see that in Qt Creator's project configuration panel.

                I'd recommend opening a feature request about that matter for Qt Creator.

                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
                • ekkescornerE Offline
                  ekkescornerE Offline
                  ekkescorner
                  Qt Champions 2016
                  wrote on last edited by
                  #7

                  cool: Qt Creator 4.4 will have run settings. So starting the Android Work App with --user 10 will be easy:
                  https://bugreports.qt.io/browse/QTCREATORBUG-17862

                  ekke ... Qt Champion 2016 | 2024 ... mobile business apps
                  5.15 --> 6.8 https://t1p.de/ekkeChecklist
                  QMake --> CMake https://t1p.de/ekkeCMakeMobileApps

                  1 Reply Last reply
                  1

                  • Login

                  • Login or register to search.
                  • First post
                    Last post
                  0
                  • Categories
                  • Recent
                  • Tags
                  • Popular
                  • Users
                  • Groups
                  • Search
                  • Get Qt Extensions
                  • Unsolved