[Interest] HowTo set Android --user (AndroidForWork) to run work app on device

ekke ekke at ekkes-corner.org
Fri Feb 17 09:15:05 CET 2017


Just doing my first AndroidForWork Qt App for one of my customers.
(QtQuickControls2)
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
<http://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


Perhaps I should create an Issue to place a AndroidUserId variable into
.pro and the Android Build process can add --user nn to the adb start cmd ?

thx for any help

also asked at Android list and in forum

-- 

ekke (ekkehard gentz)

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.qt-project.org/pipermail/interest/attachments/20170217/e021abf6/attachment.html>


More information about the Interest mailing list