@ohos.app.ability.common (Ability Common Module)

The module provides pure type definitions for common capabilities within Ability Kit, including various context objects, callback interfaces, and data structures. It exports type declarations only and does not include any implementation logic or executable code.

NOTE

The initial APIs of this module are supported since API version 9. Newly added APIs will be marked with a superscript to indicate their earliest API version.

Modules to Import

import { common } from '@kit.AbilityKit';

UIAbilityContext

type UIAbilityContext = _UIAbilityContext.default

Defines the context environment for the UIAbility. It inherits from Context.

Atomic service API: This API can be used in atomic services since API version 11.

System capability: SystemCapability.Ability.AbilityRuntime.Core

Model restriction: This API can be used only in the stage model.

Type Description
_UIAbilityContext.default Default context of the UIAbility.

AbilityStageContext

type AbilityStageContext = _AbilityStageContext.default

Defines the context environment for the AbilityStage. It inherits from Context.

Atomic service API: This API can be used in atomic services since API version 11.

System capability: SystemCapability.Ability.AbilityRuntime.Core

Model restriction: This API can be used only in the stage model.

Type Description
_AbilityStageContext.default Default context of the AbilityStage.

ApplicationContext

type ApplicationContext = _ApplicationContext.default

Defines the application context. It inherits from Context.

Atomic service API: This API can be used in atomic services since API version 11.

System capability: SystemCapability.Ability.AbilityRuntime.Core

Model restriction: This API can be used only in the stage model.

Type Description
_ApplicationContext.default Application context.

BaseContext

type BaseContext = _BaseContext.default

Defines the parent class of all context types.

Atomic service API: This API can be used in atomic services since API version 11.

System capability: SystemCapability.Ability.AbilityRuntime.Core

Model restriction: This API can be used only in the stage model.

Type Description
_BaseContext.default Parent class of all context types.

Context

type Context = _Context.default

Defines the context base class for the stage model.

Atomic service API: This API can be used in atomic services since API version 11.

System capability: SystemCapability.Ability.AbilityRuntime.Core

Model restriction: This API can be used only in the stage model.

Type Description
_Context.default Base class of the context in the stage model.

ExtensionContext

type ExtensionContext = _ExtensionContext.default

Defines the context environment for the ExtensionAbility. It inherits from Context.

Atomic service API: This API can be used in atomic services since API version 11.

System capability: SystemCapability.Ability.AbilityRuntime.Core

Model restriction: This API can be used only in the stage model.

Type Description
_ExtensionContext.default Default context of the ExtensionAbility.

FormExtensionContext

type FormExtensionContext = _FormExtensionContext.default

Defines the context environment for the FormExtensionAbility. It inherits from ExtensionContext.

Atomic service API: This API can be used in atomic services since API version 11.

System capability: SystemCapability.Ability.AbilityRuntime.Core

Model restriction: This API can be used only in the stage model.

Type Description
_FormExtensionContext.default Default context of the FormExtensionAbility.

VpnExtensionContext11+

type VpnExtensionContext = _VpnExtensionContext.default

Defines the context environment for the VpnExtensionAbility. It inherits from Context.

System capability: SystemCapability.Ability.AbilityRuntime.Core

Model restriction: This API can be used only in the stage model.

Type Description
_VpnExtensionContext.default Default context of the VpnExtensionAbility.

EventHub

type EventHub = _EventHub.default

Defines EventHub, which is an event communication mechanism based on the publish-subscribe pattern.

Atomic service API: This API can be used in atomic services since API version 11.

System capability: SystemCapability.Ability.AbilityRuntime.Core

Model restriction: This API can be used only in the stage model.

Type Description
_EventHub.default Event communication mechanism based on the publish-subscribe pattern.

PacMap

type PacMap = _PacMap

Defines the container of basic data types.

Atomic service API: This API can be used in atomic services since API version 11.

System capability: SystemCapability.Ability.AbilityRuntime.Core

Type Description
_PacMap Container of basic data types.

AbilityResult

type AbilityResult = _AbilityResult

Defines the result code and data returned when a started ability is terminated.

Atomic service API: This API can be used in atomic services since API version 11.

System capability: SystemCapability.Ability.AbilityRuntime.Core

Model restriction: This API can be used only in the stage model.

Type Description
_AbilityResult Result code and data returned when a started ability is terminated.

AbilityStartCallback11+

type AbilityStartCallback = _AbilityStartCallback

Defines the callback invoked to return the UIExtensionAbility startup result. It is usually used as an input parameter in UIAbilityContext.startAbilityByType or UIExtensionContext.startAbilityByType.

Atomic service API: This API can be used in atomic services since API version 11.

System capability: SystemCapability.Ability.AbilityRuntime.Core

Model restriction: This API can be used only in the stage model.

Type Description
_AbilityStartCallback Callback invoked to return the UIExtensionAbility startup result.

ConnectOptions

type ConnectOptions = _ConnectOptions

Defines the connection options. It is used as an input parameter for connection to a background service, to receive the connection status with the background service.

