List of usage examples for android.content Context USER_SERVICE
String USER_SERVICE
To view the source code for android.content Context USER_SERVICE.
Click Source Link
From source file:dev.ukanth.ufirewall.Api.java
@TargetApi(Build.VERSION_CODES.JELLY_BEAN_MR1) public static void setUserOwner(Context context) { if (supportsMultipleUsers(context)) { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1) { try { Method getUserHandle = UserManager.class.getMethod("getUserHandle"); int userHandle = (Integer) getUserHandle.invoke(context.getSystemService(Context.USER_SERVICE)); G.setMultiUserId(userHandle); } catch (Exception ex) { Log.e(TAG, "Exception on setUserOwner " + ex.getMessage()); }/* ww w .j a v a 2 s . c om*/ } } }
From source file:dev.ukanth.ufirewall.Api.java
@SuppressLint("NewApi") public static boolean supportsMultipleUsers(Context context) { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1) { final UserManager um = (UserManager) context.getSystemService(Context.USER_SERVICE); try {//ww w . j a v a 2 s .c o m Method supportsMultipleUsers = UserManager.class.getMethod("supportsMultipleUsers"); return (Boolean) supportsMultipleUsers.invoke(um); } catch (Exception ex) { return false; } } return false; }