Example usage for android.os UserManager getApplicationRestrictions

List of usage examples for android.os UserManager getApplicationRestrictions

Introduction

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

Prototype

@WorkerThread
public Bundle getApplicationRestrictions(String packageName) 

Source Link

Document

Returns a Bundle containing any saved application restrictions for this user, for the given package name.

Usage

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

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

    UserManager mgr = (UserManager) getSystemService(USER_SERVICE);
    Bundle restrictions = mgr.getApplicationRestrictions(getPackageName());

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

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

        f.showRestrictions(restrictions);
    } else {/*w  w  w  .  j  a  v a  2  s  .  co m*/
        Toast.makeText(this, R.string.no_restrictions, Toast.LENGTH_LONG).show();
        finish();
    }
}