openharmony 鸿蒙 js-apis-app-ability-photoEditorExtensionAbility

2025-06-12 浏览 (1)

@ohos.app.ability.PhotoEditorExtensionAbility (Image Editing)

The PhotoEditorExtensionAbility, which inherits from the ExtensionAbility, enables your application to provide an image editing page for applications that do not have the image editing capability. After an application uses startAbilityByType to start a vertical domain panel with available image editing applications that have implemented the PhotoEditorExtensionAbility, the user can select one of the applications on the panel to display an image editing page.

NOTE

The initial APIs of this module are supported since API version 12. 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 { PhotoEditorExtensionAbility } from '@kit.AbilityKit';

Properties

System capability: SystemCapability.Ability.AppExtension.PhotoEditorExtension

NameTypeRead OnlyOptionalDescription
contextPhotoEditorExtensionContextNoYesContext.

PhotoEditorExtensionAbility.onCreate

onCreate(): void

Called to initialize the service logic when a PhotoEditorExtensionAbility is created.

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

System capability: SystemCapability.Ability.AppExtension.PhotoEditorExtension

Example

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

const TAG: string = '[testTag] ExamplePhotoEditorAbility';

export default class ExamplePhotoEditorAbility extends PhotoEditorExtensionAbility {
  onCreate() {
    console.info(TAG, `onCreate`);
  }
}

PhotoEditorExtensionAbility.onStartContentEditing

onStartContentEditing(uri: string, want: Want, session: UIExtensionContentSession): void

Called when a UIExtensionContentSession instance is created for this PhotoEditorExtensionAbility. The instance can be used to read the original image and load a page.

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

System capability: SystemCapability.Ability.AppExtension.PhotoEditorExtension

Parameters

NameTypeMandatoryDescription
uristringYesURI of the image to edit. The format is file://<bundleName>/<sandboxPath>.
wantWantYesWant information, including the ability name and bundle name.
sessionUIExtensionContentSessionYesUI content information related to the PhotoEditorExtensionAbility.

Example

import { PhotoEditorExtensionAbility, Want, UIExtensionContentSession } from '@kit.AbilityKit';

const TAG: string = '[testTag] ExamplePhotoEditorAbility';

export default class ExamplePhotoEditorAbility extends PhotoEditorExtensionAbility {
  onStartContentEditing(uri: string, want: Want, session: UIExtensionContentSession) {
    console.info(TAG, `onStartContentEditing want: ${JSON.stringify(want)}, uri: ${uri}`);
  }
}

PhotoEditorExtensionAbility.onForeground

onForeground(): void

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

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

System capability: SystemCapability.Ability.AbilityRuntime.AbilityCore

Example

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

const TAG: string = '[testTag] ExamplePhotoEditorAbility';

export default class ExamplePhotoEditorAbility extends PhotoEditorExtensionAbility {
  onForeground() {
    console.info(TAG, `onForeground`);
  }
}

PhotoEditorExtensionAbility.onBackground

onBackground(): void

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

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

System capability: SystemCapability.Ability.AbilityRuntime.AbilityCore

Example

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

const TAG: string = '[testTag] ExamplePhotoEditorAbility';

export default class ExamplePhotoEditorAbility extends PhotoEditorExtensionAbility {
  onBackground() {
    console.info(TAG, `onBackground`);
  }
}

PhotoEditorExtensionAbility.onDestroy

onDestroy(): void|Promise<void>

Called to clear resources when this PhotoEditorExtensionAbility is destroyed.

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

System capability: SystemCapability.Ability.AppExtension.PhotoEditorExtension

Return value

TypeDescription
Promise<void>Promise that returns no value.

Example

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

const TAG: string = '[testTag] ExamplePhotoEditorAbility';

export default class ExamplePhotoEditorAbility extends PhotoEditorExtensionAbility {
  onDestroy() {
    console.info(TAG, `onDestroy`);
  }
}

你可能感兴趣的鸿蒙文章

harmony 鸿蒙Ability Kit

harmony 鸿蒙AbilityAccessControl

harmony 鸿蒙AbilityBase

harmony 鸿蒙AbilityBase_Element

harmony 鸿蒙AbilityRuntime

harmony 鸿蒙bundle

harmony 鸿蒙OH_NativeBundle_ApplicationInfo

harmony 鸿蒙OH_NativeBundle_ElementName

harmony 鸿蒙ability_access_control.h

harmony 鸿蒙ability_base_common.h

  • 所属分类: 后端技术
  • 本文标签: 软件 鸿蒙
  • 版权声明: 本文链接 https://seaxiang.com/blog/T0GmnR