1e41f4b71Sopenharmony_ci# EnterpriseAdminExtensionAbility Development 2e41f4b71Sopenharmony_ci 3e41f4b71Sopenharmony_ci## Introduction 4e41f4b71Sopenharmony_ci 5e41f4b71Sopenharmony_ci**EnterpriseAdminExtensionAbility** is an essential component for device administrator applications. When developing a Mobile Device Management (MDM) application, you need to create an **EnterpriseAdminExtensionAbility** instance and implement MDM service logic in this instance. The **EnterpriseAdminExtensionAbility** instance implements notifications of system management status changes and defines the related callbacks to be invoked when a device administrator application is enabled or disabled or when an application is installed or uninstalled. 6e41f4b71Sopenharmony_ci 7e41f4b71Sopenharmony_ci### Available APIs 8e41f4b71Sopenharmony_ci 9e41f4b71Sopenharmony_ci| Class | API | Description | 10e41f4b71Sopenharmony_ci| ------------------------------- | ----------------------------------------- | ---------------------------- | 11e41f4b71Sopenharmony_ci| EnterpriseAdminExtensionAbility | onAdminEnabled(): void | Called when a device administrator application is disabled. | 12e41f4b71Sopenharmony_ci| EnterpriseAdminExtensionAbility | onAdminDisabled(): void | Called when a device administrator application is disabled. | 13e41f4b71Sopenharmony_ci| EnterpriseAdminExtensionAbility | onBundleAdded(bundleName: string): void | Called when an MDM application is installed. | 14e41f4b71Sopenharmony_ci| EnterpriseAdminExtensionAbility | onBundleRemoved(bundleName: string): void | Called when an MDM application is uninstalled. | 15e41f4b71Sopenharmony_ci 16e41f4b71Sopenharmony_ci**onAdminEnabled**: This callback is invoked when an enterprise administrator or employee deploys an MDM application and activates the device administrator. The system notifies the device administrator application that the DeviceAdmin permission has been activated. The device administrator application can set initialization policies in the **onAdminEnabled** callback. 17e41f4b71Sopenharmony_ci 18e41f4b71Sopenharmony_ci**onAdminDisabled**: This callback is invoked when the system or an employee deactivates the device administrator. It notifies the application that the DeviceAdmin permission is revoked. The application can inform the enterprise administrator that the device is not under management. 19e41f4b71Sopenharmony_ci 20e41f4b71Sopenharmony_ci**onBundleAdded**: The enterprise administrator can subscribe to application installation events. When an application is installed on an enterprise device, the device administrator application reports the event in this callback to notify the enterprise administrator. 21e41f4b71Sopenharmony_ci 22e41f4b71Sopenharmony_ci**onBundleRemoved**: The enterprise administrator can subscribe to application uninstallation events. When an application is uninstalled from an enterprise device, the device administrator application reports the event in this callback to notify the enterprise administrator. 23e41f4b71Sopenharmony_ci 24e41f4b71Sopenharmony_ci## How to Develop 25e41f4b71Sopenharmony_ci 26e41f4b71Sopenharmony_ci1. Create a project. 27e41f4b71Sopenharmony_ci 28e41f4b71Sopenharmony_ci The project structure is as follows: 29e41f4b71Sopenharmony_ci 30e41f4b71Sopenharmony_ci  31e41f4b71Sopenharmony_ci 32e41f4b71Sopenharmony_ci2. Create an **ExtensionAbility** of the **EnterpriseAdmin** type, that is, an **EnterpriseAdminExtensionAbility** instance. 33e41f4b71Sopenharmony_ci 34e41f4b71Sopenharmony_ci  35e41f4b71Sopenharmony_ci 36e41f4b71Sopenharmony_ci3. Open the **EnterpriseAdminAbility.ets** file, import the **EnterpriseAdminExtensionAbility** module, enable it to inherit from the **EnterpriseAdminExtensionAbility** module, and define callbacks such as **onAdminEnabled()** and **onAdminDisabled()**. When the device administrator application is enabled or disabled, the callback will be invoked to receive notifications. 37e41f4b71Sopenharmony_ci 38e41f4b71Sopenharmony_ci ```ts 39e41f4b71Sopenharmony_ci import { EnterpriseAdminExtensionAbility } from '@kit.MDMKit'; 40e41f4b71Sopenharmony_ci 41e41f4b71Sopenharmony_ci export default class EnterpriseAdminAbility extends EnterpriseAdminExtensionAbility { 42e41f4b71Sopenharmony_ci // Callback to be invoked when the device administrator application is enabled. Initialization policy can be set in this callback. 43e41f4b71Sopenharmony_ci onAdminEnabled() { 44e41f4b71Sopenharmony_ci console.info("onAdminEnabled"); 45e41f4b71Sopenharmony_ci } 46e41f4b71Sopenharmony_ci 47e41f4b71Sopenharmony_ci // Callback to be invoked when the device administrator application is disabled. This callback can be used to notify the enterprise administrator application that the device is no longer under management. 48e41f4b71Sopenharmony_ci onAdminDisabled() { 49e41f4b71Sopenharmony_ci console.info("onAdminDisabled"); 50e41f4b71Sopenharmony_ci } 51e41f4b71Sopenharmony_ci 52e41f4b71Sopenharmony_ci // Callback to be invoked when an application is installed. This callback can be used to report events. 53e41f4b71Sopenharmony_ci onBundleAdded(bundleName: string) { 54e41f4b71Sopenharmony_ci console.info("EnterpriseAdminAbility onBundleAdded bundleName:" + bundleName); 55e41f4b71Sopenharmony_ci } 56e41f4b71Sopenharmony_ci 57e41f4b71Sopenharmony_ci // Callback to be invoked when an application is uninstalled. This callback can be used to report events. 58e41f4b71Sopenharmony_ci onBundleRemoved(bundleName: string) { 59e41f4b71Sopenharmony_ci console.info("EnterpriseAdminAbility onBundleRemoved bundleName" + bundleName); 60e41f4b71Sopenharmony_ci } 61e41f4b71Sopenharmony_ci }; 62e41f4b71Sopenharmony_ci ``` 63e41f4b71Sopenharmony_ci 64e41f4b71Sopenharmony_ci4. In the [module.json5](https://developer.huawei.com/consumer/en/doc/harmonyos-guides-V2/module-configuration-file-0000001427744540-V2) file of the project module, register **EnterpriseAdminAbility** as **ExtensionAbility**, and set type to **enterpriseAdmin** and **srcEntry** to the code path of the **ExtensionAbility** component. 65e41f4b71Sopenharmony_ci 66e41f4b71Sopenharmony_ci```ts 67e41f4b71Sopenharmony_ci"extensionAbilities": [ 68e41f4b71Sopenharmony_ci { 69e41f4b71Sopenharmony_ci "name": "EnterpriseAdminAbility", 70e41f4b71Sopenharmony_ci "type": "enterpriseAdmin", 71e41f4b71Sopenharmony_ci "exported": true, 72e41f4b71Sopenharmony_ci "srcEntry": "./ets/enterpriseadminability/EnterpriseAdminAbility.ets" 73e41f4b71Sopenharmony_ci } 74e41f4b71Sopenharmony_ci] 75e41f4b71Sopenharmony_ci``` 76e41f4b71Sopenharmony_ci 77