Reputation: 2740
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?
Upvotes: 3
Views: 2307
Reputation: 2738
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)
Upvotes: 2
Reputation: 7335
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;
}
Upvotes: 3
Reputation: 18725
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
}
Upvotes: -2