Example usage for android.app.admin DevicePolicyManager setProfileEnabled

List of usage examples for android.app.admin DevicePolicyManager setProfileEnabled

Introduction

In this page you can find the example usage for android.app.admin DevicePolicyManager setProfileEnabled.

Prototype

public void setProfileEnabled(@NonNull ComponentName admin) 

Source Link

Document

Sets the enabled state of the profile.

Usage

From source file:com.example.android.apprestrictionenforcer.EnableProfileActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    if (null == savedInstanceState) {
        // Enable the newly created profile
        DevicePolicyManager manager = (DevicePolicyManager) getSystemService(Context.DEVICE_POLICY_SERVICE);
        ComponentName componentName = EnforcerDeviceAdminReceiver.getComponentName(this);
        manager.setProfileName(componentName, getString(R.string.profile_name));
        manager.setProfileEnabled(componentName);
    }//from w ww.jav  a  2s  .c om
    // Open the main screen
    startActivity(new Intent(this, MainActivity.class));
    finish();
}