1

What i am looking for, is a way to switch between existing profiles under some specific user, using DevicePolicyManager Class for android lollipop. I googled it from last two days but doesn't get a way to make it happen. I also looked on some previously asked questions on Stack-overflow and other similar forums but not found anything useful. It would be great for me, if any one can atleast answer me whether am looking for something impossible, or is there some other alternative way to do that, like by calling settings intent or similar. Also there is method switchUser(ComponentName admin, UserHandle userHandle) in DevicePolicyManager class to switch in between users. But similar is not exist for profiles. Thank You.

U.Swap
  • 1,921
  • 4
  • 23
  • 41

1 Answers1

0

I don't think that is possible. However, I don't understand why you want to switch between profiles. If the managed profile is set up, the app which started the provisioning process is copied to the profile and set as profile owner app. The profile owner app runs then in its own process. You cannot switch from the primary user app to the managed process.

Perhaps you could explain why you want to change to a profile.

Edit:

Definition of Device Owner and Profile Owner: Is it possible to have a "Profile Owner" app in Android Lollipop that is not co-present

The DeviceOwner example shows how the Device Owner is set up on Android. http://android-developers.blogspot.co.at/2015/04/new-android-code-samples.html

Another good post about provisioning a Device Owner with NFC: Device Owner on Android 5.0 (and others) whitout rooted devices, device provisioning by NFC

You can set a Device Owner using the command line tool dpm: How to make my app a device owner?

After your app (widget) is Device Owner you can use the method switchUser of the DevicePoliyManager to switch between user profiles. The UserManager provides you with a list of all profiles on the device.

UserManager um = (UserManager) getSystemService(USER_SERVICE);
List<UserHandle> userProfiles = um.getUserProfiles();
Community
  • 1
  • 1
  • Actually am looking to create widget app which list's all available profiles, and let me cycle through them. – U.Swap May 05 '15 at 12:42
  • You can easily show all users and switch to them, IF you are a device owner. However, the provisioning of a device owner app includes a factory reset [1](http://stackoverflow.com/questions/26565196/is-it-possible-to-have-a-profile-owner-app-in-android-lollipop-that-is-not-co) [2](http://florent-dupont.blogspot.fr/2015/02/10-things-to-know-about-device-owner.html) You can show the profile beside the corresponding user account and if one is selected switch to the user which includes the profile. – Lorenz Riedler May 05 '15 at 14:26
  • Exactly what am looking for, so is it possible the way u commented above. Can u please give me some example links to that, or reference links to P – U.Swap May 06 '15 at 04:15
  • To what u explained above. Also the user profile settings varries a bit from phone to tablets. So is it feasible for both. Thank you – U.Swap May 06 '15 at 07:29
  • Thank You, for the information you provided above, i will try it and acknowledge you soon. – U.Swap May 08 '15 at 08:09
  • Also, i would like to ask you, as you said once i get the list of profiles by using your provided code snippet. Then i believe in lollipop profiles are also treated as type of "user". Then by using switchUser method of the DevicePoliyManager class will switch between the profiles.Am I correct? Thanx. – U.Swap May 08 '15 at 11:42