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