3

Android 4.2 supports multiple user spaces "on shareable devices such as tablets"(http://developer.android.com/about/versions/android-4.2.html#MultipleUsers). How do I know if a specific device is a "shareable device"?

Can I programmatically check if the device supports multiple users?

Xavi Gil
  • 11,460
  • 4
  • 56
  • 71
prograde
  • 2,620
  • 2
  • 23
  • 32
  • 2
    Not that I am aware of, unfortunately, at least in any reliable fashion. API Level 17 means the OS is capable of multiple user spaces, but whether or not there's a Settings option for it will vary. I think the plan is for tablet-sized things to have multiple users, and phone-sized things not, but that might wind up being the choice of the manufacturer. – CommonsWare Jan 14 '13 at 15:19

3 Answers3

3

There is a hidden API at UserManager.supportsMultipleUsers(). You can access this using the following method which uses reflection, though this technique is not normally recommended because the API could change in a later release.

public static boolean supportsMultipleUsers() {
  try {
  if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1) {
     // return UserManager.supportsMultipleUsers();
     return (Boolean(UserManager.class.getDeclaredMethod("supportsMultipleUsers").invoke(null));
  }
  catch (Exception e) {}
  return false;
}
Jo Jo
  • 7,245
  • 5
  • 34
  • 49
2

If it is enough for you to check if multiple users accounts have been created on the device, you can use UserManager.getUserCount() (after ensuring the SDK version is > 16).

I don't know if it's possible to distinguish if multiple users are theoretically possible, but only one has been used so far from no multi-user support at all.

EDIT: This solution does actually not work, it seems it requires a system-level permission. See here for details UserManager getUserCount() (Jelly Bean)

Community
  • 1
  • 1
Thrakbad
  • 2,728
  • 3
  • 23
  • 31
  • That's good, but it's not exactly what I wanted. But I assume then that there is no way to know if it's _possible_ to have multiple accounts. – prograde Jan 15 '13 at 07:37
  • Does it require any permission? According to this link: stackoverflow.com/q/13508258/878126 , it seems impossible to do it, as it's a system permission. Is it possible using root, perhaps? – android developer Apr 25 '15 at 20:20
  • Sorry for the very late reply. I actually never tried, but it seems that way based on this question: http://stackoverflow.com/q/13508258/1966616 – Thrakbad Sep 21 '15 at 11:20
-2

You can check the Android version with the following code:

int oSversion = Integer.valueOf(android.os.Build.VERSION.SDK_INT);

if (osVersion > 16) {
   // This phone supports multi-user   
}
Booger
  • 18,579
  • 7
  • 55
  • 72