How to know if the android device supports multi users?

2.1k Views Asked by At

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?

3

There are 3 best solutions below

0
On BEST ANSWER

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;
}
2
On

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   
}
3
On

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)