diff --git a/zh-cn/application-dev/reference/apis/js-apis-Context.md b/zh-cn/application-dev/reference/apis/js-apis-Context.md index b311ada819abc5e589723353b7c28ab7f023d188..f952f242e1da5b04fa7a6a99d5839b8cfb31f2d3 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-Context.md +++ b/zh-cn/application-dev/reference/apis/js-apis-Context.md @@ -63,7 +63,7 @@ getOrCreateLocalDir(): Promise\ ```js import featureAbility from '@ohos.ability.featureAbility' var context = featureAbility.getContext(); -context.getOrCreateLocalDir().then((void) => { +context.getOrCreateLocalDir().then(() => { console.info("==========================>getOrCreateLocalDirCallback=======================>"); }); ``` @@ -91,9 +91,9 @@ verifyPermission(permission: string, options: PermissionOptions, callback: Async import featureAbility from '@ohos.ability.featureAbility' import bundle from '@ohos.bundle' var context = featureAbility.getContext(); -var datainfo = await bundle.getBundleInfo('com.context.test',1); -context.verifyPermission("com.example.permission",datainfo.uid) - +bundle.getBundleInfo('com.context.test', 1, (datainfo) =>{ + context.verifyPermission("com.example.permission", datainfo.uid); +}); ``` @@ -146,7 +146,7 @@ verifyPermission(permission: string, options?: PermissionOptions): Promise\ { +context.getOrCreateLocalDir('com.context.permission',Permission).then(() => { console.info("==========================>verifyPermissionCallback=======================>"); }); ``` @@ -223,7 +223,7 @@ getApplicationInfo(): Promise\ ```js import featureAbility from '@ohos.ability.featureAbility' var context = featureAbility.getContext(); -context.getApplicationInfo().then((void) => { +context.getApplicationInfo().then(() => { console.info("==========================>getApplicationInfoCallback=======================>"); }); ``` @@ -269,7 +269,7 @@ getBundleName(): Promise\ ```js import featureAbility from '@ohos.ability.featureAbility' var context = featureAbility.getContext(); -context.getBundleName().then((void) => { +context.getBundleName().then(() => { console.info("==========================>getBundleNameCallback=======================>"); }); ``` @@ -315,7 +315,7 @@ getProcessInfo(): Promise\ ```js import featureAbility from '@ohos.ability.featureAbility' var context = featureAbility.getContext(); -context.getProcessInfo().then((void) => { +context.getProcessInfo().then(() => { console.info("==========================>getProcessInfoCallback=======================>"); }); ``` @@ -365,7 +365,7 @@ getElementName(): Promise\ ```js import featureAbility from '@ohos.ability.featureAbility' var context = featureAbility.getContext(); -context.getElementName().then((void) => { +context.getElementName().then(() => { console.info("==========================>getElementNameCallback=======================>"); }); ``` @@ -407,7 +407,7 @@ getProcessName(): Promise\ ```js import featureAbility from '@ohos.ability.featureAbility' var context = featureAbility.getContext(); -context.getProcessName().then((void) => { +context.getProcessName().then(() => { console.info("==========================>getProcessNameCallback=======================>"); }); ``` @@ -453,7 +453,7 @@ getCallingBundle(): Promise\ ```js import featureAbility from '@ohos.ability.featureAbility' var context = featureAbility.getContext(); -context.getCallingBundle().then((void) => { +context.getCallingBundle().then(() => { console.info("==========================>getCallingBundleCallback=======================>"); }); ``` diff --git a/zh-cn/application-dev/reference/apis/js-apis-DataUriUtils.md b/zh-cn/application-dev/reference/apis/js-apis-DataUriUtils.md index b58eef3c1d324d4c09d4e109c8b7587f5aa50a44..232d333a0af21162ab508eed5c637d829bbc1aa1 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-DataUriUtils.md +++ b/zh-cn/application-dev/reference/apis/js-apis-DataUriUtils.md @@ -27,7 +27,6 @@ getId(uri: string): number **示例:** ```js -import dataUriUtils from '@ohos.ability.datauriutils' dataUriUtils.getIdSync("com.example.dataUriUtils/1221") ``` @@ -55,10 +54,9 @@ attachId(uri: string, id: number): string **示例:** ```js -import dataUriUtils from '@ohos.ability.datauriutils' var idint = 1122; dataUriUtils.attachId( - "com.example.dataUriUtils" + "com.example.dataUriUtils", idint, ) ``` @@ -85,7 +83,6 @@ deleteId(uri: string): string **示例:** ```js -import dataUriUtils from '@ohos.ability.datauriutils' dataUriUtils.deleteId("com.example.dataUriUtils/1221") ``` @@ -112,11 +109,10 @@ updateId(uri: string, id: number): string **示例:** ```js -import dataUriUtils from '@ohos.ability.datauriutils' var idint = 1122; dataUriUtils.updateId( - "com.example.dataUriUtils" - idint, + "com.example.dataUriUtils", + idint ) ``` diff --git a/zh-cn/application-dev/reference/apis/js-apis-ability-context.md b/zh-cn/application-dev/reference/apis/js-apis-ability-context.md index 01212e408ae64aaff2a039770d006e7e4b1188a9..020beeb11908edf8cb8f32d6671add43815ba698 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-ability-context.md +++ b/zh-cn/application-dev/reference/apis/js-apis-ability-context.md @@ -137,8 +137,8 @@ terminateSelf(callback: AsyncCallback<void>): void; - 示例: ``` this.context.terminateSelf((err) => { - console.log('terminateSelf result:' + JSON.stringfy(err); - } + console.log('terminateSelf result:' + JSON.stringfy(err)); + }); ``` @@ -157,7 +157,7 @@ terminateSelf(): Promise<void>; ``` this.context.terminateSelf(want).then((data) => { console.log('success:' + JSON.stringfy(data)); - )).catch((error) => { + }).catch((error) => { console.log('failed:' + JSON.stringfy(error)); }); ``` diff --git a/zh-cn/application-dev/reference/apis/js-apis-dataAbilityHelper.md b/zh-cn/application-dev/reference/apis/js-apis-dataAbilityHelper.md index faacbf73949124197205b3cf50bf22e81e840dca..3c0e4627e4c8d0a1fabf9498df7eee99ebb4355e 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-dataAbilityHelper.md +++ b/zh-cn/application-dev/reference/apis/js-apis-dataAbilityHelper.md @@ -65,8 +65,8 @@ var DAHelper = featureAbility.acquireDataAbilityHelper( ); var mode = "rwt"; DAHelper.openFile( - "dataability:///com.example.DataAbility", - mode).then((void) => { + "dataability:///com.example.DataAbility", + mode).then((data) => { console.info("==========================>openFileCallback=======================>"); }); ``` @@ -338,7 +338,7 @@ var DAHelper = featureAbility.acquireDataAbilityHelper( "dataability:///com.example.DataAbility" ); DAHelper.denormalizeUri( - "dataability:///com.example.DataAbility",, + "dataability:///com.example.DataAbility", (err, data) => { console.info("==========================>Called=======================>"); }); @@ -398,7 +398,7 @@ var helper = featureAbility.acquireDataAbilityHelper( "dataability:///com.example.DataAbility" ); helper.notifyChange( - "dataability:///com.example.DataAbility",, + "dataability:///com.example.DataAbility", (err) => { console.info("==========================>Called=======================>"); }); @@ -430,7 +430,7 @@ var DAHelper = featureAbility.acquireDataAbilityHelper( ); DAHelper.notifyChange( "dataability:///com.example.DataAbility", - ).then((void) => { + ).then(() => { console.info("==========================>notifyChangeCallback=======================>"); }); ``` @@ -747,7 +747,7 @@ import ohos_data_ability from '@ohos.data.dataability' var DAHelper = featureAbility.acquireDataAbilityHelper( "dataability:///com.example.DataAbility" ); -var cars=new Array({"value1"}, {"value2"}, {"value3"}, {"value4"}); +var cars=new Array("value1", "value2", "value3", "value4"); let da = new ohos_data_ability.DataAbilityPredicates() DAHelper.query( "dataability:///com.example.DataAbility", @@ -787,7 +787,7 @@ import ohos_data_ability from '@ohos.data.dataability' var DAHelper = featureAbility.acquireDataAbilityHelper( "dataability:///com.example.DataAbility" ); -var cars=new Array({"value1"}, {"value2"}, {"value3"}, {"value4"}); +var cars=new Array("value1", "value2", "value3", "value4"); let da = new ohos_data_ability.DataAbilityPredicates() DAHelper.query( "dataability:///com.example.DataAbility", diff --git a/zh-cn/application-dev/reference/apis/js-apis-particleAbility.md b/zh-cn/application-dev/reference/apis/js-apis-particleAbility.md index 99b740b29f4ff715181bb2806d6ccf97cc17cc5c..5b4745b916a1e4db6792c21266911459aca974bf 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-particleAbility.md +++ b/zh-cn/application-dev/reference/apis/js-apis-particleAbility.md @@ -28,6 +28,7 @@ startAbility(parameter: StartAbilityParameter, callback: AsyncCallback\: v ```js import particleAbility from '@ohos.ability.particleAbility' +import wantConstant from "@ohos.ability.wantConstant" particleAbility.startAbility( { want: @@ -35,7 +36,7 @@ particleAbility.startAbility( action: "action.system.home", entities: ["entity.system.home"], type: "MIMETYPE", - flags: FLAG_AUTH_READ_URI_PERMISSION; + flags: wantConstant.Flags.FLAG_AUTH_READ_URI_PERMISSION, deviceId: "", bundleName: "com.example.Data", abilityName: "com.example.Data.MainAbility", @@ -70,6 +71,7 @@ startAbility(parameter: StartAbilityParameter): Promise\ ```js import particleAbility from '@ohos.ability.particleAbility' +import wantConstant from "@ohos.ability.wantConstant" particleAbility.startAbility( { want: @@ -77,14 +79,14 @@ particleAbility.startAbility( action: "action.system.home", entities: ["entity.system.home"], type: "MIMETYPE", - flags: FLAG_AUTH_READ_URI_PERMISSION; + flags: wantConstant.Flags.FLAG_AUTH_READ_URI_PERMISSION, deviceId: "", bundleName: "com.example.Data", - abilityName: "com.example.Data.MainAbility", + abilityName: "com.example. Data.MainAbility", uri:"" }, }, -).then((void) => { +).then(() => { console.info("particleAbility startAbility"); }); ``` @@ -131,7 +133,7 @@ terminateSelf(): Promise\ ```js import particleAbility from '@ohos.ability.particleAbility' -particleAbility.terminateSelf().then((void) => { +particleAbility.terminateSelf().then(() => { console.info("particleAbility terminateSelf"); }); ``` @@ -195,7 +197,7 @@ connectAbility(request: Want, options:ConnectOptions): number ```javascript import particleAbility from '@ohos.ability.particleAbility' function onConnectCallback(element, remote){ - console.log('ConnectAbility onConnect remote is proxy:' + (remote instanceof rpc.RemoteProxy)); + console.log('ConnectAbility onConnectCallback'); } function onDisconnectCallback(element){ console.log('ConnectAbility onDisconnect element.deviceId : ' + element.deviceId) @@ -234,7 +236,7 @@ disconnectAbility(connection: number, callback:AsyncCallback\): void ```javascript import particleAbility from '@ohos.ability.particleAbility' function onConnectCallback(element, remote){ - console.log('ConnectAbility onConnect remote is proxy:' + (remote instanceof rpc.RemoteProxy)); + console.log('ConnectAbility onConnectCallback'); } function onDisconnectCallback(element){ console.log('ConnectAbility onDisconnect element.deviceId : ' + element.deviceId) @@ -255,8 +257,8 @@ var connId = particleAbility.connectAbility( ); var result = particleAbility.disconnectAbility(connId, (error,data) => { - console.log('particleAbilityTest DisConnectAbility result errCode : ' + error.code + " data: " + data) - }, + console.log('particleAbilityTest DisConnectAbility result errCode : ' + error.code + " data: " + data); + } ); ``` @@ -282,7 +284,7 @@ disconnectAbility(connection: number): Promise\ ```javascript import particleAbility from '@ohos.ability.particleAbility' function onConnectCallback(element, remote){ - console.log('ConnectAbility onConnect remote is proxy:' + (remote instanceof rpc.RemoteProxy)); + console.log('ConnectAbility onConnect onConnectCallback'); } function onDisconnectCallback(element){ console.log('ConnectAbility onDisconnect element.deviceId : ' + element.deviceId) @@ -301,7 +303,7 @@ var connId = particleAbility.connectAbility( onFailed: onFailedCallback, }, ); -var result = particleAbility.disconnectAbility(connId).then((void) => { +var result = particleAbility.disconnectAbility(connId).then(() => { console.info("particleAbilityTest disconnectAbility"); }); ``` diff --git a/zh-cn/application-dev/reference/apis/js-apis-service-extension-context.md b/zh-cn/application-dev/reference/apis/js-apis-service-extension-context.md index 7d1f53d40fb9beed30fe9db79df511d3393e8c93..9df9866c2cd51d00b76c2bd3b72809a483629bbb 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-service-extension-context.md +++ b/zh-cn/application-dev/reference/apis/js-apis-service-extension-context.md @@ -29,8 +29,8 @@ startAbility(want: Want, callback: AsyncCallback<void>): void; "abilityName": "com.example.myapp.MyAbility" }; this.context.startAbility(want, (err) => { - console.log('startAbility result:' + JSON.stringfy(err); - } + console.log('startAbility result:' + JSON.stringfy(err)); + }); ``` @@ -58,7 +58,7 @@ startAbility(want: Want): Promise<void>; }; this.context.startAbility(want).then((data) => { console.log('success:' + JSON.stringfy(data)); - )).catch((error) => { + }).catch((error) => { console.log('failed:' + JSON.stringfy(error)); }); ``` @@ -78,8 +78,8 @@ terminateSelf(callback: AsyncCallback<void>): void; - 示例: ``` this.context.terminateSelf((err) => { - console.log('terminateSelf result:' + JSON.stringfy(err); - } + console.log('terminateSelf result:' + JSON.stringfy(err)); + }); ``` @@ -98,7 +98,7 @@ terminateSelf(): Promise<void>; ``` this.context.terminateSelf(want).then((data) => { console.log('success:' + JSON.stringfy(data)); - )).catch((error) => { + }).catch((error) => { console.log('failed:' + JSON.stringfy(error)); }); ``` @@ -128,8 +128,8 @@ connectAbility(want: Want, options: ConnectOptions): number; "abilityName": "com.example.myapp.MyAbility" }; let options = { - onConnect: function(elementName, proxy) {} - onDisConnect: function(elementName) {} + onConnect: function(elementName, proxy) {}, + onDisConnect: function(elementName) {}, onFailed: function(code) {} } let connection = this.context.connectAbility(want,options); @@ -151,8 +151,8 @@ disconnectAbility(connection: number, callback:AsyncCallback<void>): void; - 示例: ``` this.context.disconnectAbility(connection, (err) => { // connection为connectAbility中的返回值 - console.log('terminateSelf result:' + JSON.stringfy(err); - } + console.log('terminateSelf result:' + JSON.stringfy(err)); + }); ``` @@ -176,7 +176,7 @@ disconnectAbility(connection: number): Promise<void>; ``` this.context.disconnectAbility(connection).then((data) => { // connection为connectAbility中的返回值 console.log('success:' + JSON.stringfy(data)); - )).catch((error) => { + }).catch((error) => { console.log('failed:' + JSON.stringfy(error)); }); ``` diff --git a/zh-cn/application-dev/reference/apis/js-apis-service-extension.md b/zh-cn/application-dev/reference/apis/js-apis-service-extension.md index d01d181e57131249f3917f50c7e285aeb076951e..4084b560e9ebed38d7be22ebf75285723e1a80da 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-service-extension.md +++ b/zh-cn/application-dev/reference/apis/js-apis-service-extension.md @@ -39,8 +39,10 @@ Extension生命周期回调,在创建时回调,执行初始化业务逻辑 - 示例: ``` - onCreate(want) { + class ServiceExt extends ServiceExtension { + onCreate(want) { console.log('onCreate, want:' + want.abilityName); + } } ``` @@ -53,9 +55,10 @@ Extension生命周期回调,在销毁时回调,执行资源清理等操作 - 示例: ``` - onDestroy() { + class ServiceExt extends ServiceExtension { + onDestroy() { console.log('onDestroy'); - destory(); + } } ``` @@ -74,8 +77,10 @@ Extension生命周期回调,如果是startAbility拉起的服务,会在onCre - 示例: ``` - onRequest(want: Want, startId: number) { + class ServiceExt extends ServiceExtension { + onRequest(want, startId) { console.log('onRequest, want:' + want.abilityName); + } } ``` @@ -106,10 +111,11 @@ Extension生命周期回调,如果是connectAbility拉起的服务,会在onC onRemoteRequest(code, data, reply, option) { } } - ... - onConnect(want) { + class ServiceExt extends ServiceExtension { + onConnect(want) { console.log('onConnect , want:' + want.abilityName); return new StubTest("test"); + } } ``` @@ -127,7 +133,9 @@ Extension的生命周期,断开服务连接时回调。 - 示例: ``` - onDisconnect(want) { + class ServiceExt extends ServiceExtension { + onDisconnect(want) { console.log('onDisconnect, want:' + want.abilityName); + } } ```