• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1# AbilityStartCallback
2
3The **AbilityStartCallback** module defines the callback to be invoked when the UIExtensionAbility fails to start.
4
5> **NOTE**
6>
7> The initial APIs of this module are supported since API version 11. 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 common from '@ohos.app.ability.common';
15```
16
17## Attributes
18
19**System capability**: SystemCapability.Ability.AbilityRuntime.Core
20
21| Name       |  Type                | Mandatory| Description                                                        |
22| ----------- | -------------------- | ---- | ------------------------------------------------------------ |
23| onError<sup>11+</sup>  | function               | Yes  | Callback invoked when the UIExtensionAbility fails to start.                               |
24
25**Example**
26
27  ```ts
28  import common from '@ohos.app.ability.common';
29  import { BusinessError } from '@ohos.base';
30  let context = getContext(this) as common.UIAbilityContext;
31  let wantParam: Record<string, Object> = {
32    'time':'2023-10-23 20:45',
33  };
34  let abilityStartCallback: common.AbilityStartCallback = {
35    onError: (code: number, name: string, message: string) => {
36      console.log(`code:` + code + `name:` + name + `message:` + message);
37    }
38  }
39  context.startAbilityByType("photoEditor", wantParam, abilityStartCallback, (err: BusinessError) => {
40    if (err) {
41      console.error(`startAbilityByType fail, err: ${JSON.stringify(err)}`);
42    } else {
43      console.log(`success`);
44    }
45  });
46  ```
47