• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1# Connecting to a ServiceExtensionAbility from the FA Model
2
3
4This topic describes how the three application components of the FA model connect to the ServiceExtensionAbility component of the stage model.
5
6
7## PageAbility Accessing a ServiceExtensionAbility
8
9A PageAbility accesses a ServiceExtensionAbility in the same way as it accesses a ServiceAbility.
10
11
12```ts
13import featureAbility from '@ohos.ability.featureAbility';
14
15let want = {
16    bundleName: "com.ohos.stage",
17    abilityName: "com.ohos.stage.ServiceExtensionAbility"
18};
19
20let faConnect = {
21    onConnect:function (elementName, proxy) {
22        console.info("Faconnection onConnect called.");
23    },
24    onDisconnect:function (elementName) {
25        console.info("Faconnection onDisconnect called.");
26    },
27    onFailed:function (code) {
28        console.info("Faconnection onFailed code is: " + code);
29    }
30};
31let connectionId = featureAbility.connectAbility(want, faConnect);
32```
33
34
35## ServiceAbility or DataAbility Accessing a ServiceExtensionAbility
36
37A ServiceAbility or DataAbility accesses a ServiceExtensionAbility in the same way as it accesses a ServiceAbility.
38
39
40```ts
41import particleAbility from '@ohos.ability.particleAbility';
42
43let want = {
44    bundleName: "com.ohos.stage",
45    abilityName: "com.ohos.stage.ServiceExtensionAbility"
46};
47
48let faConnect = {
49    onConnect:function (elementName, proxy) {
50        console.info("Faconnection onConnect called.");
51    },
52    onDisconnect:function (elementName) {
53        console.info("Faconnection onDisconnect called.");
54    },
55    onFailed:function (code) {
56        console.info("Faconnection onFailed code is: " + code);
57    }
58};
59let connectionId = particleAbility.connectAbility(want, faConnect);
60```
61