Create Android profile owner

This section shows you how to create an Android work profile on a Samsung Knox device.

When you tap CREATE MANAGED PROFILE, the profile is activated.

Creating an Android P.O is simple and only requires 2 steps:

  1. Create the SampleAdminReciever class
  2. Create the CreateAndroidProfile() method

Create the SampleAdminReceiver class

Create a class called SampleAdminReceiver, as shown below:

import android.content.ComponentName;
import android.content.Context;
import android.content.Intent;
import android.widget.Toast;

public class SampleAdminReceiver extends DeviceAdminReceiver {

    void showToast(Context context, CharSequence msg) {
        Toast.makeText(context, msg, Toast.LENGTH_SHORT).show();

    public void onEnabled(Context context, Intent intent) {
        showToast(context, "Device admin enabled");

    public void onDisabled(Context context, Intent intent) {
        showToast(context, "Device admin disabled");

    public void onProfileProvisioningComplete(Context context, Intent intent) {
        showToast(context, "Profile Provisioning Complete");
        DevicePolicyManager myDevicePolicyMgr = (DevicePolicyManager) context.getSystemService(Context.DEVICE_POLICY_SERVICE);
        ComponentName mDeviceAdmin = new ComponentName(context.getApplicationContext(), SampleAdminReceiver.class);
        myDevicePolicyMgr.setProfileName(mDeviceAdmin, "My New Work Profile");

Create the createAndroidProfile method

This method generates the Android profile. When it runs, it uses the SampleAdminReceiver class to complete the profile creation.

// Provision an Android profile owner
    private void createAndroidProfile() {
        Activity provisioningActivity = this;
        ComponentName deviceAdmin = new ComponentName(MainActivity.this, SampleAdminReceiver.class);
        // Set up the provisioning intent
        Intent provisioningIntent = new Intent("");
        provisioningIntent.putExtra(EXTRA_PROVISIONING_DEVICE_ADMIN_COMPONENT_NAME, deviceAdmin);

        if (provisioningIntent.resolveActivity(provisioningActivity.getPackageManager()) == null) {
            // No handler for intent! Can't provision this device.
            // Show an error message and cancel.
        } else {
            startActivityForResult(provisioningIntent, ACTIVITY_REQUEST_CODE);

Tutorial Progress

You are 3/6 done! Go to the next step.