System capability: SystemCapability.Ability.AbilityRuntime.Core

Model restriction: This API can be used only in the stage model.

Type Description
_ConnectOptions Input parameter used to receive the connection status with the background service.

UIExtensionContext10+

type UIExtensionContext = _UIExtensionContext.default

Defines the context environment for the UIExtensionAbility. It inherits from Context.

System capability: SystemCapability.Ability.AbilityRuntime.Core

Model restriction: This API can be used only in the stage model.

Type Description
_UIExtensionContext.default Default context of the UIExtensionAbility.

EmbeddableUIAbilityContext12+

type EmbeddableUIAbilityContext = _EmbeddableUIAbilityContext.default

Defines the context environment for the EmbeddableUIAbility. It inherits from Context.

Atomic service API: This API can be used in atomic services since API version 12.

System capability: SystemCapability.Ability.AbilityRuntime.Core

Model restriction: This API can be used only in the stage model.

Type Description
_EmbeddableUIAbilityContext.default Default context of the EmbeddableUIAbility.

PhotoEditorExtensionContext12+

type PhotoEditorExtensionContext = _PhotoEditorExtensionContext.default

Defines the context environment for the PhotoEditorExtensionAbility. It inherits from Context.

System capability: SystemCapability.Ability.AppExtension.PhotoEditorExtension

Model restriction: This API can be used only in the stage model.

Type Description
_PhotoEditorExtensionContext.default Default context of the PhotoEditorExtensionAbility.

UIServiceProxy14+

type UIServiceProxy = _UIServiceProxy.default

Defines the capability for data communication with the UIServiceExtensionAbility. UIServiceExtensionAbility is a special type of ExtensionAbility provided by the system and is used to provide extended capabilities related to floating windows.

Atomic service API: This API can be used in atomic services since API version 14.

System capability: SystemCapability.Ability.AbilityRuntime.Core

Model restriction: This API can be used only in the stage model.

Type Description
_UIServiceProxy.default Capability for data communication with the UIServiceExtensionAbility.

UIServiceExtensionConnectCallback14+

type UIServiceExtensionConnectCallback = _UIServiceExtensionConnectCallback.default

Defines the connection callback. It is used as an input parameter for connection to a UIServiceExtensionAbility, to provide the callback for the connection.

Atomic service API: This API can be used in atomic services since API version 14.

System capability: SystemCapability.Ability.AbilityRuntime.Core

Model restriction: This API can be used only in the stage model.

Type Description
_UIServiceExtensionConnectCallback.default Callback for connection to a UIServiceExtensionAbility.

AppServiceExtensionContext20+

type AppServiceExtensionContext = _AppServiceExtensionContext.default

Defines the context environment for the AppServiceExtensionAbility. It inherits from Context.

System capability: SystemCapability.Ability.AbilityRuntime.Core

Model restriction: This API can be used only in the stage model.

Type Description
_AppServiceExtensionContext.default Default context of the AppServiceExtensionAbility.

FormEditExtensionContext22+

type FormEditExtensionContext = _FormEditExtensionContext.default

Defines the context environment for the FormEditExtensionAbility. It inherits from UIExtensionContext.

Atomic service API: This API can be used in atomic services since API version 22.

System capability: SystemCapability.Ability.Form

Model restriction: This API can be used only in the stage model.

Type Description
_FormEditExtensionContext.default Default context of the FormEditExtensionAbility.

LiveFormExtensionContext22+

type LiveFormExtensionContext = _LiveFormExtensionContext.default

Defines the context environment for the LiveFormExtensionAbility. It inherits from ExtensionContext.

Atomic service API: This API can be used in atomic services since API version 22.

System capability: SystemCapability.Ability.Form

Model restriction: This API can be used only in the stage model.

Type Description
_LiveFormExtensionContext.default Default context of the LiveFormExtensionAbility.

Example

import { common } from '@kit.AbilityKit';

let uiAbilityContext: common.UIAbilityContext;
let abilityStageContext: common.AbilityStageContext;
let applicationContext: common.ApplicationContext;
let baseContext: common.BaseContext;
let context: common.Context;
let uiExtensionContext: common.UIExtensionContext;
let extensionContext: common.ExtensionContext;
let formExtensionContext: common.FormExtensionContext;
let vpnExtensionContext: common.VpnExtensionContext;
let eventHub: common.EventHub;
let pacMap: common.PacMap;
let abilityResult: common.AbilityResult;
let abilityStartCallback: common.AbilityStartCallback;
let connectOptions: common.ConnectOptions;
let embeddableUIAbilityContext: common.EmbeddableUIAbilityContext;
let photoEditorExtensionContext: common.PhotoEditorExtensionContext;
let uiServiceProxy : common.UIServiceProxy;
let uiServiceExtensionConnectCallback : common.UIServiceExtensionConnectCallback;
let appServiceExtensionContext : common.AppServiceExtensionContext;
let formEditExtensionContext : common.FormEditExtensionContext;
let liveFormExtensionContext : common.LiveFormExtensionContext;