Create Android Profile owner

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

This is activated when you press CREATE MANAGED PROFILE.

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

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

SampleAdminReciever class

Create a class called SampleAdminReciever, 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");

CreateAndroidProfile method

This method creates the Android Profile. When it runs, it uses the SampleAdminReciever class to complete the profile creation.

// Provision an Android Profile Owner
    private void createAndroidProfile() {

        Activity provisioningActivity = this;
        // Set up the provisioning intent
        Intent provisioningIntent = new Intent("");
        if (provisioningIntent.resolveActivity(provisioningActivity.getPackageManager()) == null) {
            // No handler for intent! Can't provision this device.
            // Show an error message and cancel.
        } else {
            startActivityForResult(provisioningIntent, 1);

Tutorial Progress

You are 4/7 done! Go to the next step.

Share it: