• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1# @ohos.app.ability.PhotoEditorExtensionAbility (Image Editing)
2The PhotoEditorExtensionAbility, which inherits from the [ExtensionAbility](js-apis-app-ability-extensionAbility.md), enables your application to provide an image editing page for applications that do not have the image editing capability. After an application uses [startAbilityByType](js-apis-inner-application-uiAbilityContext.md#uiabilitycontextstartability) 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.
3> **NOTE**
4>
5> 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.
6>
7> The APIs of this module can be used only in the stage model.
8## Modules to Import
9```ts
10import { PhotoEditorExtensionAbility } from '@kit.AbilityKit';
11```
12## Properties
13**System capability**: SystemCapability.Ability.AppExtension.PhotoEditorExtension
14|  Name|Type  |Read Only  |Optional  |Description  |
15| ------------ | ------------ | ------------ | ------------ | ------------ |
16|  context | [PhotoEditorExtensionContext](./js-apis-app-ability-photoEditorExtensionContext.md)  | No | Yes | Context. |
17
18## PhotoEditorExtensionAbility.onCreate
19onCreate(): void
20
21Called to initialize the service logic when a PhotoEditorExtensionAbility is created.
22
23**Model restriction**: This API can be used only in the stage model.
24
25**System capability**: SystemCapability.Ability.AppExtension.PhotoEditorExtension
26
27**Example**
28
29```ts
30import { PhotoEditorExtensionAbility } from '@kit.AbilityKit';
31
32const TAG: string = '[testTag] ExamplePhotoEditorAbility';
33
34export default class ExamplePhotoEditorAbility extends PhotoEditorExtensionAbility {
35  onCreate() {
36    console.info(TAG, `onCreate`);
37  }
38}
39
40```
41## PhotoEditorExtensionAbility.onStartContentEditing
42onStartContentEditing(uri: string, want: Want, session: UIExtensionContentSession): void
43
44Called when a **UIExtensionContentSession** instance is created for this PhotoEditorExtensionAbility. The instance can be used to read the original image and load a page.
45
46**Model restriction**: This API can be used only in the stage model.
47
48**System capability**: SystemCapability.Ability.AppExtension.PhotoEditorExtension
49
50**Parameters**
51| Name|  Type| Mandatory | Description |
52| ------------ | ------------ | ------------ | ------------ |
53|  uri |  string |  Yes| [URI](../apis-core-file-kit/js-apis-file-fileuri.md) of the image to edit. The format is file://\<bundleName>/\<sandboxPath>. |
54| want  | [Want](./js-apis-app-ability-want.md)  | Yes | Want information, including the ability name and bundle name. |
55|  session |  [UIExtensionContentSession](./js-apis-app-ability-uiExtensionContentSession.md) | Yes |  UI content information related to the PhotoEditorExtensionAbility.|
56
57
58**Example**
59
60```ts
61import { PhotoEditorExtensionAbility, Want, UIExtensionContentSession } from '@kit.AbilityKit';
62
63const TAG: string = '[testTag] ExamplePhotoEditorAbility';
64
65export default class ExamplePhotoEditorAbility extends PhotoEditorExtensionAbility {
66  onStartContentEditing(uri: string, want: Want, session: UIExtensionContentSession) {
67    console.info(TAG, `onStartContentEditing want: ${JSON.stringify(want)}, uri: ${uri}`);
68  }
69}
70
71```
72## PhotoEditorExtensionAbility.onForeground
73onForeground(): void
74
75Called when this PhotoEditorExtensionAbility is switched from the background to the foreground.
76
77**Model restriction**: This API can be used only in the stage model.
78
79**System capability**: SystemCapability.Ability.AbilityRuntime.AbilityCore
80
81**Example**
82
83```ts
84import { PhotoEditorExtensionAbility } from '@kit.AbilityKit';
85
86const TAG: string = '[testTag] ExamplePhotoEditorAbility';
87
88export default class ExamplePhotoEditorAbility extends PhotoEditorExtensionAbility {
89  onForeground() {
90    console.info(TAG, `onForeground`);
91  }
92}
93
94```
95## PhotoEditorExtensionAbility.onBackground
96onBackground(): void
97
98Called when this PhotoEditorExtensionAbility is switched from the foreground to the background.
99
100**Model restriction**: This API can be used only in the stage model.
101
102**System capability**: SystemCapability.Ability.AbilityRuntime.AbilityCore
103
104**Example**
105
106```ts
107import { PhotoEditorExtensionAbility } from '@kit.AbilityKit';
108
109const TAG: string = '[testTag] ExamplePhotoEditorAbility';
110
111export default class ExamplePhotoEditorAbility extends PhotoEditorExtensionAbility {
112  onBackground() {
113    console.info(TAG, `onBackground`);
114  }
115}
116
117```
118## PhotoEditorExtensionAbility.onDestroy
119onDestroy(): void | Promise\<void>
120
121Called to clear resources when this PhotoEditorExtensionAbility is destroyed.
122
123**Model restriction**: This API can be used only in the stage model.
124
125**System capability**: SystemCapability.Ability.AppExtension.PhotoEditorExtension
126
127**Return value**
128|  Type|Description  |
129| ------------ | ------------ |
130|  Promise\<void> |  Promise that returns no value.|
131
132**Example**
133
134```ts
135import { PhotoEditorExtensionAbility } from '@kit.AbilityKit';
136
137const TAG: string = '[testTag] ExamplePhotoEditorAbility';
138
139export default class ExamplePhotoEditorAbility extends PhotoEditorExtensionAbility {
140  onDestroy() {
141    console.info(TAG, `onDestroy`);
142  }
143}
144
145```
146