Example usage for android.os UserManager getUserRestrictions

List of usage examples for android.os UserManager getUserRestrictions

Introduction

In this page you can find the example usage for android.os UserManager getUserRestrictions.

Prototype

public Bundle getUserRestrictions() 

Source Link

Document

Returns the user-wide restrictions imposed on this user.

Usage

From source file:Main.java

public static boolean isUnableToModifyAccounts(Context context) {
    UserManager um = (UserManager) context.getSystemService(Context.USER_SERVICE);
    Bundle restrictions = um.getUserRestrictions();
    return restrictions.getBoolean(UserManager.DISALLOW_MODIFY_ACCOUNTS, false);
}

From source file:Main.java

@SuppressLint("InlinedApi")
@TargetApi(Build.VERSION_CODES.JELLY_BEAN_MR2)
private static boolean hasSyncPermissions(Context context) {
    if (Build.VERSION.SDK_INT < Build.VERSION_CODES.JELLY_BEAN_MR2)
        return true;

    UserManager manager = (UserManager) context.getSystemService(Context.USER_SERVICE);
    Bundle userRestrictions = manager.getUserRestrictions();
    return !userRestrictions.getBoolean(UserManager.DISALLOW_MODIFY_ACCOUNTS, false);
}

From source file:com.commonsware.android.profile.device.MainActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    UserManager mgr = (UserManager) getSystemService(USER_SERVICE);
    Bundle restrictions = mgr.getUserRestrictions();

    if (restrictions.keySet().size() > 0) {
        setContentView(R.layout.activity_main);

        RestrictionsFragment f = (RestrictionsFragment) getSupportFragmentManager()
                .findFragmentById(R.id.contents);

        f.showRestrictions(restrictions);
    } else {//w  ww .  j  ava 2s  .c om
        Toast.makeText(this, R.string.no_restrictions, Toast.LENGTH_LONG).show();
        finish();
    }
}