harmony 鸿蒙@ohos.app.ability.UIExtensionAbility (Base Class for ExtensionAbilities with UI)

  • 2023-10-30
  • 浏览 (556)

@ohos.app.ability.UIExtensionAbility (Base Class for ExtensionAbilities with UI)

UIExtensionAbility, inherited from ExtensionAbility, is a base class for ExtensionAbilities with UI in specific scenarios. It provides attributes and APIs related to ExtensionAbilities with UI. You cannot inherit from this base class.

NOTE

The initial APIs of this module are supported since API version 10. Newly added APIs will be marked with a superscript to indicate their earliest API version. The APIs of this module can be used only in the stage model.

Modules to Import

import UIExtensionAbility from '@ohos.app.ability.UIExtensionAbility';

Attributes

System capability: SystemCapability.Ability.AbilityRuntime.AbilityCore

Name Type Readable Writable Description
context UIExtensionContext Yes No Context.

UIExtensionAbility.onCreate

onCreate(): void

Called to initialize the service logic when a UIExtensionAbility is being created.

System capability: SystemCapability.Ability.AbilityRuntime.Core

UIExtensionAbility.onSessionCreate

onSessionCreate(want: Want, session: UIExtensionContentSession): void

Called when a UIExtensionContentSession instance is created for this UIExtensionAbility.

System capability: SystemCapability.Ability.AbilityRuntime.Core

Parameters

Name Type Mandatory Description
want Want Yes Want information related to this UIExtensionAbility, including the ability name and bundle name.
session UIExtensionContentSession Yes UI content information related to this UIExtensionAbility.

UIExtensionAbility.onSessionDestroy

onSessionDestroy(session: UIExtensionContentSession): void

Called when a UIExtensionContentSession instance is destroyed for this UIExtensionAbility.

System capability: SystemCapability.Ability.AbilityRuntime.Core

Parameters

Name Type Mandatory Description
session UIExtensionContentSession Yes UI content information related to this UIExtensionAbility.

UIExtensionAbility.onForeground

onForeground(): void;

Called when this UIExtensionAbility is switched from the background to the foreground.

System capability: SystemCapability.Ability.AbilityRuntime.AbilityCore

UIExtensionAbility.onBackground

onBackground(): void;

Called when this UIExtensionAbility is switched from the foreground to the background.

System capability: SystemCapability.Ability.AbilityRuntime.AbilityCore

UIExtensionAbility.onDestroy

onDestroy(): void|Promise<void>;

Called to clear resources when this UIExtensionAbility is destroyed.

After the onDestroy() lifecycle callback is executed, the application may exit. Consequently, the asynchronous function (for example, asynchronously writing data to the database) in onDestroy() may fail to be executed. You can use the asynchronous lifecycle to ensure that the subsequent lifecycle continues only after the asynchronous function in onDestroy() finishes the execution.

System capability: SystemCapability.Ability.AbilityRuntime.Core

你可能感兴趣的鸿蒙文章

harmony 鸿蒙APIs

harmony 鸿蒙System Common Events (To Be Deprecated Soon)

harmony 鸿蒙System Common Events

harmony 鸿蒙API Reference Document Description

harmony 鸿蒙Enterprise Device Management Overview (for System Applications Only)

harmony 鸿蒙BundleStatusCallback

harmony 鸿蒙@ohos.bundle.innerBundleManager (innerBundleManager)

harmony 鸿蒙@ohos.distributedBundle (Distributed Bundle Management)

harmony 鸿蒙@ohos.bundle (Bundle)

harmony 鸿蒙@ohos.enterprise.EnterpriseAdminExtensionAbility (EnterpriseAdminExtensionAbility)

0  赞