js-apis-application-ability.md 17.6 KB
Newer Older
W
wusongqing 已提交
1 2
# Ability

W
wusongqing 已提交
3 4 5 6
> **NOTE**
> 
> The initial APIs of this module are supported since API version 9. 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.
W
wusongqing 已提交
7 8 9 10 11 12 13 14 15 16 17

Manages the ability lifecycle and context.

## Modules to Import

```
import Ability from '@ohos.application.Ability';
```

## Attributes

W
wusongqing 已提交
18 19
**System capability**: SystemCapability.Ability.AbilityRuntime.AbilityCore

W
wusongqing 已提交
20 21 22 23 24
| Name| Type| Readable| Writable| Description| 
| -------- | -------- | -------- | -------- | -------- |
| context | [AbilityContext](js-apis-ability-context.md) | Yes| No| Context of an ability.| 
| launchWant | [Want](js-apis-application-Want.md) | Yes| No| Parameters for starting the ability.| 
| lastRequestWant | [Want](js-apis-application-Want.md) | Yes| No| Parameters used when the ability was started last time.| 
W
wusongqing 已提交
25 26
| callee | [Callee](#callee) | Yes| No| Object that invokes the stub service.| 

W
wusongqing 已提交
27 28


W
wusongqing 已提交
29
## Ability.onCreate
W
wusongqing 已提交
30

W
wusongqing 已提交
31
onCreate(want: Want, param: AbilityConstant.LaunchParam): void;
W
wusongqing 已提交
32 33 34

Called to initialize the service logic when an ability is created.

W
wusongqing 已提交
35 36 37 38
**System capability**: SystemCapability.Ability.AbilityRuntime.AbilityCore

**Parameters**

W
wusongqing 已提交
39 40 41 42
  | Name| Type| Mandatory| Description| 
  | -------- | -------- | -------- | -------- |
  | want | [Want](js-apis-application-Want.md) | Yes| Information related to this ability, including the ability name and bundle name.| 
  | param | AbilityConstant.LaunchParam | Yes| Parameters for starting the ability, and the reason for the last abnormal exit.| 
W
wusongqing 已提交
43

W
wusongqing 已提交
44
**Example**
W
wusongqing 已提交
45
    
W
wusongqing 已提交
46
  ```js
W
wusongqing 已提交
47 48 49 50 51 52 53 54
  class myAbility extends Ability {
      onCreate(want, param) {
          console.log('onCreate, want:' + want.abilityName);
      }
  }
  ```


W
wusongqing 已提交
55
## Ability.onWindowStageCreate
W
wusongqing 已提交
56 57 58 59 60

onWindowStageCreate(windowStage: window.WindowStage): void

Called when a **WindowStage** is created for this ability.

W
wusongqing 已提交
61 62 63 64
**System capability**: SystemCapability.Ability.AbilityRuntime.AbilityCore

**Parameters**

W
wusongqing 已提交
65 66 67
  | Name| Type| Mandatory| Description| 
  | -------- | -------- | -------- | -------- |
  | windowStage | window.WindowStage | Yes| **WindowStage** information.| 
W
wusongqing 已提交
68

W
wusongqing 已提交
69
**Example**
W
wusongqing 已提交
70
    
W
wusongqing 已提交
71
  ```js
W
wusongqing 已提交
72 73 74 75 76 77 78 79
  class myAbility extends Ability {
      onWindowStageCreate(windowStage) {
          console.log('onWindowStageCreate');
      }
  }
  ```


W
wusongqing 已提交
80
## Ability.onWindowStageDestroy
W
wusongqing 已提交
81 82 83 84 85

onWindowStageDestroy(): void

Called when the **WindowStage** is destroyed for this ability.

W
wusongqing 已提交
86 87 88
**System capability**: SystemCapability.Ability.AbilityRuntime.AbilityCore

**Example**
W
wusongqing 已提交
89
    
W
wusongqing 已提交
90
  ```js
W
wusongqing 已提交
91 92 93 94 95 96 97 98
  class myAbility extends Ability {
      onWindowStageDestroy() {
          console.log('onWindowStageDestroy');
      }
  }
  ```


W
wusongqing 已提交
99
## Ability.onWindowStageRestore
W
wusongqing 已提交
100 101 102 103 104

onWindowStageRestore(windowStage: window.WindowStage): void

Called when the **WindowStage** is restored during the migration of this ability, which is a multi-instance ability.

W
wusongqing 已提交
105 106 107 108
**System capability**: SystemCapability.Ability.AbilityRuntime.AbilityCore

**Parameters**

W
wusongqing 已提交
109 110 111
  | Name| Type| Mandatory| Description| 
  | -------- | -------- | -------- | -------- |
  | windowStage | window.WindowStage | Yes| **WindowStage** information.| 
W
wusongqing 已提交
112

W
wusongqing 已提交
113
**Example**
W
wusongqing 已提交
114
    
W
wusongqing 已提交
115
  ```js
W
wusongqing 已提交
116 117 118 119 120 121 122 123
  class myAbility extends Ability {
      onWindowStageRestore(windowStage) {
          console.log('onWindowStageRestore');
      }
  }
  ```


W
wusongqing 已提交
124
## Ability.onDestroy
W
wusongqing 已提交
125 126 127 128 129

onDestroy(): void;

Called when this ability is destroyed to clear resources.

W
wusongqing 已提交
130 131 132
**System capability**: SystemCapability.Ability.AbilityRuntime.AbilityCore

**Example**
W
wusongqing 已提交
133
    
W
wusongqing 已提交
134
  ```js
W
wusongqing 已提交
135 136 137 138 139 140 141 142
  class myAbility extends Ability {
      onDestroy() {
          console.log('onDestroy');
      }
  }
  ```


W
wusongqing 已提交
143
## Ability.onForeground
W
wusongqing 已提交
144 145 146

onForeground(): void;

W
wusongqing 已提交
147
Called when this ability is switched from the background to the foreground.
W
wusongqing 已提交
148

W
wusongqing 已提交
149 150 151
**System capability**: SystemCapability.Ability.AbilityRuntime.AbilityCore

**Example**
W
wusongqing 已提交
152
    
W
wusongqing 已提交
153
  ```js
W
wusongqing 已提交
154 155 156 157 158 159 160 161
  class myAbility extends Ability {
      onForeground() {
          console.log('onForeground');
      }
  }
  ```


W
wusongqing 已提交
162
## Ability.onBackground
W
wusongqing 已提交
163 164 165

onBackground(): void;

W
wusongqing 已提交
166
Called when this ability is switched from the foreground to the background.
W
wusongqing 已提交
167

W
wusongqing 已提交
168 169 170
**System capability**: SystemCapability.Ability.AbilityRuntime.AbilityCore

**Example**
W
wusongqing 已提交
171
    
W
wusongqing 已提交
172
  ```js
W
wusongqing 已提交
173 174 175 176 177 178 179 180
  class myAbility extends Ability {
      onBackground() {
          console.log('onBackground');
      }
  }
  ```


W
wusongqing 已提交
181
## Ability.onContinue
W
wusongqing 已提交
182

W
wusongqing 已提交
183
onContinue(wantParam : {[key: string]: any}): AbilityConstant.OnContinueResult;
W
wusongqing 已提交
184 185 186

Called to save data during the ability migration preparation process.

W
wusongqing 已提交
187 188 189 190
**System capability**: SystemCapability.Ability.AbilityRuntime.AbilityCore

**Parameters**

W
wusongqing 已提交
191 192 193
  | Name| Type| Mandatory| Description| 
  | -------- | -------- | -------- | -------- |
  | wantParam | {[key: string]: any} | Yes| **want** parameter.| 
W
wusongqing 已提交
194

W
wusongqing 已提交
195 196
**Return value**

W
wusongqing 已提交
197 198 199
  | Type| Description| 
  | -------- | -------- |
  | AbilityConstant.OnContinueResult | Continuation result.| 
W
wusongqing 已提交
200

W
wusongqing 已提交
201
**Example**
W
wusongqing 已提交
202
    
W
wusongqing 已提交
203
  ```js
W
wusongqing 已提交
204
  import AbilityConstant from "@ohos.application.AbilityConstant"
W
wusongqing 已提交
205 206 207 208
  class myAbility extends Ability {
      onContinue(wantParams) {
          console.log('onContinue');
          wantParams["myData"] = "my1234567";
W
wusongqing 已提交
209
          return AbilityConstant.OnContinueResult.AGREE;
W
wusongqing 已提交
210 211 212 213 214
      }
  }
  ```


W
wusongqing 已提交
215
## Ability.onNewWant
W
wusongqing 已提交
216

W
wusongqing 已提交
217
onNewWant(want: Want, launchParams: AbilityConstant.LaunchParam): void;
W
wusongqing 已提交
218 219 220

Called when the ability startup mode is set to singleton.

W
wusongqing 已提交
221 222 223 224
**System capability**: SystemCapability.Ability.AbilityRuntime.AbilityCore

**Parameters**

W
wusongqing 已提交
225 226 227
  | Name| Type| Mandatory| Description| 
  | -------- | -------- | -------- | -------- |
  | want | [Want](js-apis-application-Want.md) | Yes| Want parameters, such as the ability name and bundle name.| 
W
wusongqing 已提交
228
  | launchParams | AbilityConstant.LaunchParam | Yes| Reason for the ability startup and the last abnormal exit.|
W
wusongqing 已提交
229

W
wusongqing 已提交
230
**Example**
W
wusongqing 已提交
231
    
W
wusongqing 已提交
232
  ```js
W
wusongqing 已提交
233
  class myAbility extends Ability {
W
wusongqing 已提交
234
      onNewWant(want, launchParams) {
W
wusongqing 已提交
235
          console.log('onNewWant, want:' + want.abilityName);
W
wusongqing 已提交
236 237 238
          if (launchParams.launchReason === AbilityConstant.LaunchReason.CONTINUATION) {
              console.log('onNewWant, launchReason is continuation');
          }
W
wusongqing 已提交
239 240 241 242 243
      }
  }
  ```


W
wusongqing 已提交
244
## Ability.onConfigurationUpdated
W
wusongqing 已提交
245 246 247 248 249

onConfigurationUpdated(config: Configuration): void;

Called when the configuration of the environment where the ability is running is updated.

W
wusongqing 已提交
250 251 252 253
**System capability**: SystemCapability.Ability.AbilityRuntime.AbilityCore

**Parameters**

W
wusongqing 已提交
254 255 256
  | Name| Type| Mandatory| Description| 
  | -------- | -------- | -------- | -------- |
  | config | [Configuration](js-apis-configuration.md) | Yes| New configuration.| 
W
wusongqing 已提交
257

W
wusongqing 已提交
258
**Example**
W
wusongqing 已提交
259
    
W
wusongqing 已提交
260
  ```js
W
wusongqing 已提交
261 262 263 264 265 266 267
  class myAbility extends Ability {
      onConfigurationUpdated(config) {
          console.log('onConfigurationUpdated, config:' + JSON.stringify(config));
      }
  }
  ```

W
wusongqing 已提交
268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293
## Ability.dump

dump(params: Array\<string>): Array\<string>;

Called when the client information is dumped.

**System capability**: SystemCapability.Ability.AbilityRuntime.AbilityCore

**Parameters**

  | Name| Type| Mandatory| Description| 
  | -------- | -------- | -------- | -------- |
  | params | Array\<string> | Yes| Parameters in the form of a command.| 

**Example**
    
  ```js
  class myAbility extends Ability {
      dump(params) {
          console.log('dump, params:' + JSON.stringify(params));
          return ["params"]
      }
  }
  ```


W
wusongqing 已提交
294 295 296 297 298 299

## Caller

Implements sending of sequenceable data to the target ability when an ability (caller) invokes the target ability (callee).


W
wusongqing 已提交
300
## Caller.call
W
wusongqing 已提交
301

W
wusongqing 已提交
302
call(method: string, data: rpc.Sequenceable): Promise&lt;void&gt;;
W
wusongqing 已提交
303 304 305

Sends sequenceable data to the target ability.

W
wusongqing 已提交
306 307 308 309
**System capability**: SystemCapability.Ability.AbilityRuntime.AbilityCore

**Parameters**

W
wusongqing 已提交
310 311 312 313
  | Name| Type| Mandatory| Description| 
  | -------- | -------- | -------- | -------- |
  | method | string | Yes| Notification message string negotiated between the two abilities. The message is used to instruct the callee to register a function to receive the sequenceable data.| 
  | data | rpc.Sequenceable | Yes| Sequenceable data. You need to customize the data.| 
W
wusongqing 已提交
314

W
wusongqing 已提交
315 316
**Return value**

W
wusongqing 已提交
317 318 319
  | Type| Description| 
  | -------- | -------- |
  | Promise&lt;void&gt; | Promise used to return a response.| 
W
wusongqing 已提交
320

W
wusongqing 已提交
321
**Example**
W
wusongqing 已提交
322
    
W
wusongqing 已提交
323
  ```js
W
wusongqing 已提交
324 325
  import Ability from '@ohos.application.Ability';
  class MyMessageAble{ // Custom sequenceable data structure
W
wusongqing 已提交
326 327 328
      name:""
      str:""
      num: 1
W
wusongqing 已提交
329 330 331 332
      constructor(name, str) {
        this.name = name;
        this.str = str;
      }
W
wusongqing 已提交
333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349
      marshalling(messageParcel) {
          messageParcel.writeInt(this.num);
          messageParcel.writeString(this.str);
          console.log('MyMessageAble marshalling num[' + this.num + '] str[' + this.str + ']');
          return true;
      }
      unmarshalling(messageParcel) {
          this.num = messageParcel.readInt();
          this.str = messageParcel.readString();
          console.log('MyMessageAble unmarshalling num[' + this.num + '] str[' + this.str + ']');
          return true;
      }
  };
  var method = 'call_Function'; // Notification message string negotiated by the two abilities
  var caller;
  export default class MainAbility extends Ability {
      onWindowStageCreate(windowStage) {
W
wusongqing 已提交
350 351
        this.context.startAbilityByCall({
            bundleName: "com.example.myservice",
W
wusongqing 已提交
352
            abilityName: "MainAbility",
W
wusongqing 已提交
353 354 355 356 357 358 359 360 361 362 363 364 365 366
            deviceId: ""
        }).then((obj) => {
            caller = obj;
            let msg = new MyMessageAble(1, "world"); // See the definition of Sequenceable.
            caller.call(method, msg)
                .then(() => {
                    console.log('Caller call() called');
                }).catch((e) => {
                console.log('Caller call() catch error ' + e);
            });
            console.log('Caller GetCaller Get ' + caller);
        }).catch((e) => {
            console.log('Caller GetCaller error ' + e);
        });
W
wusongqing 已提交
367
      }
W
wusongqing 已提交
368
      
W
wusongqing 已提交
369 370 371 372
  }
  ```


W
wusongqing 已提交
373
## Caller.callWithResult
W
wusongqing 已提交
374

W
wusongqing 已提交
375
callWithResult(method: string, data: rpc.Sequenceable): Promise&lt;rpc.MessageParcel&gt;;
W
wusongqing 已提交
376 377 378

Sends sequenceable data to the target ability and obtains the sequenceable data returned by the target ability.

W
wusongqing 已提交
379 380 381 382
**System capability**: SystemCapability.Ability.AbilityRuntime.AbilityCore

**Parameters**

W
wusongqing 已提交
383 384 385 386
  | Name| Type| Mandatory| Description| 
  | -------- | -------- | -------- | -------- |
  | method | string | Yes| Notification message string negotiated between the two abilities. The message is used to instruct the callee to register a function to receive the sequenceable data.| 
  | data | rpc.Sequenceable | Yes| Sequenceable data. You need to customize the data.| 
W
wusongqing 已提交
387

W
wusongqing 已提交
388 389
**Return value**

W
wusongqing 已提交
390 391 392
  | Type| Description| 
  | -------- | -------- |
  | Promise&lt;rpc.MessageParcel&gt; | Promise used to return the sequenceable data from the target ability.| 
W
wusongqing 已提交
393

W
wusongqing 已提交
394
**Example**
W
wusongqing 已提交
395
    
W
wusongqing 已提交
396
  ```js
W
wusongqing 已提交
397 398
  import Ability from '@ohos.application.Ability';
  class MyMessageAble{
W
wusongqing 已提交
399 400 401
      name:""
      str:""
      num: 1
W
wusongqing 已提交
402 403 404 405
      constructor(name, str) {
        this.name = name;
        this.str = str;
      }
W
wusongqing 已提交
406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421
      marshalling(messageParcel) {
          messageParcel.writeInt(this.num);
          messageParcel.writeString(this.str);
          console.log('MyMessageAble marshalling num[' + this.num + '] str[' + this.str + ']');
          return true;
      }
      unmarshalling(messageParcel) {
          this.num = messageParcel.readInt();
          this.str = messageParcel.readString();
          console.log('MyMessageAble unmarshalling num[' + this.num + '] str[' + this.str + ']');
          return true;
      }
  };
  var method = 'call_Function';
  var caller;
  export default class MainAbility extends Ability {
W
wusongqing 已提交
422 423 424
      onWindowStageCreate(windowStage) {
        this.context.startAbilityByCall({
            bundleName: "com.example.myservice",
W
wusongqing 已提交
425
            abilityName: "MainAbility",
W
wusongqing 已提交
426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441
            deviceId: ""
        }).then((obj) => {
            caller = obj;
            let msg = new MyMessageAble(1, "world");
            caller.callWithResult(method, msg)
                .then((data) => {
                    console.log('Caller callWithResult() called');
                    let retmsg = new MyMessageAble(0, "");
                    data.readSequenceable(retmsg);
                }).catch((e) => {
                console.log('Caller callWithResult() catch error ' + e);
            });
            console.log('Caller GetCaller Get ' + caller);
        }).catch((e) => {
            console.log('Caller GetCaller error ' + e);
        });
W
wusongqing 已提交
442 443 444 445 446
      }
  }
  ```


W
wusongqing 已提交
447
## Caller.release
W
wusongqing 已提交
448 449 450 451 452

release(): void;

Releases the caller interface of the target ability.

W
wusongqing 已提交
453 454 455
**System capability**: SystemCapability.Ability.AbilityRuntime.AbilityCore

**Example**
W
wusongqing 已提交
456
    
W
wusongqing 已提交
457
  ```js
W
wusongqing 已提交
458 459 460 461
  import Ability from '@ohos.application.Ability';
  var caller;
  export default class MainAbility extends Ability {
      onWindowStageCreate(windowStage) {
W
wusongqing 已提交
462 463
        this.context.startAbilityByCall({
            bundleName: "com.example.myservice",
W
wusongqing 已提交
464
            abilityName: "MainAbility",
W
wusongqing 已提交
465 466 467 468 469 470 471 472 473 474 475 476
            deviceId: ""
        }).then((obj) => {
            caller = obj;
            try {
                caller.release();
            } catch (e) {
                console.log('Caller Release error ' + e);
            }
            console.log('Caller GetCaller Get ' + caller);
        }).catch((e) => {
            console.log('Caller GetCaller error ' + e);
        });
W
wusongqing 已提交
477 478 479 480 481
      }
  }
  ```


W
wusongqing 已提交
482
## Caller.onRelease
W
wusongqing 已提交
483

W
wusongqing 已提交
484
onRelease(callback: OnReleaseCallBack): void;
W
wusongqing 已提交
485

W
wusongqing 已提交
486
Registers a callback that is invoked when the stub on the target ability is disconnected.
W
wusongqing 已提交
487

W
wusongqing 已提交
488 489 490 491
**System capability**: SystemCapability.Ability.AbilityRuntime.AbilityCore

**Parameters**

W
wusongqing 已提交
492 493 494
  | Name| Type| Mandatory| Description| 
  | -------- | -------- | -------- | -------- |
  | callback | OnReleaseCallBack | Yes| Callback used for the **onRelease** API.| 
W
wusongqing 已提交
495

W
wusongqing 已提交
496
**Example**
W
wusongqing 已提交
497
    
W
wusongqing 已提交
498
  ```js
W
wusongqing 已提交
499 500 501 502
  import Ability from '@ohos.application.Ability';
  var caller;
  export default class MainAbility extends Ability {
      onWindowStageCreate(windowStage) {
W
wusongqing 已提交
503 504
        this.context.startAbilityByCall({
            bundleName: "com.example.myservice",
W
wusongqing 已提交
505
            abilityName: "MainAbility",
W
wusongqing 已提交
506 507 508 509 510 511 512 513 514 515 516 517 518 519
            deviceId: ""
        }).then((obj) => {
            caller = obj;
            try {
                caller.onRelease((str) => {
                    console.log(' Caller OnRelease CallBack is called ' + str);
                });
            } catch (e) {
                console.log('Caller Release error ' + e);
            }
            console.log('Caller GetCaller Get ' + caller);
        }).catch((e) => {
            console.log('Caller GetCaller error ' + e);
        });
W
wusongqing 已提交
520 521 522 523 524 525 526
      }
  }
  ```


## Callee

W
wusongqing 已提交
527
Implements callbacks for caller notification registration and deregistration.
W
wusongqing 已提交
528 529


W
wusongqing 已提交
530
## Callee.on
W
wusongqing 已提交
531

W
wusongqing 已提交
532
on(method: string, callback: CaleeCallBack): void;
W
wusongqing 已提交
533 534 535

Registers a caller notification callback, which is invoked when the target ability registers a function.

W
wusongqing 已提交
536 537 538 539
**System capability**: SystemCapability.Ability.AbilityRuntime.AbilityCore

**Parameters**

W
wusongqing 已提交
540 541 542 543
  | Name| Type| Mandatory| Description| 
  | -------- | -------- | -------- | -------- |
  | method | string | Yes| Notification message string negotiated between the two abilities.| 
  | callback | CaleeCallBack | Yes| JS notification synchronization callback of the **rpc.MessageParcel** type. The callback must return at least one empty **rpc.Sequenceable** object. Otherwise, the function execution fails.| 
W
wusongqing 已提交
544

W
wusongqing 已提交
545
**Example**
W
wusongqing 已提交
546
    
W
wusongqing 已提交
547
  ```js
W
wusongqing 已提交
548 549
  import Ability from '@ohos.application.Ability';
  class MyMessageAble{
W
wusongqing 已提交
550 551 552
      name:""
      str:""
      num: 1
W
wusongqing 已提交
553 554 555 556
      constructor(name, str) {
        this.name = name;
        this.str = str;
      }
W
wusongqing 已提交
557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585
      marshalling(messageParcel) {
          messageParcel.writeInt(this.num);
          messageParcel.writeString(this.str);
          console.log('MyMessageAble marshalling num[' + this.num + '] str[' + this.str + ']');
          return true;
      }
      unmarshalling(messageParcel) {
          this.num = messageParcel.readInt();
          this.str = messageParcel.readString();
          console.log('MyMessageAble unmarshalling num[' + this.num + '] str[' + this.str + ']');
          return true;
      }
  };
  var method = 'call_Function';
  function funcCallBack(pdata) {
      console.log('Callee funcCallBack is called ' + pdata);
      let msg = new MyMessageAble(0, "");
      pdata.readSequenceable(msg);
      return new MyMessageAble(10, "Callee test");
  }
  export default class MainAbility extends Ability {
      onCreate(want, launchParam) {
          console.log('Callee onCreate is called');
          this.callee.on(method, funcCallBack);
      }
  }
  ```


W
wusongqing 已提交
586
## Callee.off
W
wusongqing 已提交
587 588 589

off(method: string): void;

W
wusongqing 已提交
590
Deregisters a caller notification callback, which is invoked when the target ability registers a function.
W
wusongqing 已提交
591

W
wusongqing 已提交
592 593 594 595
**System capability**: SystemCapability.Ability.AbilityRuntime.AbilityCore

**Parameters**

W
wusongqing 已提交
596 597 598
  | Name| Type| Mandatory| Description| 
  | -------- | -------- | -------- | -------- |
  | method | string | Yes| Registered notification message string.| 
W
wusongqing 已提交
599

W
wusongqing 已提交
600
**Example**
W
wusongqing 已提交
601
    
W
wusongqing 已提交
602
  ```js
W
wusongqing 已提交
603 604 605 606 607 608 609 610 611
  import Ability from '@ohos.application.Ability';
  var method = 'call_Function';
  export default class MainAbility extends Ability {
      onCreate(want, launchParam) {
          console.log('Callee onCreate is called');
          this.callee.off(method);
      }
  }
  ```
W
wusongqing 已提交
612 613 614 615 616

## OnReleaseCallBack

(msg: string): void;

W
wusongqing 已提交
617 618
**System capability**: SystemCapability.Ability.AbilityRuntime.AbilityCore

W
wusongqing 已提交
619 620 621
| Name| Type| Readable| Writable| Description| 
| -------- | -------- | -------- | -------- | -------- |
| (msg: string) | function | Yes| No| Prototype of the listener function interface registered by the caller.| 
W
wusongqing 已提交
622 623 624 625 626 627
 

 ## CaleeCallBack

(indata: rpc.MessageParcel): rpc.Sequenceable;

W
wusongqing 已提交
628 629
**System capability**: SystemCapability.Ability.AbilityRuntime.AbilityCore

W
wusongqing 已提交
630 631 632
| Name| Type| Readable| Writable| Description| 
| -------- | -------- | -------- | -------- | -------- |
| (indata: rpc.MessageParcel) | rpc.Sequenceable | Yes| No| Prototype of the message listener function interface registered by the callee.|