List of usage examples for android.os UserManager removeUser
@UnsupportedAppUsage public boolean removeUser(@UserIdInt int userHandle)
From source file:com.android.managedprovisioning.ProfileOwnerPreProvisioningActivity.java
/** * Builds a dialog that allows the user to remove an existing managed profile after they were * shown an additional warning./*www. ja v a2 s .co m*/ */ private void showManagedProfileExistsDialog(final int existingManagedProfileUserId) { // Before deleting, show a warning dialog DialogInterface.OnClickListener warningListener = new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { // Really delete the profile if the user clicks delete on the warning dialog. final DialogInterface.OnClickListener deleteListener = new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { UserManager userManager = (UserManager) getSystemService(Context.USER_SERVICE); userManager.removeUser(existingManagedProfileUserId); showStartProvisioningScreen(); } }; buildDeleteManagedProfileDialog(getString(R.string.sure_you_want_to_delete_profile), deleteListener) .show(); } }; buildDeleteManagedProfileDialog(getString(R.string.managed_profile_already_present), warningListener) .show(); }