提交 4b9d28cf 编写于 作者: W wusongqing

updated docs

Signed-off-by: Nwusongqing <wusongqing@huawei.com>
上级 984c3afb
...@@ -24,16 +24,16 @@ A Service ability is used to run tasks in the background, such as playing music ...@@ -24,16 +24,16 @@ A Service ability is used to run tasks in the background, such as playing music
```javascript ```javascript
export default { export default {
onStart(want) { onStart() {
console.log('ServiceAbility onStart'); console.log('ServiceAbility onStart');
}, },
onCommand(want, restart, startId) { onCommand(want, startId) {
console.log('ServiceAbility onCommand'); console.log('ServiceAbility onCommand');
}, },
onConnect(want) { onConnect(want) {
console.log('ServiceAbility OnConnect'); console.log('ServiceAbility OnConnect');
}, },
onDisconnect() { onDisconnect(want) {
console.log('ServiceAbility OnDisConnect'); console.log('ServiceAbility OnDisConnect');
}, },
onStop() { onStop() {
...@@ -174,7 +174,7 @@ import rpc from "@ohos.rpc"; ...@@ -174,7 +174,7 @@ import rpc from "@ohos.rpc";
let mMyStub; let mMyStub;
export default { export default {
onStart(want) { onStart() {
class MyStub extends rpc.RemoteObject{ class MyStub extends rpc.RemoteObject{
constructor(des) { constructor(des) {
if (typeof des === 'string') { if (typeof des === 'string') {
...@@ -182,7 +182,7 @@ export default { ...@@ -182,7 +182,7 @@ export default {
} }
return null; return null;
} }
onRemoteRequest(code, message, reply, option) { onRemoteRequest(code, data, reply, option) {
console.log("ServiceAbility onRemoteRequest called"); console.log("ServiceAbility onRemoteRequest called");
if (code === 1) { if (code === 1) {
let op1 = data.readInt(); let op1 = data.readInt();
...@@ -197,14 +197,14 @@ export default { ...@@ -197,14 +197,14 @@ export default {
} }
mMyStub = new MyStub("ServiceAbility-test"); mMyStub = new MyStub("ServiceAbility-test");
}, },
onCommand(want, restart, startId) { onCommand(want, startId) {
console.log('ServiceAbility onCommand'); console.log('ServiceAbility onCommand');
}, },
onConnect(want) { onConnect(want) {
console.log('ServiceAbility OnConnect'); console.log('ServiceAbility OnConnect');
return mMyStub; return mMyStub;
}, },
onDisconnect() { onDisconnect(want) {
console.log('ServiceAbility OnDisConnect'); console.log('ServiceAbility OnDisConnect');
}, },
onStop() { onStop() {
...@@ -225,12 +225,12 @@ The following code snippet shows how to implement the callbacks: ...@@ -225,12 +225,12 @@ The following code snippet shows how to implement the callbacks:
```ts ```ts
let mRemote; let mRemote;
function onConnectCallback(element, remote){ function onConnectCallback(element, remote){
console.log('onConnectLocalService onConnectDone element: ' + element); console.log('onConnectRemoteService onConnectDone element: ' + element);
console.log('onConnectLocalService onConnectDone remote: ' + remote); console.log('onConnectRemotelService onConnectDone remote: ' + remote);
mRemote = remote; mRemote = remote;
if (mRemote == null) { if (mRemote == null) {
prompt.showToast({ prompt.showToast({
message: "onConnectLocalService not connected yet" message: "onConnectRemoteService not connected yet"
}); });
return; return;
} }
...@@ -243,7 +243,7 @@ function onConnectCallback(element, remote){ ...@@ -243,7 +243,7 @@ function onConnectCallback(element, remote){
console.log('sendRequest success'); console.log('sendRequest success');
let msg = reply.readInt(); let msg = reply.readInt();
prompt.showToast({ prompt.showToast({
message: "onConnectLocalService connect result: " + msg, message: "onConnectRemoteService connect result: " + msg,
duration: 3000 duration: 3000
}); });
}).catch((e) => { }).catch((e) => {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册