After further research, it turned out that the multi-user api does not work yet, it cannot be used for anything. there is a hack, although to check if the user is the owner using reflections:
public boolean isCurrentUserOwner(Context context) { try { Method getUserHandle = UserManager.class.getMethod("getUserHandle"); int userHandle = (Integer) getUserHandle.invoke(context.getSystemService(Context.USER_SERVICE)); return userHandle == 0; } catch (Exception ex) { return false; } }
This works for me on Nexus 7 and Nexus 10 with Android 4.2.1. It's very dirty. therefore, I would not recommend using it if you are not making an application with this device and version
source share