androidandroid-multiple-users

How to know if the android device supports multi users?


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?


Solution

  • 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;
    }