Android UserManager: Check if user is owner (admin) -
im developing app latest android version (4.2.1 api-level 17) tablets multiuser capabilities.
i want restrict features (like access app preferences) owner of tablet (that user can add together , remove other user accounts)
is there way can find out if current user owner?
i read through usermanager , userhandle api docs couldn't find function allows me check it.
have missed or there way that?
similar without reflection:
static boolean isadminuser(context context) { userhandle uh = process.myuserhandle(); usermanager um = (usermanager) context.getsystemservice(context.user_service); if(null != um) { long userserialnumber = um.getserialnumberforuser(uh); log.d(tag, "userserialnumber = " + userserialnumber); homecoming 0 == userserialnumber; } else homecoming false; }
android android-4.2-jelly-bean
No comments:
Post a Comment