9

I need to launch an app which is in different work profile (Android For Work). If install the app in personal profile then I am able to launch the app from the personal profile on the same device.

However, When I install the app only in the work profile then I am not able to launch the app through adb command.

As per my understanding, google keeps two different containers for personal and work profile. I think the work profile has different space and adb does not have any access to that app and workspace of work profile.

I need to launch the app through appium

If anyone has the answer to the above problem, please answer. Thanks in Advance !

Vinod
  • 956
  • 7
  • 15

3 Answers3

3

Do you mean launching application on different user account ? check this link please : https://stackoverflow.com/a/24093533/5093606 You can get try to get list of accounts using

adb shell pm list users

and if you working account is there, try

adb shell am start --user WORKING_ACCOUNT com.example.MainActivity
Community
  • 1
  • 1
Andriy
  • 550
  • 5
  • 15
  • Thanks for your answer. I need to launch the app through appium. Is there any way we can mention user details in appium capabilities? – Vinod Apr 20 '17 at 09:44
  • @Vinod I never used appium, but I think it's possible to use adb operations there. Take a look in [this](https://github.com/appium/appium-adb) project, maybe it can help you – Andriy Apr 20 '17 at 09:51
  • Seems I need to modify the source code as per my requirement and compile again. Anyway Thanks for your suggestion. :) – Vinod Apr 20 '17 at 10:44
0

Yes, there is way to launch the apps by using Appium/Adb commands. Instead of appium use adb commands to launch the apps.

The app which you have used for AndroidForWork enrollment, it should be in android:debuggable mode. Set debuggable mode to true and build the apk.

Once the device is enrolled/Configured Androidfor work then get the list of users.

adb shell pm list users UserInfo{0:Drew:13} running UserInfo{10:Work profile:30} running

Get the workprofile user id. In this case 10 is the id. Use the user id to launch the apps.

adb shell am start --user 10 -n "com.android.vending/com.google.android.finsky.activities.MainActivity"

Note: If the provision app is not enabled in Debug mode then you don't have the access to the work profile user.

Sridhar Reddy S
  • 121
  • 2
  • 13
  • You should make a comment and not an answer! – oikonomopo May 26 '17 at 11:10
  • I don't have reputation points to add a comment :( Hence I have added here. Please let me know if you have any answer for this. – Sridhar Reddy S May 26 '17 at 11:13
  • @oikonomopo And you should not edit a post that is Not An Answer. :) The usual course is to downvote, and, most importantly, to flag as NAA so that it can eventually be deleted. – Eric Aya May 26 '17 at 14:36
  • @Eric Aya i understand what you say, but we should have a more welcome behaviour to new users! We should care to help/guide etc and not threaten them! – oikonomopo May 26 '17 at 14:48
  • @user3496995 I agree that the site should be more welcoming to new users, but still, the site rules are pretty clear that the Answer section should only be used for actual attempts to answer the question. We can't make an exception just because you don't have enough reputation to comment yet. – EJoshuaS - Stand with Ukraine May 26 '17 at 19:37
0

Turns out I was able to accomplish this with Appium Desktop by adding another parameter to the inspector:

optionalIntentArguments text --user 12

Where '12' is the work profile id you'd see from typing this:

adb -d shell pm list users
Users:
    UserInfo{0:Ken Corey:13} running
    UserInfo{12:Workspace:50100030} running
Ken Corey
  • 435
  • 3
  • 15