harmony 鸿蒙ExtensionAbility Overview

  • 2023-02-03
  • 浏览 (702)

ExtensionAbility Overview

The ExtensionAbility component is used for specific scenarios such as widget development and input method development.

The system defines an ExtensionAbility type for every specific scenario. You can use (implement and access) only the types that have been defined. All types of ExtensionAbility components are managed by the corresponding system services in a unified manner. For example, the InputMethodExtensionAbility component is managed by the input method management service.

The table below lists the ExtensionAbility types defined in the system.

NOTE

  • The column Allow Third-Party Apps to Implement specifies whether third-party applications can inherit the ExtensionAbility parent class and implement their own service logic for a type of ExtensionAbility. The value Y means that third-party applications can implement their own service logic for a type of ExtensionAbility, N means the opposite.
  • The column Allow Third-Party Apps to Access specifies whether third-party applications can access external services provided by a type of ExtensionAbility. The value Y means that third-party applications can access external services provided by a certain type of ExtensionAbility, N means that they cannot access external services, and NA means that no external services are provided.

System applications are not restricted. They can implement all the ExtensionAbility types defined in the system and access external services provided by all the ExtensionAbility types.

Supported ExtensionAbility Type Description Allow Third-Party Apps to Implement Allow Third-Party Apps to Access
FormExtensionAbility ExtensionAbility component of the form type, which provides APIs related to widgets. Y N
WorkSchedulerExtensionAbility ExtensionAbility component of the work_scheduler type, which provides callbacks for deferred tasks. Y NA
InputMethodExtensionAbility ExtensionAbility component of the input_method type, which is used to develop input method applications. Y Y
AccessibilityExtensionAbility ExtensionAbility component of the accessibility type, which provides APIs related to the accessibility feature. Y NA
ServiceExtensionAbility ExtensionAbility component of the service type, which provides APIs related to background services for system applications. To implement background transaction processing for non-system applications, use background tasks. N Y
DataShareExtensionAbility ExtensionAbility component of the data_share type, which provides APIs for data sharing. N Y
StaticSubscriberExtensionAbility ExtensionAbility component of the static_subscriber type, which provides APIs for static subscription to common events. N NA
WindowExtensionAbility ExtensionAbility component of the window type, which provides window extension APIs for system applications so that a system application can be embedded in and displayed over another application. N NA
EnterpriseAdminExtensionAbility ExtensionAbility component of the enterprise_admin type, which provides APIs for managing enterprise device events, such as application installation events on devices and events indicating too many incorrect screen-lock password attempts. N NA
DriverExtensionAbility ExtensionAbility component of the driver type, which provides the driver-related extension framework. Y Y

Accessing ExtensionAbility of the Specified Type

Each type of ExtensionAbility component is started by the corresponding system management service, rather than applications, so that its lifecycle is under system control. The caller of the ExtensionAbility component does not need to care about its lifecycle.

The following uses InputMethodExtensionAbility as an example. As shown in the figure below, when an application calls the InputMethodExtensionAbility component, the input method management service is called first. The input method management service starts the InputMethodExtensionAbility component, returns the component to the application, and starts to manage its lifecycle.

Figure 1 Using the InputMethodExtensionAbility component

ExtensionAbility-start

Implementing ExtensionAbility of the Specified Type

The following uses FormExtensionAbility as an example. The widget framework provides the base class FormExtensionAbility. You can derive this base class to create your own class (for example, MyFormExtensionAbility) and implement the callbacks, such as onCreate() and onUpdateForm(), to provide specific widget features. For details, see FormExtensionAbility.

You do not need to care when to add or delete a widget. The lifecycle of the FormExtensionAbility instance and the lifecycle of the ExtensionAbility process where the FormExtensionAbility instance is located are managed by FormManagerService.

form_extension

NOTE

For an application, all ExtensionAbility components of the same type run in an independent process, whereas the UIAbility, ServiceExtensionAbility, and DataShareExtensionAbility components run in another independent process. For details, see Process Model (Stage Model).

你可能感兴趣的鸿蒙文章

harmony 鸿蒙Application Models

harmony 鸿蒙Using Explicit Want to Start an Application Component

harmony 鸿蒙Using Implicit Want to Open a Website

harmony 鸿蒙AbilityStage Component Container

harmony 鸿蒙Accessing a DataAbility

harmony 鸿蒙Accessing a DataShareExtensionAbility from the FA Model

harmony 鸿蒙AccessibilityExtensionAbility

harmony 鸿蒙Common action and entities Values

harmony 鸿蒙API Switching Overview

harmony 鸿蒙Switching of app and deviceConfig

0  赞