@@ -30,7 +30,7 @@ A Service ability is used to run tasks in the background, such as playing music
...
@@ -30,7 +30,7 @@ A Service ability is used to run tasks in the background, such as playing music
},
},
onConnect(want){
onConnect(want){
console.log('ServiceAbility OnConnect');
console.log('ServiceAbility OnConnect');
returnnull;
returnnewFirstServiceAbilityStub('test');
},
},
onDisconnect(want){
onDisconnect(want){
console.log('ServiceAbility OnDisConnect');
console.log('ServiceAbility OnDisConnect');
...
@@ -113,8 +113,6 @@ let promise = featureAbility.startAbility(
...
@@ -113,8 +113,6 @@ let promise = featureAbility.startAbility(
Once created, the Service ability keeps running in the background. The system does not stop or destroy it unless memory resources must be reclaimed.
Once created, the Service ability keeps running in the background. The system does not stop or destroy it unless memory resources must be reclaimed.
### Connecting to a Local Service Ability
### Connecting to a Local Service Ability
If you need to connect a Service ability to a Page ability or to a Service ability in another application, you must first implement the **IAbilityConnection** API for the connection. A Service ability allows other abilities to connect to it through **connectAbility()**.
If you need to connect a Service ability to a Page ability or to a Service ability in another application, you must first implement the **IAbilityConnection** API for the connection. A Service ability allows other abilities to connect to it through **connectAbility()**.
...
@@ -124,7 +122,7 @@ You can use either of the following methods to connect to a Service ability:
...
@@ -124,7 +122,7 @@ You can use either of the following methods to connect to a Service ability:
1. Using the IDL to automatically generate code
1. Using the IDL to automatically generate code
Use OpenHarmony Interface Definition Language (IDL) to automatically generate the corresponding client, server, and **IRemoteObject** code. For details, see [“Development Using TS” in OpenHarmony IDL Specifications and User Guide](https://gitee.com/openharmony/docs/blob/master/en/application-dev/IDL/idl-guidelines.md#development-using-ts).
Use OpenHarmony Interface Definition Language (IDL) to automatically generate the corresponding client, server, and **IRemoteObject** code. For details, see “Development Using TS" in [OpenHarmony IDL Specifications and User Guide](../IDL/idl-guidelines.md).
2. Writing code in the corresponding file
2. Writing code in the corresponding file
...
@@ -135,41 +133,36 @@ You can use either of the following methods to connect to a Service ability:
...
@@ -135,41 +133,36 @@ You can use either of the following methods to connect to a Service ability:
```javascript
```javascript
import prompt from '@system.prompt'
import prompt from '@system.prompt'
let mRemote;
var option = {
function onConnectCallback(element, remote){
onConnect: function onConnectCallback(element, proxy) {