diff --git a/zh-cn/application-dev/reference/apis/js-apis-ability-ability.md b/zh-cn/application-dev/reference/apis/js-apis-ability-ability.md index 88c738004e9b4be3bf877c8e4f0c41c4e7e81247..2ec899589fce0fd7deb34e659ed1261c23bd6a6c 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-ability-ability.md +++ b/zh-cn/application-dev/reference/apis/js-apis-ability-ability.md @@ -10,7 +10,7 @@ Ability模块将二级模块API组织在一起方便开发者进行导出。 ## 导入模块 ```ts -import ability from '@ohos.ability.ability' +import ability from '@ohos.ability.ability'; ``` **系统能力**:以下各项对应的系统能力均为SystemCapability.Ability.AbilityBase 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 68913e83d94e67ca66b91b7f1546f83fa822e09e..1879a7eaa8aa05b3c2100d26b9cafb48350f19f3 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 @@ -65,8 +65,8 @@ startAbility(want: Want, callback: AsyncCallback<void>): void; ```ts let want = { - bundleName: "com.example.myapp", - abilityName: "MyAbility" + bundleName: 'com.example.myapp', + abilityName: 'MyAbility' }; try { @@ -120,9 +120,9 @@ startAbility(want: Want, options: StartOptions, callback: AsyncCallback<void& ```ts let want = { - deviceId: "", - bundleName: "com.extreme.test", - abilityName: "MainAbility" + deviceId: '', + bundleName: 'com.extreme.test', + abilityName: 'MainAbility' }; let options = { windowMode: 0 @@ -183,8 +183,8 @@ startAbility(want: Want, options?: StartOptions): Promise<void>; ```ts let want = { - bundleName: "com.example.myapp", - abilityName: "MyAbility" + bundleName: 'com.example.myapp', + abilityName: 'MyAbility' }; let options = { windowMode: 0, @@ -243,9 +243,9 @@ startAbilityForResult(want: Want, callback: AsyncCallback<AbilityResult>): ```ts let want = { - deviceId: "", - bundleName: "com.extreme.test", - abilityName: "MainAbility" + deviceId: '', + bundleName: 'com.extreme.test', + abilityName: 'MainAbility' }; try { @@ -257,8 +257,8 @@ startAbilityForResult(want: Want, callback: AsyncCallback<AbilityResult>): return; } // 执行正常业务 - console.log("startAbilityForResult succeed, result.resultCode = " + - result.resultCode) + console.log('startAbilityForResult succeed, result.resultCode = ' + + result.resultCode); }); } catch (paramError) { // 处理入参错误异常 @@ -302,9 +302,9 @@ startAbilityForResult(want: Want, options: StartOptions, callback: AsyncCallback ```ts let want = { - deviceId: "", - bundleName: "com.extreme.test", - abilityName: "MainAbility" + deviceId: '', + bundleName: 'com.extreme.test', + abilityName: 'MainAbility' }; let options = { windowMode: 0, @@ -319,8 +319,8 @@ startAbilityForResult(want: Want, options: StartOptions, callback: AsyncCallback return; } // 执行正常业务 - console.log("startAbilityForResult succeed, result.resultCode = " + - result.resultCode) + console.log('startAbilityForResult succeed, result.resultCode = ' + + result.resultCode); }); } catch (paramError) { // 处理入参错误异常 @@ -371,8 +371,8 @@ startAbilityForResult(want: Want, options?: StartOptions): Promise<AbilityRes ```ts let want = { - bundleName: "com.example.myapp", - abilityName: "MyAbility" + bundleName: 'com.example.myapp', + abilityName: 'MyAbility' }; let options = { windowMode: 0, @@ -382,7 +382,7 @@ startAbilityForResult(want: Want, options?: StartOptions): Promise<AbilityRes this.context.startAbilityForResult(want, options) .then((result) => { // 执行正常业务 - console.log("startAbilityForResult succeed, result.resultCode = " + result.resultCode); + console.log('startAbilityForResult succeed, result.resultCode = ' + result.resultCode); }) .catch((error) => { // 处理业务逻辑错误 @@ -432,9 +432,9 @@ startAbilityForResultWithAccount(want: Want, accountId: number, callback: AsyncC ```ts let want = { - deviceId: "", - bundleName: "com.extreme.test", - abilityName: "MainAbility" + deviceId: '', + bundleName: 'com.extreme.test', + abilityName: 'MainAbility' }; let accountId = 100; @@ -447,8 +447,8 @@ startAbilityForResultWithAccount(want: Want, accountId: number, callback: AsyncC return; } // 执行正常业务 - console.log("startAbilityForResultWithAccount succeed, result.resultCode = " + - result.resultCode) + console.log('startAbilityForResultWithAccount succeed, result.resultCode = ' + + result.resultCode); }); } catch (paramError) { // 处理入参错误异常 @@ -495,9 +495,9 @@ startAbilityForResultWithAccount(want: Want, accountId: number, options: StartOp ```ts let want = { - deviceId: "", - bundleName: "com.extreme.test", - abilityName: "MainAbility" + deviceId: '', + bundleName: 'com.extreme.test', + abilityName: 'MainAbility' }; let accountId = 100; let options = { @@ -513,8 +513,8 @@ startAbilityForResultWithAccount(want: Want, accountId: number, options: StartOp return; } // 执行正常业务 - console.log("startAbilityForResultWithAccount succeed, result.resultCode = " + - result.resultCode) + console.log('startAbilityForResultWithAccount succeed, result.resultCode = ' + + result.resultCode); }); } catch (paramError) { // 处理入参错误异常 @@ -566,9 +566,9 @@ startAbilityForResultWithAccount(want: Want, accountId: number, options?: StartO ```ts let want = { - deviceId: "", - bundleName: "com.extreme.test", - abilityName: "MainAbility" + deviceId: '', + bundleName: 'com.extreme.test', + abilityName: 'MainAbility' }; let accountId = 100; let options = { @@ -579,8 +579,8 @@ startAbilityForResultWithAccount(want: Want, accountId: number, options?: StartO this.context.startAbilityForResultWithAccount(want, accountId, options) .then((result) => { // 执行正常业务 - console.log("startAbilityForResultWithAccount succeed, result.resultCode = " + - result.resultCode) + console.log('startAbilityForResultWithAccount succeed, result.resultCode = ' + + result.resultCode); }) .catch((error) => { // 处理业务逻辑错误 @@ -621,9 +621,9 @@ startServiceExtensionAbility(want: Want, callback: AsyncCallback\): void; ```ts let want = { - deviceId: "", - bundleName: "com.extreme.test", - abilityName: "MainAbility" + deviceId: '', + bundleName: 'com.extreme.test', + abilityName: 'MainAbility' }; try { @@ -671,9 +671,9 @@ startServiceExtensionAbility(want: Want): Promise\; ```ts let want = { - deviceId: "", - bundleName: "com.extreme.test", - abilityName: "MainAbility" + deviceId: '', + bundleName: 'com.extreme.test', + abilityName: 'MainAbility' }; try { @@ -725,9 +725,9 @@ startServiceExtensionAbilityWithAccount(want: Want, accountId: number, callback: ```ts let want = { - deviceId: "", - bundleName: "com.extreme.test", - abilityName: "MainAbility" + deviceId: '', + bundleName: 'com.extreme.test', + abilityName: 'MainAbility' }; let accountId = 100; @@ -779,9 +779,9 @@ startServiceExtensionAbilityWithAccount(want: Want, accountId: number): Promise\ ```ts let want = { - deviceId: "", - bundleName: "com.extreme.test", - abilityName: "MainAbility" + deviceId: '', + bundleName: 'com.extreme.test', + abilityName: 'MainAbility' }; let accountId = 100; @@ -830,9 +830,9 @@ stopServiceExtensionAbility(want: Want, callback: AsyncCallback\): void; ```ts let want = { - deviceId: "", - bundleName: "com.extreme.test", - abilityName: "MainAbility" + deviceId: '', + bundleName: 'com.extreme.test', + abilityName: 'MainAbility' }; try { @@ -880,9 +880,9 @@ stopServiceExtensionAbility(want: Want): Promise\; ```ts let want = { - deviceId: "", - bundleName: "com.extreme.test", - abilityName: "MainAbility" + deviceId: '', + bundleName: 'com.extreme.test', + abilityName: 'MainAbility' }; try { @@ -934,9 +934,9 @@ stopServiceExtensionAbilityWithAccount(want: Want, accountId: number, callback: ```ts let want = { - deviceId: "", - bundleName: "com.extreme.test", - abilityName: "MainAbility" + deviceId: '', + bundleName: 'com.extreme.test', + abilityName: 'MainAbility' }; let accountId = 100; @@ -988,9 +988,9 @@ stopServiceExtensionAbilityWithAccount(want: Want, accountId: number): Promise\< ```ts let want = { - deviceId: "", - bundleName: "com.extreme.test", - abilityName: "MainAbility" + deviceId: '', + bundleName: 'com.extreme.test', + abilityName: 'MainAbility' }; let accountId = 100; @@ -1110,15 +1110,15 @@ terminateSelfWithResult(parameter: AbilityResult, callback: AsyncCallback<voi ```ts let want = { - bundleName: "com.extreme.myapplication", - abilityName: "SecondAbility" - } + bundleName: 'com.extreme.myapplication', + abilityName: 'SecondAbility' + }; let resultCode = 100; // 返回给接口调用方AbilityResult信息 let abilityResult = { want, resultCode - } + }; try { this.context.terminateSelfWithResult(abilityResult, (error) => { @@ -1172,15 +1172,15 @@ terminateSelfWithResult(parameter: AbilityResult): Promise<void>; ```ts let want = { - bundleName: "com.extreme.myapplication", - abilityName: "SecondAbility" - } + bundleName: 'com.extreme.myapplication', + abilityName: 'SecondAbility' + }; let resultCode = 100; // 返回给接口调用方AbilityResult信息 let abilityResult = { want, resultCode - } + }; try { this.context.terminateSelfWithResult(abilityResult) @@ -1234,9 +1234,9 @@ connectServiceExtensionAbility(want: Want, options: ConnectOptions): number; ```ts let want = { - deviceId: "", - bundleName: "com.extreme.test", - abilityName: "MainAbility" + deviceId: '', + bundleName: 'com.extreme.test', + abilityName: 'MainAbility' }; let options = { onConnect(elementName, remote) { console.log('----------- onConnect -----------') }, @@ -1292,9 +1292,9 @@ connectServiceExtensionAbilityWithAccount(want: Want, accountId: number, options ```ts let want = { - deviceId: "", - bundleName: "com.extreme.test", - abilityName: "MainAbility" + deviceId: '', + bundleName: 'com.extreme.test', + abilityName: 'MainAbility' }; let accountId = 100; let options = { @@ -1446,10 +1446,10 @@ startAbilityByCall(want: Want): Promise<Caller>; // 后台启动Ability,不配置parameters let wantBackground = { - bundleName: "com.example.myservice", - moduleName: "entry", - abilityName: "MainAbility", - deviceId: "" + bundleName: 'com.example.myservice', + moduleName: 'entry', + abilityName: 'MainAbility', + deviceId: '' }; try { @@ -1475,14 +1475,14 @@ startAbilityByCall(want: Want): Promise<Caller>; ```ts let caller = undefined; - // 前台启动Ability,将parameters中的"ohos.aafwk.param.callAbilityToForeground"配置为true + // 前台启动Ability,将parameters中的'ohos.aafwk.param.callAbilityToForeground'配置为true let wantForeground = { - bundleName: "com.example.myservice", - moduleName: "entry", - abilityName: "MainAbility", - deviceId: "", + bundleName: 'com.example.myservice', + moduleName: 'entry', + abilityName: 'MainAbility', + deviceId: '', parameters: { - "ohos.aafwk.param.callAbilityToForeground": true + 'ohos.aafwk.param.callAbilityToForeground': true } }; @@ -1540,9 +1540,9 @@ startAbilityWithAccount(want: Want, accountId: number, callback: AsyncCallback\< ```ts let want = { - deviceId: "", - bundleName: "com.extreme.test", - abilityName: "MainAbility" + deviceId: '', + bundleName: 'com.extreme.test', + abilityName: 'MainAbility' }; let accountId = 100; @@ -1602,9 +1602,9 @@ startAbilityWithAccount(want: Want, accountId: number, options: StartOptions, ca ```ts let want = { - deviceId: "", - bundleName: "com.extreme.test", - abilityName: "MainAbility" + deviceId: '', + bundleName: 'com.extreme.test', + abilityName: 'MainAbility' }; let accountId = 100; let options = { @@ -1666,9 +1666,9 @@ startAbilityWithAccount(want: Want, accountId: number, options?: StartOptions): ```ts let want = { - deviceId: "", - bundleName: "com.extreme.test", - abilityName: "MainAbility" + deviceId: '', + bundleName: 'com.extreme.test', + abilityName: 'MainAbility' }; let accountId = 100; let options = { @@ -1711,7 +1711,7 @@ setMissionLabel(label: string, callback:AsyncCallback<void>): void; **示例:** ```ts - this.context.setMissionLabel("test",(result) => { + this.context.setMissionLabel('test',(result) => { console.log('setMissionLabel result:' + JSON.stringify(result)); }); ``` @@ -1740,7 +1740,7 @@ setMissionLabel(label: string): Promise<void>; **示例:** ```ts - this.context.setMissionLabel("test").then(() => { + this.context.setMissionLabel('test').then(() => { console.log('success'); }).catch((error) => { console.log('failed:' + JSON.stringify(error)); @@ -1780,7 +1780,7 @@ setMissionIcon(icon: image.PixelMap, callback:AsyncCallback\): void; imagePixelMap = data; }) .catch((err) => { - console.log('--------- createPixelMap fail, err: ---------', err) + console.log('--------- createPixelMap fail, err: ---------', err); }); this.context.setMissionIcon(imagePixelMap, (err) => { console.log('---------- setMissionIcon fail, err: -----------', err); @@ -1827,7 +1827,7 @@ setMissionIcon(icon: image.PixelMap): Promise\; imagePixelMap = data; }) .catch((err) => { - console.log('--------- createPixelMap fail, err: ---------', err) + console.log('--------- createPixelMap fail, err: ---------', err); }); this.context.setMissionIcon(imagePixelMap) .then(() => { diff --git a/zh-cn/application-dev/reference/apis/js-apis-ability-dataUriUtils.md b/zh-cn/application-dev/reference/apis/js-apis-ability-dataUriUtils.md index 0d5aaf26a22bdc5cd384f4412131cbbd1e2dec6b..8b12e20e1b7dd9c859d70bcd4f17581c8d2fdeec 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-ability-dataUriUtils.md +++ b/zh-cn/application-dev/reference/apis/js-apis-ability-dataUriUtils.md @@ -35,7 +35,7 @@ getId(uri: string): number **示例:** ```ts -let id = dataUriUtils.getId("com.example.dataUriUtils/1221"); +let id = dataUriUtils.getId('com.example.dataUriUtils/1221'); ``` @@ -66,9 +66,9 @@ attachId(uri: string, id: number): string ```ts let id = 1122; let uri = dataUriUtils.attachId( - "com.example.dataUriUtils", + 'com.example.dataUriUtils', id, -) +); ``` @@ -96,7 +96,7 @@ deleteId(uri: string): string **示例:** ```ts -let uri = dataUriUtils.deleteId("com.example.dataUriUtils/1221") +let uri = dataUriUtils.deleteId('com.example.dataUriUtils/1221'); ``` @@ -127,8 +127,8 @@ updateId(uri: string, id: number): string ```ts let id = 1122; let uri = dataUriUtils.updateId( - "com.example.dataUriUtils/1221", + 'com.example.dataUriUtils/1221', id -) +); ``` diff --git a/zh-cn/application-dev/reference/apis/js-apis-ability-errorCode.md b/zh-cn/application-dev/reference/apis/js-apis-ability-errorCode.md index b66275351ef87e69938efc7cbc1a743efe44b7b2..8b6f2227c3165c6f946095c03e77ed049500c240 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-ability-errorCode.md +++ b/zh-cn/application-dev/reference/apis/js-apis-ability-errorCode.md @@ -9,7 +9,7 @@ ErrorCode定义启动Ability时返回的错误码,包括无效的参数、权 ## 导入模块 ```ts -import errorCode from '@ohos.ability.errorCode' +import errorCode from '@ohos.ability.errorCode'; ``` ## ErrorCode diff --git a/zh-cn/application-dev/reference/apis/js-apis-ability-featureAbility.md b/zh-cn/application-dev/reference/apis/js-apis-ability-featureAbility.md index 888f7536074351fc4314d25d7f6ee7c6b4462be7..8d12235a119f975a73fa23905411bfd115bee8fb 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-ability-featureAbility.md +++ b/zh-cn/application-dev/reference/apis/js-apis-ability-featureAbility.md @@ -46,19 +46,19 @@ featureAbility.startAbility( { want: { - action: "", - entities: [""], - type: "", + action: '', + entities: [''], + type: '', flags: wantConstant.Flags.FLAG_AUTH_READ_URI_PERMISSION, - deviceId: "", - bundleName: "com.example.myapplication", + deviceId: '', + bundleName: 'com.example.myapplication', /* FA模型中abilityName由package + Ability name组成 */ - abilityName: "com.example.myapplication.secondAbility", - uri: "" + abilityName: 'com.example.myapplication.secondAbility', + uri: '' }, }, (err, data) => { - console.info("startAbility err: " + JSON.stringify(err) + "data: " + JSON.stringify(data)); + console.info('startAbility err: ' + JSON.stringify(err) + 'data: ' + JSON.stringify(data)); } ); ``` @@ -99,19 +99,19 @@ featureAbility.startAbility( { want: { - action: "action.system.home", - entities: ["entity.system.home"], - type: "MIMETYPE", + action: 'action.system.home', + entities: ['entity.system.home'], + type: 'MIMETYPE', flags: wantConstant.Flags.FLAG_AUTH_READ_URI_PERMISSION, - deviceId: "", - bundleName: "com.example.myapplication", + deviceId: '', + bundleName: 'com.example.myapplication', /* FA模型中abilityName由package + Ability name组成 */ - abilityName: "com.example.myapplication.secondAbility", - uri: "" + abilityName: 'com.example.myapplication.secondAbility', + uri: '' }, } ).then((data) => { - console.info("startAbility data: " + JSON.stringify(data)); + console.info('startAbility data: ' + JSON.stringify(data)); }); ``` @@ -140,7 +140,7 @@ acquireDataAbilityHelper(uri: string): DataAbilityHelper ```ts import featureAbility from '@ohos.ability.featureAbility'; let dataAbilityHelper = featureAbility.acquireDataAbilityHelper( - "dataability:///com.example.DataAbility" + 'dataability:///com.example.DataAbility' ); ``` @@ -176,19 +176,19 @@ featureAbility.startAbilityForResult( { want: { - action: "action.system.home", - entities: ["entity.system.home"], - type: "MIMETYPE", + action: 'action.system.home', + entities: ['entity.system.home'], + type: 'MIMETYPE', flags: wantConstant.Flags.FLAG_AUTH_READ_URI_PERMISSION, - deviceId: "", - bundleName: "com.example.myapplication", + deviceId: '', + bundleName: 'com.example.myapplication', /* FA模型中abilityName由package + Ability name组成 */ - abilityName: "com.example.myapplication.secondAbility", - uri:"" + abilityName: 'com.example.myapplication.secondAbility', + uri:'' }, }, (err, data) => { - console.info("startAbilityForResult err: " + JSON.stringify(err) + "data: " + JSON.stringify(data)); + console.info('startAbilityForResult err: ' + JSON.stringify(err) + 'data: ' + JSON.stringify(data)); } ); ``` @@ -230,30 +230,30 @@ featureAbility.startAbilityForResult( { want: { - action: "action.system.home", - entities: ["entity.system.home"], - type: "MIMETYPE", + action: 'action.system.home', + entities: ['entity.system.home'], + type: 'MIMETYPE', flags: wantConstant.Flags.FLAG_AUTH_READ_URI_PERMISSION, - deviceId: "", - bundleName: "com.example.myapplication", + deviceId: '', + bundleName: 'com.example.myapplication', /* FA模型中abilityName由package + Ability name组成 */ - abilityName: "com.example.myapplication.secondAbility", - uri:"", + abilityName: 'com.example.myapplication.secondAbility', + uri:'', parameters: { mykey0: 1111, mykey1: [1, 2, 3], - mykey2: "[1, 2, 3]", - mykey3: "xxxxxxxxxxxxxxxxxxxxxx", + mykey2: '[1, 2, 3]', + mykey3: 'xxxxxxxxxxxxxxxxxxxxxx', mykey4: [1, 15], mykey5: [false, true, false], - mykey6: ["aaaaaa", "bbbbb", "ccccccccccc"], + mykey6: ['aaaaaa', 'bbbbb', 'ccccccccccc'], mykey7: true, }, }, }, ).then((data) => { - console.info("startAbilityForResult data: " + JSON.stringify(data)); + console.info('startAbilityForResult data: ' + JSON.stringify(data)); }); ``` @@ -282,29 +282,29 @@ featureAbility.terminateSelfWithResult( resultCode: 1, want: { - action: "action.system.home", - entities: ["entity.system.home"], - type: "MIMETYPE", + action: 'action.system.home', + entities: ['entity.system.home'], + type: 'MIMETYPE', flags: wantConstant.Flags.FLAG_AUTH_READ_URI_PERMISSION, - deviceId: "", - bundleName: "com.example.myapplication", + deviceId: '', + bundleName: 'com.example.myapplication', /* FA模型中abilityName由package + Ability name组成 */ - abilityName: "com.example.myapplication.secondAbility", - uri:"", + abilityName: 'com.example.myapplication.secondAbility', + uri:'', parameters: { mykey0: 2222, mykey1: [1, 2, 3], - mykey2: "[1, 2, 3]", - mykey3: "ssssssssssssssssssssssssss", + mykey2: '[1, 2, 3]', + mykey3: 'ssssssssssssssssssssssssss', mykey4: [1, 15], mykey5: [false, true, false], - mykey6: ["qqqqq", "wwwwww", "aaaaaaaaaaaaaaaaa"], + mykey6: ['qqqqq', 'wwwwww', 'aaaaaaaaaaaaaaaaa'], mykey7: true, } }, }, (err) => { - console.info("err: " + JSON.stringify(err)) + console.error('err: ' + JSON.stringify(err)); } ); ``` @@ -339,29 +339,29 @@ featureAbility.terminateSelfWithResult( resultCode: 1, want: { - action: "action.system.home", - entities: ["entity.system.home"], - type: "MIMETYPE", + action: 'action.system.home', + entities: ['entity.system.home'], + type: 'MIMETYPE', flags: wantConstant.Flags.FLAG_AUTH_READ_URI_PERMISSION, - deviceId: "", - bundleName: "com.example.myapplication", + deviceId: '', + bundleName: 'com.example.myapplication', /* FA模型中abilityName由package + Ability name组成 */ - abilityName: "com.example.myapplication.secondAbility", - uri:"", + abilityName: 'com.example.myapplication.secondAbility', + uri:'', parameters: { mykey0: 2222, mykey1: [1, 2, 3], - mykey2: "[1, 2, 3]", - mykey3: "ssssssssssssssssssssssssss", + mykey2: '[1, 2, 3]', + mykey3: 'ssssssssssssssssssssssssss', mykey4: [1, 15], mykey5: [false, true, false], - mykey6: ["qqqqq", "wwwwww", "aaaaaaaaaaaaaaaaa"], + mykey6: ['qqqqq', 'wwwwww', 'aaaaaaaaaaaaaaaaa'], mykey7: true, } }, } ).then((data) => { - console.info("==========================>terminateSelfWithResult=======================>"); + console.info('==========================>terminateSelfWithResult=======================>'); }); ``` @@ -384,7 +384,7 @@ hasWindowFocus(callback: AsyncCallback\): void ```ts import featureAbility from '@ohos.ability.featureAbility'; featureAbility.hasWindowFocus((err, data) => { - console.info("hasWindowFocus err: " + JSON.stringify(err) + "data: " + JSON.stringify(data)); + console.info('hasWindowFocus err: ' + JSON.stringify(err) + 'data: ' + JSON.stringify(data)); }); ``` @@ -407,7 +407,7 @@ hasWindowFocus(): Promise\ ```ts import featureAbility from '@ohos.ability.featureAbility'; featureAbility.hasWindowFocus().then((data) => { - console.info("hasWindowFocus data: " + JSON.stringify(data)); + console.info('hasWindowFocus data: ' + JSON.stringify(data)); }); ``` @@ -430,7 +430,7 @@ getWant(callback: AsyncCallback\): void ```ts import featureAbility from '@ohos.ability.featureAbility'; featureAbility.getWant((err, data) => { - console.info("getWant err: " + JSON.stringify(err) + "data: " + JSON.stringify(data)); + console.info('getWant err: ' + JSON.stringify(err) + 'data: ' + JSON.stringify(data)); }); ``` @@ -453,7 +453,7 @@ getWant(): Promise\ ```ts import featureAbility from '@ohos.ability.featureAbility'; featureAbility.getWant().then((data) => { - console.info("getWant data: " + JSON.stringify(data)); + console.info('getWant data: ' + JSON.stringify(data)); }); ``` @@ -475,9 +475,9 @@ getContext(): Context ```ts import featureAbility from '@ohos.ability.featureAbility'; -let context = featureAbility.getContext() +let context = featureAbility.getContext(); context.getBundleName((err, data) => { - console.info("getBundleName err: " + JSON.stringify(err) + "data: " + JSON.stringify(data)); + console.info('getBundleName err: ' + JSON.stringify(err) + 'data: ' + JSON.stringify(data)); }); ``` @@ -501,7 +501,7 @@ terminateSelf(callback: AsyncCallback\): void import featureAbility from '@ohos.ability.featureAbility'; featureAbility.terminateSelf( (err) => { - console.info("err: " + JSON.stringify(err)) + console.error('err: ' + JSON.stringify(err)); } ) ``` @@ -525,7 +525,7 @@ terminateSelf(): Promise\ ```ts import featureAbility from '@ohos.ability.featureAbility'; featureAbility.terminateSelf().then((data) => { - console.info("==========================>terminateSelf=======================>"); + console.info('==========================>terminateSelf=======================>'); }); ``` @@ -566,9 +566,9 @@ function onFailedCallback(code){ } let connectId = featureAbility.connectAbility( { - deviceId: "", - bundleName: "com.ix.ServiceAbility", - abilityName: "com.ix.ServiceAbility.ServiceAbilityA", + deviceId: '', + bundleName: 'com.ix.ServiceAbility', + abilityName: 'com.ix.ServiceAbility.ServiceAbilityA', }, { onConnect: onConnectCallback, @@ -602,15 +602,15 @@ function onConnectCallback(element, remote){ console.log('ConnectAbility onConnect remote is proxy:' + (remote instanceof rpc.RemoteProxy)); } function onDisconnectCallback(element){ - console.log('ConnectAbility onDisconnect element.deviceId : ' + element.deviceId) + console.log('ConnectAbility onDisconnect element.deviceId : ' + element.deviceId); } function onFailedCallback(code){ - console.log('featureAbilityTest ConnectAbility onFailed errCode : ' + code) + console.log('featureAbilityTest ConnectAbility onFailed errCode : ' + code); } let connectId = featureAbility.connectAbility( { - bundleName: "com.ix.ServiceAbility", - abilityName: "com.ix.ServiceAbility.ServiceAbilityA", + bundleName: 'com.ix.ServiceAbility', + abilityName: 'com.ix.ServiceAbility.ServiceAbilityA', }, { onConnect: onConnectCallback, @@ -620,8 +620,8 @@ let connectId = featureAbility.connectAbility( ); featureAbility.disconnectAbility(connectId, (err) => { - console.log("featureAbilityTest disconnectAbility err====>" - + ("json err=") + JSON.stringify(err)); + console.error('featureAbilityTest disconnectAbility err====>' + + ('json err=') + JSON.stringify(err)); }); ``` @@ -654,15 +654,15 @@ function onConnectCallback(element, remote){ console.log('ConnectAbility onConnect remote is proxy:' + (remote instanceof rpc.RemoteProxy)); } function onDisconnectCallback(element){ - console.log('ConnectAbility onDisconnect element.deviceId : ' + element.deviceId) + console.log('ConnectAbility onDisconnect element.deviceId : ' + element.deviceId); } function onFailedCallback(code){ - console.log('featureAbilityTest ConnectAbility onFailed errCode : ' + code) + console.log('featureAbilityTest ConnectAbility onFailed errCode : ' + code); } let connectId = featureAbility.connectAbility( { - bundleName: "com.ix.ServiceAbility", - abilityName: "com.ix.ServiceAbility.ServiceAbilityA", + bundleName: 'com.ix.ServiceAbility', + abilityName: 'com.ix.ServiceAbility.ServiceAbilityA', }, { onConnect: onConnectCallback, @@ -674,7 +674,7 @@ let connectId = featureAbility.connectAbility( featureAbility.disconnectAbility(connectId).then((data) => { console.log('data : ' + data); }).catch((error)=>{ - console.log('featureAbilityTest result errCode : ' + error.code); + console.error('featureAbilityTest result errCode : ' + error.code); }); ``` @@ -697,7 +697,7 @@ getWindow(callback: AsyncCallback\): void ```ts featureAbility.getWindow((err, data) => { - console.info("getWindow err: " + JSON.stringify(err) + "data: " + typeof(data)); + console.info('getWindow err: ' + JSON.stringify(err) + 'data: ' + typeof(data)); }); ``` @@ -719,7 +719,7 @@ getWindow(): Promise\; ```ts featureAbility.getWindow().then((data) => { - console.info("getWindow data: " + typeof(data)); + console.info('getWindow data: ' + typeof(data)); }); ``` @@ -760,9 +760,9 @@ featureAbility.AbilityStartSetting.BOUNDS_KEY | 名称 | 值 | 说明 | | ---------------------------- | --------------- | ---------------------------------------- | -| BOUNDS_KEY7+ | "abilityBounds" | 窗口显示大小属性的参数名。 | -| WINDOW_MODE_KEY7+ | "windowMode" | 窗口显示模式属性的参数名。| -| DISPLAY_ID_KEY7+ | "displayId" | 窗口显示设备ID属性的参数名。 | +| BOUNDS_KEY7+ | 'abilityBounds' | 窗口显示大小属性的参数名。 | +| WINDOW_MODE_KEY7+ | 'windowMode' | 窗口显示模式属性的参数名。| +| DISPLAY_ID_KEY7+ | 'displayId' | 窗口显示设备ID属性的参数名。 | ## ErrorCode diff --git a/zh-cn/application-dev/reference/apis/js-apis-ability-particleAbility.md b/zh-cn/application-dev/reference/apis/js-apis-ability-particleAbility.md index ff2c0379e3a934a26ba54e8da63f77b240540fef..e72eb4246eac4e18116566d4a3556f723a5de2ff 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-ability-particleAbility.md +++ b/zh-cn/application-dev/reference/apis/js-apis-ability-particleAbility.md @@ -14,7 +14,7 @@ particleAbility模块用来对Data和Service类型的Ability进行操作。 ## 导入模块 ```ts -import particleAbility from '@ohos.ability.particleAbility' +import particleAbility from '@ohos.ability.particleAbility'; ``` ## particleAbility.startAbility @@ -40,27 +40,27 @@ startAbility(parameter: StartAbilityParameter, callback: AsyncCallback\): **示例:** ```ts -import particleAbility from '@ohos.ability.particleAbility' -import wantConstant from '@ohos.ability.wantConstant' +import particleAbility from '@ohos.ability.particleAbility'; +import wantConstant from '@ohos.ability.wantConstant'; particleAbility.startAbility( { want: { - action: "action.system.home", - entities: ["entity.system.home"], - type: "MIMETYPE", + action: 'action.system.home', + entities: ['entity.system.home'], + type: 'MIMETYPE', flags: wantConstant.Flags.FLAG_AUTH_READ_URI_PERMISSION, - deviceId: "", - bundleName: "com.example.Data", - abilityName: "com.example.Data.MainAbility", - uri: "" + deviceId: '', + bundleName: 'com.example.Data', + abilityName: 'com.example.Data.MainAbility', + uri: '' }, }, (error, result) => { - console.log('particleAbility startAbility errCode:' + error + 'result:' + result) + console.log('particleAbility startAbility errCode:' + error + 'result:' + result); }, -) +); ``` ## particleAbility.startAbility @@ -91,25 +91,25 @@ startAbility(parameter: StartAbilityParameter): Promise\; **示例:** ```ts -import particleAbility from '@ohos.ability.particleAbility' -import wantConstant from '@ohos.ability.wantConstant' +import particleAbility from '@ohos.ability.particleAbility'; +import wantConstant from '@ohos.ability.wantConstant'; particleAbility.startAbility( { want: { - action: "action.system.home", - entities: ["entity.system.home"], - type: "MIMETYPE", + action: 'action.system.home', + entities: ['entity.system.home'], + type: 'MIMETYPE', flags: wantConstant.Flags.FLAG_AUTH_READ_URI_PERMISSION, - deviceId: "", - bundleName: "com.example.Data", - abilityName: "com.example. Data.MainAbility", - uri: "" + deviceId: '', + bundleName: 'com.example.Data', + abilityName: 'com.example. Data.MainAbility', + uri: '' }, }, ).then((data) => { - console.info("particleAbility startAbility"); + console.info('particleAbility startAbility'); }); ``` @@ -130,13 +130,13 @@ terminateSelf(callback: AsyncCallback\): void **示例:** ```ts -import particleAbility from '@ohos.ability.particleAbility' +import particleAbility from '@ohos.ability.particleAbility'; particleAbility.terminateSelf( (error, result) => { - console.log('particleAbility terminateSelf errCode:' + error + 'result:' + result) + console.log('particleAbility terminateSelf errCode:' + error + 'result:' + result); } -) +); ``` ## particleAbility.terminateSelf @@ -156,10 +156,10 @@ terminateSelf(): Promise\ **示例:** ```ts -import particleAbility from '@ohos.ability.particleAbility' +import particleAbility from '@ohos.ability.particleAbility'; particleAbility.terminateSelf().then((data) => { - console.info("particleAbility terminateSelf"); + console.info('particleAbility terminateSelf'); }); ``` @@ -188,10 +188,10 @@ acquireDataAbilityHelper(uri: string): DataAbilityHelper **示例:** ```ts -import particleAbility from '@ohos.ability.particleAbility' +import particleAbility from '@ohos.ability.particleAbility'; -let uri = ""; -particleAbility.acquireDataAbilityHelper(uri) +let uri = ''; +particleAbility.acquireDataAbilityHelper(uri); ``` @@ -222,17 +222,17 @@ import wantAgent from '@ohos.wantAgent'; function callback(err, data) { if (err) { - console.error("Operation failed cause: " + JSON.stringify(err)); + console.error('Operation failed cause: ' + JSON.stringify(err)); } else { - console.info("Operation succeeded"); + console.info('Operation succeeded'); } } let wantAgentInfo = { wants: [ { - bundleName: "com.example.myapplication", - abilityName: "com.example.myapplication.MainAbility" + bundleName: 'com.example.myapplication', + abilityName: 'com.example.myapplication.MainAbility' } ], operationType: wantAgent.OperationType.START_ABILITY, @@ -242,8 +242,8 @@ let wantAgentInfo = { wantAgent.getWantAgent(wantAgentInfo).then((wantAgentObj) => { let basicContent = { - title: "title", - text: "text" + title: 'title', + text: 'text' }; let notificationContent = { contentType: notification.ContentType.NOTIFICATION_CONTENT_BASIC_TEXT, @@ -292,8 +292,8 @@ import wantAgent from '@ohos.wantAgent'; let wantAgentInfo = { wants: [ { - bundleName: "com.example.myapplication", - abilityName: "com.example.myapplication.MainAbility" + bundleName: 'com.example.myapplication', + abilityName: 'com.example.myapplication.MainAbility' } ], operationType: wantAgent.OperationType.START_ABILITY, @@ -303,8 +303,8 @@ let wantAgentInfo = { wantAgent.getWantAgent(wantAgentInfo).then((wantAgentObj) => { let basicContent = { - title: "title", - text: "text" + title: 'title', + text: 'text' }; let notificationContent = { contentType: notification.ContentType.NOTIFICATION_CONTENT_BASIC_TEXT, @@ -316,9 +316,9 @@ wantAgent.getWantAgent(wantAgentInfo).then((wantAgentObj) => { }; let id = 1; particleAbility.startBackgroundRunning(id, request).then(() => { - console.info("Operation succeeded"); + console.info('Operation succeeded'); }).catch((err) => { - console.error("Operation failed cause: " + JSON.stringify(err)); + console.error('Operation failed cause: ' + JSON.stringify(err)); }); }); @@ -345,9 +345,9 @@ import particleAbility from '@ohos.ability.particleAbility'; function callback(err, data) { if (err) { - console.error("Operation failed cause: " + JSON.stringify(err)); + console.error('Operation failed cause: ' + JSON.stringify(err)); } else { - console.info("Operation succeeded"); + console.info('Operation succeeded'); } } @@ -375,9 +375,9 @@ cancelBackgroundRunning(): Promise<void>; import particleAbility from '@ohos.ability.particleAbility'; particleAbility.cancelBackgroundRunning().then(() => { - console.info("Operation succeeded"); + console.info('Operation succeeded'); }).catch((err) => { - console.error("Operation failed cause: " + JSON.stringify(err)); + console.error('Operation failed cause: ' + JSON.stringify(err)); }); ``` @@ -401,25 +401,25 @@ connectAbility(request: Want, options:ConnectOptions): number **示例**: ```ts -import particleAbility from '@ohos.ability.particleAbility' -import rpc from '@ohos.rpc' +import particleAbility from '@ohos.ability.particleAbility'; +import rpc from '@ohos.rpc'; function onConnectCallback(element, remote) { console.log('ConnectAbility onConnect remote is proxy:' + (remote instanceof rpc.RemoteProxy)); } function onDisconnectCallback(element) { - console.log('ConnectAbility onDisconnect element.deviceId : ' + element.deviceId) + console.log('ConnectAbility onDisconnect element.deviceId : ' + element.deviceId); } function onFailedCallback(code) { - console.log('particleAbilityTest ConnectAbility onFailed errCode : ' + code) + console.log('particleAbilityTest ConnectAbility onFailed errCode : ' + code); } let connId = particleAbility.connectAbility( { - bundleName: "com.ix.ServiceAbility", - abilityName: "ServiceAbilityA", + bundleName: 'com.ix.ServiceAbility', + abilityName: 'ServiceAbilityA', }, { onConnect: onConnectCallback, @@ -429,9 +429,9 @@ let connId = particleAbility.connectAbility( ); particleAbility.disconnectAbility(connId).then((data) => { - console.log(" data: " + data); + console.log(' data: ' + data); }).catch((error) => { - console.log('particleAbilityTest result errCode : ' + error.code) + console.log('particleAbilityTest result errCode : ' + error.code); }); ``` @@ -460,17 +460,17 @@ function onConnectCallback(element, remote) { } function onDisconnectCallback(element) { - console.log('ConnectAbility onDisconnect element.deviceId : ' + element.deviceId) + console.log('ConnectAbility onDisconnect element.deviceId : ' + element.deviceId); } function onFailedCallback(code) { - console.log('particleAbilityTest ConnectAbility onFailed errCode : ' + code) + console.log('particleAbilityTest ConnectAbility onFailed errCode : ' + code); } let connId = particleAbility.connectAbility( { - bundleName: "com.ix.ServiceAbility", - abilityName: "ServiceAbilityA", + bundleName: 'com.ix.ServiceAbility', + abilityName: 'ServiceAbilityA', }, { onConnect: onConnectCallback, @@ -480,8 +480,8 @@ let connId = particleAbility.connectAbility( ); particleAbility.disconnectAbility(connId, (err) => { - console.log("particleAbilityTest disconnectAbility err====>" - + ("json err=") + JSON.stringify(err)); + console.log('particleAbilityTest disconnectAbility err====>' + + ('json err=') + JSON.stringify(err)); }); ``` @@ -511,17 +511,17 @@ function onConnectCallback(element, remote) { } function onDisconnectCallback(element) { - console.log('ConnectAbility onDisconnect element.deviceId : ' + element.deviceId) + console.log('ConnectAbility onDisconnect element.deviceId : ' + element.deviceId); } function onFailedCallback(code) { - console.log('particleAbilityTest ConnectAbility onFailed errCode : ' + code) + console.log('particleAbilityTest ConnectAbility onFailed errCode : ' + code); } let connId = particleAbility.connectAbility( { - bundleName: "com.ix.ServiceAbility", - abilityName: "ServiceAbilityA", + bundleName: 'com.ix.ServiceAbility', + abilityName: 'ServiceAbilityA', }, { onConnect: onConnectCallback, @@ -531,9 +531,9 @@ let connId = particleAbility.connectAbility( ); particleAbility.disconnectAbility(connId).then((data) => { - console.log(" data: " + data); + console.log(' data: ' + data); }).catch((error) => { - console.log('particleAbilityTest result errCode : ' + error.code) + console.log('particleAbilityTest result errCode : ' + error.code); }); ``` diff --git a/zh-cn/application-dev/reference/apis/js-apis-app-ability-abilityConstant.md b/zh-cn/application-dev/reference/apis/js-apis-app-ability-abilityConstant.md index c07b6c469d6b32f365ac9e5e65a420489e328862..b19d7b67d4b2c55bd2fa9ae5c6a9f9ec4a40f134 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-app-ability-abilityConstant.md +++ b/zh-cn/application-dev/reference/apis/js-apis-app-ability-abilityConstant.md @@ -48,7 +48,7 @@ import UIAbility from '@ohos.app.ability.UIAbility'; class MyAbility extends UIAbility { onCreate(want, launchParam) { if (launchParam.launchReason === AbilityConstant.LaunchReason.START_ABILITY) { - console.log("The ability has been started by the way of startAbility."); + console.log('The ability has been started by the way of startAbility.'); } } } @@ -74,7 +74,7 @@ import UIAbility from '@ohos.app.ability.UIAbility'; class MyAbility extends UIAbility { onCreate(want, launchParam) { if (launchParam.lastExitReason === AbilityConstant.LastExitReason.ABILITY_NOT_RESPONDING) { - console.log("The ability has exit last because the ability was not responding."); + console.log('The ability has exit last because the ability was not responding.'); } } } @@ -122,8 +122,8 @@ class MyAbility extends UIAbility { ```ts let want = { - bundleName: "com.test.example", - abilityName: "MainAbility" + bundleName: 'com.test.example', + abilityName: 'MainAbility' }; let option = { windowMode: AbilityConstant.WindowMode.WINDOW_MODE_FULLSCREEN @@ -131,9 +131,9 @@ let option = { // 确保从上下文获取到context this.context.startAbility(want, option).then(()={ - console.log("Succeed to start ability."); + console.log('Succeed to start ability.'); }).catch((error)=>{ - console.log("Failed to start ability with error: " + JSON.stringify(error)); + console.log('Failed to start ability with error: ' + JSON.stringify(error)); }); ``` @@ -157,7 +157,7 @@ import UIAbility from '@ohos.app.ability.UIAbility'; class MyAbility extends UIAbility { onMemoryLevel(level) { if (level === AbilityConstant.MemoryLevel.MEMORY_LEVEL_CRITICAL) { - console.log("The memory of device is critical, please release some memory."); + console.log('The memory of device is critical, please release some memory.'); } } } @@ -209,7 +209,7 @@ import UIAbility from '@ohos.app.ability.UIAbility'; class MyAbility extends UIAbility { onSaveState(reason, wantParam) { if (reason === AbilityConstant.StateType.CONTINUATION) { - console.log("Save the ability data when the ability continuation."); + console.log('Save the ability data when the ability continuation.'); } return AbilityConstant.OnSaveResult.ALL_AGREE; } diff --git a/zh-cn/application-dev/reference/apis/js-apis-app-ability-abilityDelegatorRegistry.md b/zh-cn/application-dev/reference/apis/js-apis-app-ability-abilityDelegatorRegistry.md index 3fb88dfc5eba562d52fa0ed6da2435ef42961d95..f08c8bd3a0a786339696971abe7730da40953e68 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-app-ability-abilityDelegatorRegistry.md +++ b/zh-cn/application-dev/reference/apis/js-apis-app-ability-abilityDelegatorRegistry.md @@ -49,14 +49,14 @@ import AbilityDelegatorRegistry from '@ohos.app.ability.abilityDelegatorRegistry let abilityDelegator = AbilityDelegatorRegistry.getAbilityDelegator(); let want = { - bundleName: "com.ohos.example", - abilityName: "MainAbility" + bundleName: 'com.ohos.example', + abilityName: 'MainAbility' }; abilityDelegator.startAbility(want, (err) => { if (err.code !== 0) { - console.log("Success start ability."); + console.log('Success start ability.'); } else { - console.log("Failed start ability, error: " + JSON.stringify(err)); + console.log('Failed start ability, error: ' + JSON.stringify(err)); } }) ``` @@ -81,8 +81,8 @@ getArguments(): AbilityDelegatorArgs import AbilityDelegatorRegistry from '@ohos.app.ability.abilityDelegatorRegistry'; let args = AbilityDelegatorRegistry.getArguments(); -console.info("getArguments bundleName:" + args.bundleName); -console.info("getArguments parameters:" + JSON.stringify(args.parameters)); -console.info("getArguments testCaseNames:" + args.testCaseNames); -console.info("getArguments testRunnerClassName:" + args.testRunnerClassName); +console.info('getArguments bundleName:' + args.bundleName); +console.info('getArguments parameters:' + JSON.stringify(args.parameters)); +console.info('getArguments testCaseNames:' + args.testCaseNames); +console.info('getArguments testRunnerClassName:' + args.testRunnerClassName); ``` diff --git a/zh-cn/application-dev/reference/apis/js-apis-app-ability-abilityLifecycleCallback.md b/zh-cn/application-dev/reference/apis/js-apis-app-ability-abilityLifecycleCallback.md index 919cbce9d3af5bb0991b425ea5bc1daff90b1e7d..e10b75fc766e5c20f2bbca4695574b8992765c4a 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-app-ability-abilityLifecycleCallback.md +++ b/zh-cn/application-dev/reference/apis/js-apis-app-ability-abilityLifecycleCallback.md @@ -11,7 +11,7 @@ AbilityLifecycleCallback模块提供应用上下文[ApplicationContext](js-apis- ## 导入模块 ```ts -import AbilityLifecycleCallback from "@ohos.app.ability.AbilityLifecycleCallback"; +import AbilityLifecycleCallback from '@ohos.app.ability.AbilityLifecycleCallback'; ``` @@ -33,7 +33,7 @@ onAbilityCreate(ability: UIAbility): void; ```ts let abilityLifecycleCallback = { onAbilityCreate(ability){ - console.log("AbilityLifecycleCallback onAbilityCreate."); + console.log('AbilityLifecycleCallback onAbilityCreate.'); } }; ``` @@ -57,7 +57,7 @@ onWindowStageCreate(ability: UIAbility, windowStage: window.WindowStage): void; ```ts let abilityLifecycleCallback = { onWindowStageCreate(ability, windowStage){ - console.log("AbilityLifecycleCallback onWindowStageCreate."); + console.log('AbilityLifecycleCallback onWindowStageCreate.'); } }; ``` @@ -81,7 +81,7 @@ onWindowStageActive(ability: UIAbility, windowStage: window.WindowStage): void; ```ts let abilityLifecycleCallback = { onWindowStageActive(ability, windowStage){ - console.log("AbilityLifecycleCallback onWindowStageActive."); + console.log('AbilityLifecycleCallback onWindowStageActive.'); } }; ``` @@ -105,7 +105,7 @@ onWindowStageInactive(ability: UIAbility, windowStage: window.WindowStage): void ```ts let abilityLifecycleCallback = { onWindowStageInactive(ability, windowStage){ - console.log("AbilityLifecycleCallback onWindowStageInactive."); + console.log('AbilityLifecycleCallback onWindowStageInactive.'); } }; ``` @@ -129,7 +129,7 @@ onWindowStageDestroy(ability: UIAbility, windowStage: window.WindowStage): void; ```ts let abilityLifecycleCallback = { onWindowStageDestroy(ability, windowStage){ - console.log("AbilityLifecycleCallback onWindowStageDestroy."); + console.log('AbilityLifecycleCallback onWindowStageDestroy.'); } }; ``` @@ -152,7 +152,7 @@ onAbilityDestroy(ability: UIAbility): void; ```ts let abilityLifecycleCallback = { onAbilityDestroy(ability){ - console.log("AbilityLifecycleCallback onAbilityDestroy."); + console.log('AbilityLifecycleCallback onAbilityDestroy.'); } }; ``` @@ -175,7 +175,7 @@ onAbilityForeground(ability: UIAbility): void; ```ts let abilityLifecycleCallback = { onAbilityForeground(ability){ - console.log("AbilityLifecycleCallback onAbilityForeground."); + console.log('AbilityLifecycleCallback onAbilityForeground.'); } }; ``` @@ -198,7 +198,7 @@ onAbilityBackground(ability: UIAbility): void; ```ts let abilityLifecycleCallback = { onAbilityBackground(ability){ - console.log("AbilityLifecycleCallback onAbilityBackground."); + console.log('AbilityLifecycleCallback onAbilityBackground.'); } }; ``` @@ -221,7 +221,7 @@ onAbilityContinue(ability: UIAbility): void; ```ts let abilityLifecycleCallback = { onAbilityContinue(ability){ - console.log("AbilityLifecycleCallback onAbilityContinue."); + console.log('AbilityLifecycleCallback onAbilityContinue.'); } }; ``` @@ -232,52 +232,52 @@ let abilityLifecycleCallback = { MyFirstAbility.ts ```ts -import AbilityLifecycleCallback from "@ohos.app.ability.AbilityLifecycleCallback"; -import AbilityStage from "@ohos.app.ability.AbilityStage"; +import AbilityLifecycleCallback from '@ohos.app.ability.AbilityLifecycleCallback'; +import AbilityStage from '@ohos.app.ability.AbilityStage'; import UIAbility from '@ohos.app.ability.UIAbility'; // 声明ability生命周期回调,需配置所有回调后才可以在applicationContext注册 let abilityLifecycleCallback = { onAbilityCreate(ability){ - console.log("AbilityLifecycleCallback onAbilityCreate."); + console.log('AbilityLifecycleCallback onAbilityCreate.'); }, onWindowStageCreate(ability, windowStage){ - console.log("AbilityLifecycleCallback onWindowStageCreate."); + console.log('AbilityLifecycleCallback onWindowStageCreate.'); }, onWindowStageActive(ability, windowStage){ - console.log("AbilityLifecycleCallback onWindowStageActive."); + console.log('AbilityLifecycleCallback onWindowStageActive.'); }, onWindowStageInactive(ability, windowStage){ - console.log("AbilityLifecycleCallback onWindowStageInactive."); + console.log('AbilityLifecycleCallback onWindowStageInactive.'); }, onWindowStageDestroy(ability, windowStage){ - console.log("AbilityLifecycleCallback onWindowStageDestroy."); + console.log('AbilityLifecycleCallback onWindowStageDestroy.'); }, onAbilityDestroy(ability){ - console.log("AbilityLifecycleCallback onAbilityDestroy."); + console.log('AbilityLifecycleCallback onAbilityDestroy.'); }, onAbilityForeground(ability){ - console.log("AbilityLifecycleCallback onAbilityForeground."); + console.log('AbilityLifecycleCallback onAbilityForeground.'); }, onAbilityBackground(ability){ - console.log("AbilityLifecycleCallback onAbilityBackground."); + console.log('AbilityLifecycleCallback onAbilityBackground.'); }, onAbilityContinue(ability){ - console.log("AbilityLifecycleCallback onAbilityContinue."); + console.log('AbilityLifecycleCallback onAbilityContinue.'); } }; export default class MyFirstAbility extends UIAbility { onCreate() { - console.log("MyAbilityStage onCreate"); + console.log('MyAbilityStage onCreate'); // 1.通过context属性获取applicationContext let applicationContext = this.context.getApplicationContext(); // 2.通过applicationContext注册监听应用内生命周期 try { - globalThis.lifecycleId = applicationContext.on("abilityLifecycle", abilityLifecycleCallback); - console.log("registerAbilityLifecycleCallback number: " + JSON.stringify(lifecycleId)); + globalThis.lifecycleId = applicationContext.on('abilityLifecycle', abilityLifecycleCallback); + console.log('registerAbilityLifecycleCallback number: ' + JSON.stringify(lifecycleId)); } catch (paramError) { - console.log("error: " + paramError.code + " ," + paramError.message); + console.log('error: ' + paramError.code + ' ,' + paramError.message); } } } @@ -285,17 +285,17 @@ export default class MyFirstAbility extends UIAbility { MySecondAbility.ts ```ts -import UIAbility from "ohos.app.ability.UIAbility"; +import UIAbility from 'ohos.app.ability.UIAbility'; export default class MySecondAbility extends UIAbility { onDestroy() { let applicationContext = this.context.getApplicationContext(); // 3.通过applicationContext注销监听应用内生命周期 - applicationContext.off("abilityLifecycle", globalThis.lifecycleId, (error) => { + applicationContext.off('abilityLifecycle', globalThis.lifecycleId, (error) => { if (error.code != 0) { - console.log("unregisterAbilityLifecycleCallback failed, error: " + JSON.stringify(error)); + console.log('unregisterAbilityLifecycleCallback failed, error: ' + JSON.stringify(error)); } else { - console.log("unregisterAbilityLifecycleCallback success."); + console.log('unregisterAbilityLifecycleCallback success.'); } }); } diff --git a/zh-cn/application-dev/reference/apis/js-apis-app-ability-abilityManager.md b/zh-cn/application-dev/reference/apis/js-apis-app-ability-abilityManager.md index 2ca889c93fbe78893b5ac071bd7fbacfa836ccc7..c14b772aee8fcc2efbb540f6b615a974dc4e4acf 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-app-ability-abilityManager.md +++ b/zh-cn/application-dev/reference/apis/js-apis-app-ability-abilityManager.md @@ -63,7 +63,7 @@ const config = { language: 'Zh-Hans', // 简体中文 colorMode: COLOR_MODE_LIGHT, // 浅色模式 direction: DIRECTION_VERTICAL, // 垂直方向 - screenDensity: SCREEN_DENSITY_SDPI, // 屏幕分辨率为"sdpi" + screenDensity: SCREEN_DENSITY_SDPI, // 屏幕分辨率为'sdpi' displayId: 1, // 应用在Id为1的物理屏上显示 hasPointerDevice: true, // 指针类型设备已连接 }; @@ -71,9 +71,9 @@ const config = { try { abilityManager.updateConfiguration(config, (err) => { if (err.code !== 0) { - console.log("updateConfiguration fail, err: " + JSON.stringify(err)); + console.log('updateConfiguration fail, err: ' + JSON.stringify(err)); } else { - console.log("updateConfiguration success."); + console.log('updateConfiguration success.'); } }) } catch (paramError) { @@ -121,7 +121,7 @@ const config = { language: 'Zh-Hans', // 简体中文 colorMode: COLOR_MODE_LIGHT, // 浅色模式 direction: DIRECTION_VERTICAL, // 垂直方向 - screenDensity: SCREEN_DENSITY_SDPI, // 屏幕分辨率为"sdpi" + screenDensity: SCREEN_DENSITY_SDPI, // 屏幕分辨率为'sdpi' displayId: 1, // 应用在Id为1的物理屏上显示 hasPointerDevice: true, // 指针类型设备已连接 }; @@ -170,9 +170,9 @@ import abilityManager from '@ohos.app.ability.abilityManager'; try { abilityManager.getAbilityRunningInfos((err, data) => { if (err.code !== 0) { - console.log("getAbilityRunningInfos fail, error: " + JSON.stringify(err)); + console.log('getAbilityRunningInfos fail, error: ' + JSON.stringify(err)); } else { - console.log("getAbilityRunningInfos success, data: " + JSON.stringify(data)); + console.log('getAbilityRunningInfos success, data: ' + JSON.stringify(data)); } }); } catch (paramError) { @@ -212,9 +212,9 @@ import abilityManager from '@ohos.app.ability.abilityManager'; try { abilityManager.getAbilityRunningInfos().then((data) => { - console.log("getAbilityRunningInfos success, data: " + JSON.stringify(data)) + console.log('getAbilityRunningInfos success, data: ' + JSON.stringify(data)); }).catch((err) => { - console.log("getAbilityRunningInfos fail, err: " + JSON.stringify(err)); + console.log('getAbilityRunningInfos fail, err: ' + JSON.stringify(err)); }); } catch (paramError) { console.log('error.code: ' + JSON.stringify(paramError.code) @@ -257,9 +257,9 @@ let upperLimit = 10; try { abilityManager.getExtensionRunningInfos(upperLimit, (err, data) => { if (err.code !== 0) { - console.log("getExtensionRunningInfos fail, err: " + JSON.stringify(err)); + console.log('getExtensionRunningInfos fail, err: ' + JSON.stringify(err)); } else { - console.log("getExtensionRunningInfos success, data: " + JSON.stringify(data)); + console.log('getExtensionRunningInfos success, data: ' + JSON.stringify(data)); } }); } catch (paramError) { @@ -307,9 +307,9 @@ let upperLimit = 10; try { abilityManager.getExtensionRunningInfos(upperLimit).then((data) => { - console.log("getExtensionRunningInfos success, data: " + JSON.stringify(data)); + console.log('getExtensionRunningInfos success, data: ' + JSON.stringify(data)); }).catch((err) => { - console.log("getExtensionRunningInfos fail, err: " + JSON.stringify(err)); + console.log('getExtensionRunningInfos fail, err: ' + JSON.stringify(err)); }) } catch (paramError) { console.log('error.code: ' + JSON.stringify(paramError.code) @@ -346,9 +346,9 @@ import abilityManager from '@ohos.app.ability.abilityManager'; abilityManager.getTopAbility((err, data) => { if (err.code !== 0) { - console.log("getTopAbility fail, err: " + JSON.stringify(err)); + console.log('getTopAbility fail, err: ' + JSON.stringify(err)); } else { - console.log("getTopAbility success, data: " + JSON.stringify(data)); + console.log('getTopAbility success, data: ' + JSON.stringify(data)); } }); ``` @@ -381,8 +381,8 @@ getTopAbility(): Promise\; import abilityManager from '@ohos.app.ability.abilityManager'; abilityManager.getTopAbility().then((data) => { - console.log("getTopAbility success, data: " + JSON.stringify(data)); + console.log('getTopAbility success, data: ' + JSON.stringify(data)); }).catch((err) => { - console.log("getTopAbility fail, err: " + JSON.stringify(err)); + console.log('getTopAbility fail, err: ' + JSON.stringify(err)); }) ``` \ No newline at end of file diff --git a/zh-cn/application-dev/reference/apis/js-apis-app-ability-abilityStage.md b/zh-cn/application-dev/reference/apis/js-apis-app-ability-abilityStage.md index 310b6df02cfdadc6ef31b9744a7cdb8937e587c8..22779603bf712a1fe4d421d7e8787b228ea8c0a5 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-app-ability-abilityStage.md +++ b/zh-cn/application-dev/reference/apis/js-apis-app-ability-abilityStage.md @@ -30,7 +30,7 @@ import AbilityStage from '@ohos.app.ability.AbilityStage'; class MyAbilityStage extends AbilityStage { onCreate() { - console.log("MyAbilityStage.onCreate is called"); + console.log('MyAbilityStage.onCreate is called'); } } ``` @@ -63,8 +63,8 @@ import AbilityStage from '@ohos.app.ability.AbilityStage'; class MyAbilityStage extends AbilityStage { onAcceptWant(want) { - console.log("MyAbilityStage.onAcceptWant called"); - return "com.example.test"; + console.log('MyAbilityStage.onAcceptWant called'); + return 'com.example.test'; } } ``` diff --git a/zh-cn/application-dev/reference/apis/js-apis-app-ability-appManager.md b/zh-cn/application-dev/reference/apis/js-apis-app-ability-appManager.md index d150ed4402ef238f551a135cfcc3740f5c4f09ae..13a5d31faf1066605308e5293f31c4c470f7fc9c 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-app-ability-appManager.md +++ b/zh-cn/application-dev/reference/apis/js-apis-app-ability-appManager.md @@ -41,9 +41,9 @@ import appManager from '@ohos.app.ability.appManager'; appManager.isRunningInStabilityTest((err, flag) => { if (err.code !== 0) { - console.log("isRunningInStabilityTest faile, err: " + JSON.stringify(err)); + console.log('isRunningInStabilityTest faile, err: ' + JSON.stringify(err)); } else { - console.log("The result of isRunningInStabilityTest is:" + JSON.stringify(flag)); + console.log('The result of isRunningInStabilityTest is:' + JSON.stringify(flag)); } }) ``` @@ -77,9 +77,9 @@ static isRunningInStabilityTest(): Promise<boolean> import appManager from '@ohos.app.ability.appManager'; appManager.isRunningInStabilityTest().then((flag) => { - console.log("The result of isRunningInStabilityTest is:" + JSON.stringify(flag)); + console.log('The result of isRunningInStabilityTest is:' + JSON.stringify(flag)); }).catch((error) => { - console.log("error:" + JSON.stringify(error)); + console.log('error:' + JSON.stringify(error)); }); ``` @@ -112,9 +112,9 @@ isRamConstrainedDevice(): Promise\; import appManager from '@ohos.app.ability.appManager'; appManager.isRamConstrainedDevice().then((data) => { - console.log("The result of isRamConstrainedDevice is:" + JSON.stringify(data)); + console.log('The result of isRamConstrainedDevice is:' + JSON.stringify(data)); }).catch((error) => { - console.log("error:" + JSON.stringify(error)); + console.log('error:' + JSON.stringify(error)); }); ``` @@ -147,9 +147,9 @@ import appManager from '@ohos.app.ability.appManager'; appManager.isRamConstrainedDevice((err, data) => { if (err.code !== 0) { - console.log("isRamConstrainedDevice faile, err: " + JSON.stringify(err)); + console.log('isRamConstrainedDevice faile, err: ' + JSON.stringify(err)); } else { - console.log("The result of isRamConstrainedDevice is:" + JSON.stringify(data)); + console.log('The result of isRamConstrainedDevice is:' + JSON.stringify(data)); } }) ``` @@ -182,9 +182,9 @@ getAppMemorySize(): Promise\; import appManager from '@ohos.app.ability.appManager'; appManager.getAppMemorySize().then((data) => { - console.log("The size of app memory is:" + JSON.stringify(data)); + console.log('The size of app memory is:' + JSON.stringify(data)); }).catch((error) => { - console.log("error:" + JSON.stringify(error)); + console.log('error:' + JSON.stringify(error)); }); ``` @@ -217,9 +217,9 @@ import appManager from '@ohos.app.ability.appManager'; appManager.getAppMemorySize((err, data) => { if (err.code !== 0) { - console.log("getAppMemorySize faile, err: " + JSON.stringify(err)); + console.log('getAppMemorySize faile, err: ' + JSON.stringify(err)); } else { - console.log("The size of app memory is:" + JSON.stringify(data)); + console.log('The size of app memory is:' + JSON.stringify(data)); } }) ``` @@ -256,9 +256,9 @@ getProcessRunningInformation(): Promise\>; import appManager from '@ohos.app.ability.appManager'; appManager.getProcessRunningInformation().then((data) => { - console.log("The process running information is:" + JSON.stringify(data)); + console.log('The process running information is:' + JSON.stringify(data)); }).catch((error) => { - console.log("error:" + JSON.stringify(error)); + console.log('error:' + JSON.stringify(error)); }); ``` @@ -295,16 +295,16 @@ import appManager from '@ohos.app.ability.appManager'; appManager.getProcessRunningInformation((err, data) => { if (err.code !== 0) { - console.log("getProcessRunningInformation faile, err: " + JSON.stringify(err)); + console.log('getProcessRunningInformation faile, err: ' + JSON.stringify(err)); } else { - console.log("The process running information is:" + JSON.stringify(data)); + console.log('The process running information is:' + JSON.stringify(data)); } }) ``` ## appManager.on -on(type: "applicationState", observer: ApplicationStateObserver): number; +on(type: 'applicationState', observer: ApplicationStateObserver): number; 注册全部应用程序的状态观测器。 @@ -318,7 +318,7 @@ on(type: "applicationState", observer: ApplicationStateObserver): number; | 参数名 | 类型 | 必填 | 说明 | | -------- | -------- | -------- | -------- | -| type | string | 是 | 调用接口类型,固定填"applicationState"字符串。 | +| type | string | 是 | 调用接口类型,固定填'applicationState'字符串。 | | observer | [ApplicationStateObserver](./js-apis-inner-application-applicationStateObserver.md) | 是 | 应用状态观测器,用于观测应用的生命周期变化。 | **返回值:** @@ -367,7 +367,7 @@ try { ## appManager.on -on(type: "applicationState", observer: ApplicationStateObserver, bundleNameList: Array\): number; +on(type: 'applicationState', observer: ApplicationStateObserver, bundleNameList: Array\): number; 注册指定应用程序的状态观测器。 @@ -381,7 +381,7 @@ on(type: "applicationState", observer: ApplicationStateObserver, bundleNameList: | 参数名 | 类型 | 必填 | 说明 | | -------- | -------- | -------- | -------- | -| type | string | 是 | 调用接口类型,固定填"applicationState"字符串。 | +| type | string | 是 | 调用接口类型,固定填'applicationState'字符串。 | | observer | [ApplicationStateObserver](./js-apis-inner-application-applicationStateObserver.md) | 是 | 应用状态观测器,用于观测应用的生命周期变化。 | | bundleNameList | `Array` | 是 | 表示需要注册监听的bundleName数组。最大值128。 | @@ -423,7 +423,7 @@ let applicationStateObserver = { } let bundleNameList = ['bundleName1', 'bundleName2']; try { - const observerId = appManager.on("applicationState", applicationStateObserver, bundleNameList); + const observerId = appManager.on('applicationState', applicationStateObserver, bundleNameList); console.log(`[appManager] observerCode: ${observerId}`); } catch (paramError) { console.log(`[appManager] error: ${paramError.code}, ${paramError.message} `); @@ -432,7 +432,7 @@ try { ## appManager.off -off(type: "applicationState", observerId: number, callback: AsyncCallback\): void; +off(type: 'applicationState', observerId: number, callback: AsyncCallback\): void; 取消注册应用程序状态观测器。 @@ -446,7 +446,7 @@ off(type: "applicationState", observerId: number, callback: AsyncCallback\ | 是 | 以回调方式返回接口运行结果,可进行错误处理或其他自定义处理。 | @@ -485,7 +485,7 @@ let applicationStateObserver = { } let bundleNameList = ['bundleName1', 'bundleName2']; try { - observerId = appManager.on("applicationState", applicationStateObserver, bundleNameList); + observerId = appManager.on('applicationState', applicationStateObserver, bundleNameList); console.log(`[appManager] observerCode: ${observerId}`); } catch (paramError) { console.log(`[appManager] error: ${paramError.code}, ${paramError.message} `); @@ -494,13 +494,13 @@ try { // 2.注销应用状态监听器 function unregisterApplicationStateObserverCallback(err) { if (err.code !== 0) { - console.log("unregisterApplicationStateObserverCallback faile, err: " + JSON.stringify(err)); + console.log('unregisterApplicationStateObserverCallback faile, err: ' + JSON.stringify(err)); } else { - console.log("unregisterApplicationStateObserverCallback success."); + console.log('unregisterApplicationStateObserverCallback success.'); } } try { - appManager.off("applicationState", observerId, unregisterApplicationStateObserverCallback); + appManager.off('applicationState', observerId, unregisterApplicationStateObserverCallback); } catch (paramError) { console.log('error: ' + paramError.code + ', ' + paramError.message); } @@ -508,7 +508,7 @@ try { ## appManager.off -off(type: "applicationState", observerId: number): Promise\; +off(type: 'applicationState', observerId: number): Promise\; 取消注册应用程序状态观测器。 @@ -522,7 +522,7 @@ off(type: "applicationState", observerId: number): Promise\; | 参数名 | 类型 | 必填 | 说明 | | -------- | -------- | -------- | -------- | -| type | string | 是 | 调用接口类型,固定填"applicationState"字符串。 | +| type | string | 是 | 调用接口类型,固定填'applicationState'字符串。 | | observerId | number | 是 | 表示观测器的编号代码。 | **返回值:** @@ -566,7 +566,7 @@ let applicationStateObserver = { } let bundleNameList = ['bundleName1', 'bundleName2']; try { - observerId = appManager.on("applicationState", applicationStateObserver, bundleNameList); + observerId = appManager.on('applicationState', applicationStateObserver, bundleNameList); console.log(`[appManager] observerCode: ${observerId}`); } catch (paramError) { console.log(`[appManager] error: ${paramError.code}, ${paramError.message} `); @@ -574,10 +574,10 @@ try { // 2.注销应用状态监听器 try { - appManager.off("applicationState", observerId).then((data) => { - console.log("unregisterApplicationStateObserver success, data: " + JSON.stringify(data)); + appManager.off('applicationState', observerId).then((data) => { + console.log('unregisterApplicationStateObserver success, data: ' + JSON.stringify(data)); }).catch((err) => { - console.log("unregisterApplicationStateObserver faile, err: " + JSON.stringify(err)); + console.log('unregisterApplicationStateObserver faile, err: ' + JSON.stringify(err)); }) } catch (paramError) { console.log('error: ' + paramError.code + ', ' + paramError.message); @@ -617,15 +617,15 @@ import appManager from '@ohos.app.ability.appManager'; function getForegroundApplicationsCallback(err, data) { if (err.code !== 0) { - console.log("getForegroundApplicationsCallback fail, err: " + JSON.stringify(err)); + console.log('getForegroundApplicationsCallback fail, err: ' + JSON.stringify(err)); } else { - console.log("getForegroundApplicationsCallback success, data: " + JSON.stringify(data)); + console.log('getForegroundApplicationsCallback success, data: ' + JSON.stringify(data)); } } try { appManager.getForegroundApplications(getForegroundApplicationsCallback); } catch (paramError) { - console.log("error: " + paramError.code + ", " + paramError.message); + console.log('error: ' + paramError.code + ', ' + paramError.message); } ``` @@ -661,9 +661,9 @@ getForegroundApplications(): Promise\>; import appManager from '@ohos.app.ability.appManager'; appManager.getForegroundApplications().then((data) => { - console.log("getForegroundApplications success, data: " + JSON.stringify(data)); + console.log('getForegroundApplications success, data: ' + JSON.stringify(data)); }).catch((err) => { - console.log("getForegroundApplications fail, err: " + JSON.stringify(err)); + console.log('getForegroundApplications fail, err: ' + JSON.stringify(err)); }) ``` @@ -703,12 +703,12 @@ let bundleName = 'bundleName'; let accountId = 0; try { appManager.killProcessWithAccount(bundleName, accountId).then(() => { - console.log("killProcessWithAccount success"); + console.log('killProcessWithAccount success'); }).catch((err) => { - console.log("killProcessWithAccount fail, err: " + JSON.stringify(err)); + console.error('killProcessWithAccount fail, err: ' + JSON.stringify(err)); }) } catch (paramError) { - console.log("error: " + paramError.code + ", " + paramError.message); + console.error('error: ' + paramError.code + ', ' + paramError.message); } ``` @@ -750,9 +750,9 @@ let bundleName = 'bundleName'; let accountId = 0; function killProcessWithAccountCallback(err, data) { if (err.code !== 0) { - console.log("killProcessWithAccountCallback fail, err: " + JSON.stringify(err)); + console.log('killProcessWithAccountCallback fail, err: ' + JSON.stringify(err)); } else { - console.log("killProcessWithAccountCallback success."); + console.log('killProcessWithAccountCallback success.'); } } appManager.killProcessWithAccount(bundleName, accountId, killProcessWithAccountCallback); @@ -793,15 +793,15 @@ import appManager from '@ohos.app.ability.appManager'; let bundleName = 'bundleName'; function killProcessesByBundleNameCallback(err, data) { if (err.code !== 0) { - console.log("killProcessesByBundleNameCallback fail, err: " + JSON.stringify(err)); + console.log('killProcessesByBundleNameCallback fail, err: ' + JSON.stringify(err)); } else { - console.log("killProcessesByBundleNameCallback success."); + console.log('killProcessesByBundleNameCallback success.'); } } try { appManager.killProcessesByBundleName(bundleName, killProcessesByBundleNameCallback); } catch (paramError) { - console.log("error: " + paramError.code + ", " + paramError.message); + console.log('error: ' + paramError.code + ', ' + paramError.message); } ``` @@ -845,12 +845,12 @@ import appManager from '@ohos.app.ability.appManager'; let bundleName = 'bundleName'; try { appManager.killProcessesByBundleName(bundleName).then((data) => { - console.log("killProcessesByBundleName success."); + console.log('killProcessesByBundleName success.'); }).catch((err) => { - console.log("killProcessesByBundleName fail, err: " + JSON.stringify(err)); + console.log('killProcessesByBundleName fail, err: ' + JSON.stringify(err)); }) } catch (paramError) { - console.log("error: " + paramError.code + ", " + paramError.message); + console.log('error: ' + paramError.code + ', ' + paramError.message); } ``` @@ -889,15 +889,15 @@ import appManager from '@ohos.app.ability.appManager'; let bundleName = 'bundleName'; function clearUpApplicationDataCallback(err, data) { if (err) { - console.log("clearUpApplicationDataCallback fail, err: " + JSON.stringify(err)); + console.log('clearUpApplicationDataCallback fail, err: ' + JSON.stringify(err)); } else { - console.log("clearUpApplicationDataCallback success."); + console.log('clearUpApplicationDataCallback success.'); } } try { appManager.clearUpApplicationData(bundleName, clearUpApplicationDataCallback); } catch (paramError) { - console.log("error: " + paramError.code + ", " + paramError.message); + console.log('error: ' + paramError.code + ', ' + paramError.message); } ``` @@ -941,12 +941,12 @@ import appManager from '@ohos.app.ability.appManager'; let bundleName = 'bundleName'; try { appManager.clearUpApplicationData(bundleName).then((data) => { - console.log("clearUpApplicationData success."); + console.log('clearUpApplicationData success.'); }).catch((err) => { - console.log("clearUpApplicationData fail, err: " + JSON.stringify(err)); + console.log('clearUpApplicationData fail, err: ' + JSON.stringify(err)); }) } catch (paramError) { - console.log("error: " + paramError.code + ", " + paramError.message); + console.log('error: ' + paramError.code + ', ' + paramError.message); } ``` diff --git a/zh-cn/application-dev/reference/apis/js-apis-app-ability-appRecovery.md b/zh-cn/application-dev/reference/apis/js-apis-app-ability-appRecovery.md index 72c8116699a3130bdb0fe7bd1045e2f14ef50955..9ee4f92ebd41a686747f49a44f235f7db4a283fe 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-app-ability-appRecovery.md +++ b/zh-cn/application-dev/reference/apis/js-apis-app-ability-appRecovery.md @@ -99,15 +99,15 @@ import errorManager from '@ohos.app.ability.errorManager'; let observer = { onUnhandledException(errorMsg) { - console.log('onUnhandledException, errorMsg: ', errorMsg) + console.log('onUnhandledException, errorMsg: ', errorMsg); appRecovery.restartApp(); } }; try { - errorManager.on("error", observer); + errorManager.on('error', observer); } catch (paramError) { - console.log("error: " + paramError.code + ", " + paramError.message); + console.log('error: ' + paramError.code + ', ' + paramError.message); } ``` @@ -133,14 +133,14 @@ import errorManager from '@ohos.app.ability.errorManager'; let observer = { onUnhandledException(errorMsg) { - console.log('onUnhandledException, errorMsg: ', errorMsg) + console.log('onUnhandledException, errorMsg: ', errorMsg); appRecovery.saveAppState(); } }; try { - errorManager.on("error", observer); + errorManager.on('error', observer); } catch (paramError) { - console.log("error: " + paramError.code + ", " + paramError.message); + console.log('error: ' + paramError.code + ', ' + paramError.message); } ``` diff --git a/zh-cn/application-dev/reference/apis/js-apis-app-ability-common.md b/zh-cn/application-dev/reference/apis/js-apis-app-ability-common.md index f148dca1d6c61519ce2b3224f4a72e9a252b63be..a051e73d34fac74b9b8a40a3ae2ec06bf6cb3275 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-app-ability-common.md +++ b/zh-cn/application-dev/reference/apis/js-apis-app-ability-common.md @@ -10,7 +10,7 @@ Common模块将二级模块API组织在一起方便开发者进行导出。 ## 导入模块 ```ts -import common from '@ohos.app.ability.common' +import common from '@ohos.app.ability.common'; ``` **系统能力**:以下各项对应的系统能力均为SystemCapability.Ability.AbilityBase @@ -33,7 +33,7 @@ import common from '@ohos.app.ability.common' **示例:** ```ts -import common from '@ohos.app.ability.common' +import common from '@ohos.app.ability.common'; let uiAbilityContext: common.UIAbilityContext; let abilityStageContext: common.AbilityStageContext; diff --git a/zh-cn/application-dev/reference/apis/js-apis-app-ability-configuration.md b/zh-cn/application-dev/reference/apis/js-apis-app-ability-configuration.md index 240d075b5cc339c0ef242b3a8401fadcf167f797..6b46b05282b050346a2f7386af702cefec17cb05 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-app-ability-configuration.md +++ b/zh-cn/application-dev/reference/apis/js-apis-app-ability-configuration.md @@ -39,10 +39,10 @@ }; try { let applicationContext = this.context.getApplicationContext(); - let callbackId = applicationContext.on("environment", envCallback); - console.log("callbackId: " + callbackId); + let callbackId = applicationContext.on('environment', envCallback); + console.log('callbackId: ' + callbackId); } catch (paramError) { - console.log("error: " + paramError.code + ", " + paramError.message); + console.log('error: ' + paramError.code + ', ' + paramError.message); } } } diff --git a/zh-cn/application-dev/reference/apis/js-apis-app-ability-configurationConstant.md b/zh-cn/application-dev/reference/apis/js-apis-app-ability-configurationConstant.md index 772ae7727a94e5192b970785b28c9ebf5ae33d38..b9d69888dd49c2251857dfc922a34feacd31270f 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-app-ability-configurationConstant.md +++ b/zh-cn/application-dev/reference/apis/js-apis-app-ability-configurationConstant.md @@ -47,9 +47,9 @@ import ConfigurationConstant from '@ohos.app.ability.ConfigurationConstant'; | 名称 | 值 | 说明 | | -------- | -------- | -------- | | SCREEN_DENSITY_NOT_SET | 0 | 未设置屏幕分辨率。 | -| SCREEN_DENSITY_SDPI | 120 | 屏幕分辨率为"sdpi"。 | -| SCREEN_DENSITY_MDPI | 160 | 屏幕分辨率为"mdpi"。 | -| SCREEN_DENSITY_LDPI | 240 | 屏幕分辨率为"ldpi"。 | -| SCREEN_DENSITY_XLDPI | 320 | 屏幕分辨率为"xldpi"。 | -| SCREEN_DENSITY_XXLDPI | 480 | 屏幕分辨率为"xxldpi"。 | -| SCREEN_DENSITY_XXXLDPI | 640 | 屏幕分辨率为"xxxldpi"。 | +| SCREEN_DENSITY_SDPI | 120 | 屏幕分辨率为'sdpi'。 | +| SCREEN_DENSITY_MDPI | 160 | 屏幕分辨率为'mdpi'。 | +| SCREEN_DENSITY_LDPI | 240 | 屏幕分辨率为'ldpi'。 | +| SCREEN_DENSITY_XLDPI | 320 | 屏幕分辨率为'xldpi'。 | +| SCREEN_DENSITY_XXLDPI | 480 | 屏幕分辨率为'xxldpi'。 | +| SCREEN_DENSITY_XXXLDPI | 640 | 屏幕分辨率为'xxxldpi'。 | diff --git a/zh-cn/application-dev/reference/apis/js-apis-app-ability-environmentCallback.md b/zh-cn/application-dev/reference/apis/js-apis-app-ability-environmentCallback.md index 047bbb974f205611b317f4af60e27d96647dd5d4..795d7a6e5c392912d5a29f8e68772f323a8db9f7 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-app-ability-environmentCallback.md +++ b/zh-cn/application-dev/reference/apis/js-apis-app-ability-environmentCallback.md @@ -11,7 +11,7 @@ EnvironmentCallback模块提供应用上下文ApplicationContext对系统环境 ## 导入模块 ```ts -import EnvironmentCallback from "@ohos.app.ability.EnvironmentCallback"; +import EnvironmentCallback from '@ohos.app.ability.EnvironmentCallback'; ``` @@ -33,29 +33,29 @@ onConfigurationUpdated(config: Configuration): void; ```ts -import Ability from "@ohos.application.Ability"; +import Ability from '@ohos.application.Ability'; let callbackId; export default class MyAbility extends Ability { onCreate() { - console.log("MyAbility onCreate") + console.log('MyAbility onCreate') globalThis.applicationContext = this.context.getApplicationContext(); let EnvironmentCallback = { onConfigurationUpdated(config){ - console.log("onConfigurationUpdated config:" + JSON.stringify(config)); + console.log('onConfigurationUpdated config:' + JSON.stringify(config)); }, } // 1.获取applicationContext let applicationContext = globalThis.applicationContext; // 2.通过applicationContext注册监听应用内生命周期 callbackId = applicationContext.registerEnvironmentCallback(EnvironmentCallback); - console.log("registerEnvironmentCallback number: " + JSON.stringify(callbackId)); + console.log('registerEnvironmentCallback number: ' + JSON.stringify(callbackId)); } onDestroy() { let applicationContext = globalThis.applicationContext; applicationContext.unregisterEnvironmentCallback(callbackId, (error, data) => { - console.log("unregisterEnvironmentCallback success, err: " + JSON.stringify(error)); + console.log('unregisterEnvironmentCallback success, err: ' + JSON.stringify(error)); }); } } diff --git a/zh-cn/application-dev/reference/apis/js-apis-app-ability-errorManager.md b/zh-cn/application-dev/reference/apis/js-apis-app-ability-errorManager.md index 747f5901d306b6157976639d6d5dc5d29b715b49..428542aee3b5f66d0578ed32d27b8798e81cde0a 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-app-ability-errorManager.md +++ b/zh-cn/application-dev/reference/apis/js-apis-app-ability-errorManager.md @@ -13,7 +13,7 @@ import errorManager from '@ohos.app.ability.errorManager' ## ErrorManager.on -on(type: "error", observer: ErrorObserver): number; +on(type: 'error', observer: ErrorObserver): number; 注册错误观测器。 @@ -35,15 +35,15 @@ let observer = { } } try { - errorManager.on("error", observer); + errorManager.on('error', observer); } catch (paramError) { - console.log("error: " + paramError.code + ", " + paramError.message); + console.log('error: ' + paramError.code + ', ' + paramError.message); } ``` ## ErrorManager.off -off(type: "error", observerId: number, callback: AsyncCallback\): void; +off(type: 'error', observerId: number, callback: AsyncCallback\): void; 注销错误观测器。 @@ -68,15 +68,15 @@ function unregisterErrorObserverCallback(err) { } } try { - errorManager.off("error", observerId, unregisterErrorObserverCallback); + errorManager.off('error', observerId, unregisterErrorObserverCallback); } catch (paramError) { - console.log("error: " + paramError.code + ", " + paramError.message); + console.log('error: ' + paramError.code + ', ' + paramError.message); } ``` ## ErrorManager.off -off(type: "error", observerId: number): Promise\; +off(type: 'error', observerId: number): Promise\; 注销错误观测器。 @@ -100,7 +100,7 @@ off(type: "error", observerId: number): Promise\; ```js let observerId = 100; try { - errorManager.off("error", observerId) + errorManager.off('error', observerId) .then((data) => { console.log('----------- unregisterErrorObserver success ----------', data); }) @@ -108,7 +108,7 @@ try { console.log('----------- unregisterErrorObserver fail ----------', err); }) } catch (paramError) { - console.log("error: " + paramError.code + ", " + paramError.message); + console.log('error: ' + paramError.code + ', ' + paramError.message); } ``` diff --git a/zh-cn/application-dev/reference/apis/js-apis-app-ability-missionManager.md b/zh-cn/application-dev/reference/apis/js-apis-app-ability-missionManager.md index 030e37ff8c1e33875c5766561171ae9a025c5567..2fc90276654d557447b8867f4a62b2c1f62e9790 100755 --- a/zh-cn/application-dev/reference/apis/js-apis-app-ability-missionManager.md +++ b/zh-cn/application-dev/reference/apis/js-apis-app-ability-missionManager.md @@ -18,7 +18,7 @@ ohos.permission.MANAGE_MISSIONS ## missionManager.on -on(type:"mission", listener: MissionListener): number; +on(type:'mission', listener: MissionListener): number; 注册系统任务状态监听。 @@ -44,25 +44,25 @@ on(type:"mission", listener: MissionListener): number; ```ts let listener = { - onMissionCreated: function (mission) {console.log("--------onMissionCreated-------")}, - onMissionDestroyed: function (mission) {console.log("--------onMissionDestroyed-------")}, - onMissionSnapshotChanged: function (mission) {console.log("--------onMissionSnapshotChanged-------")}, - onMissionMovedToFront: function (mission) {console.log("--------onMissionMovedToFront-------")}, - onMissionIconUpdated: function (mission, icon) {console.log("--------onMissionIconUpdated-------")}, - onMissionClosed: function (mission) {console.log("--------onMissionClosed-------")} + onMissionCreated: function (mission) {console.log('--------onMissionCreated-------');}, + onMissionDestroyed: function (mission) {console.log('--------onMissionDestroyed-------');}, + onMissionSnapshotChanged: function (mission) {console.log('--------onMissionSnapshotChanged-------');}, + onMissionMovedToFront: function (mission) {console.log('--------onMissionMovedToFront-------');}, + onMissionIconUpdated: function (mission, icon) {console.log('--------onMissionIconUpdated-------');}, + onMissionClosed: function (mission) {console.log('--------onMissionClosed-------');} }; - console.log("registerMissionListener") + console.log('registerMissionListener') try { - let listenerid = missionManager.on("mission", listener); + let listenerid = missionManager.on('mission', listener); } catch (paramError) { - console.log("error: " + paramError.code + ", " + paramError.message); + console.log('error: ' + paramError.code + ', ' + paramError.message); } ``` ## missionManager.off -off(type: "mission", listenerId: number, callback: AsyncCallback<void>): void; +off(type: 'mission', listenerId: number, callback: AsyncCallback<void>): void; 取消任务状态监听。 @@ -83,29 +83,29 @@ off(type: "mission", listenerId: number, callback: AsyncCallback<void>): v ```ts let listener = { - onMissionCreated: function (mission) {console.log("--------onMissionCreated-------")}, - onMissionDestroyed: function (mission) {console.log("--------onMissionDestroyed-------")}, - onMissionSnapshotChanged: function (mission) {console.log("--------onMissionSnapshotChanged-------")}, - onMissionMovedToFront: function (mission) {console.log("--------onMissionMovedToFront-------")}, - onMissionIconUpdated: function (mission, icon) {console.log("--------onMissionIconUpdated-------")}, - onMissionClosed: function (mission) {console.log("--------onMissionClosed-------")} + onMissionCreated: function (mission) {console.log('--------onMissionCreated-------');}, + onMissionDestroyed: function (mission) {console.log('--------onMissionDestroyed-------');}, + onMissionSnapshotChanged: function (mission) {console.log('--------onMissionSnapshotChanged-------');}, + onMissionMovedToFront: function (mission) {console.log('--------onMissionMovedToFront-------');}, + onMissionIconUpdated: function (mission, icon) {console.log('--------onMissionIconUpdated-------');}, + onMissionClosed: function (mission) {console.log('--------onMissionClosed-------');} }; - console.log("registerMissionListener") + console.log('registerMissionListener') try { let listenerid = missionManager.registerMissionListener(listener); missionManager.unregisterMissionListener(listenerid, (error) => { - console.log("unregisterMissionListener"); + console.log('unregisterMissionListener'); }) } catch (paramError) { - console.log("error: " + paramError.code + ", " + paramError.message); + console.log('error: ' + paramError.code + ', ' + paramError.message); } ``` ## missionManager.off -off(type: "mission", listenerId: number): Promise<void>; +off(type: 'mission', listenerId: number): Promise<void>; 取消任务状态监听,以promise方式返回执行结果。 @@ -131,14 +131,14 @@ off(type: "mission", listenerId: number): Promise<void>; ```ts let listener = { - onMissionCreated: function (mission) {console.log("--------onMissionCreated-------")}, - onMissionDestroyed: function (mission) {console.log("--------onMissionDestroyed-------")}, - onMissionSnapshotChanged: function (mission) {console.log("--------onMissionSnapshotChanged-------")}, - onMissionMovedToFront: function (mission) {console.log("--------onMissionMovedToFront-------")}, - onMissionIconUpdated: function (mission, icon) {console.log("--------onMissionIconUpdated-------")}, - onMissionClosed: function (mission) {console.log("--------onMissionClosed-------")} + onMissionCreated: function (mission) {console.log('--------onMissionCreated-------');}, + onMissionDestroyed: function (mission) {console.log('--------onMissionDestroyed-------');}, + onMissionSnapshotChanged: function (mission) {console.log('--------onMissionSnapshotChanged-------');}, + onMissionMovedToFront: function (mission) {console.log('--------onMissionMovedToFront-------');}, + onMissionIconUpdated: function (mission, icon) {console.log('--------onMissionIconUpdated-------');}, + onMissionClosed: function (mission) {console.log('--------onMissionClosed-------');} }; - console.log("registerMissionListener") + console.log('registerMissionListener') try { let listenerid = missionManager.registerMissionListener(listener); @@ -146,7 +146,7 @@ off(type: "mission", listenerId: number): Promise<void>; console.log(err); }); } catch (paramError) { - console.log("error: " + paramError.code + ", " + paramError.message); + console.log('error: ' + paramError.code + ', ' + paramError.message); } ``` @@ -177,18 +177,18 @@ getMissionInfo(deviceId: string, missionId: number, callback: AsyncCallback<M import missionManager from '@ohos.app.ability.missionManager' try { - let allMissions=missionManager.getMissionInfos("",10).catch(function(err){console.log(err);}); - missionManager.getMissionInfo("", allMissions[0].missionId, (error, mission) => { - console.log("getMissionInfo is called, error.code = " + error.code) - console.log("mission.missionId = " + mission.missionId); - console.log("mission.runningState = " + mission.runningState); - console.log("mission.lockedState = " + mission.lockedState); - console.log("mission.timestamp = " + mission.timestamp); - console.log("mission.label = " + mission.label); - console.log("mission.iconPath = " + mission.iconPath); + let allMissions=missionManager.getMissionInfos('',10).catch(function(err){console.log(err);}); + missionManager.getMissionInfo('', allMissions[0].missionId, (error, mission) => { + console.log('getMissionInfo is called, error.code = ' + error.code); + console.log('mission.missionId = ' + mission.missionId); + console.log('mission.runningState = ' + mission.runningState); + console.log('mission.lockedState = ' + mission.lockedState); + console.log('mission.timestamp = ' + mission.timestamp); + console.log('mission.label = ' + mission.label); + console.log('mission.iconPath = ' + mission.iconPath); }); } catch (paramError) { - console.log("error: " + paramError.code + ", " + paramError.message); + console.log('error: ' + paramError.code + ', ' + paramError.message); } ``` @@ -224,11 +224,11 @@ getMissionInfo(deviceId: string, missionId: number): Promise<MissionInfo>; import missionManager from '@ohos.app.ability.missionManager' try { - let mission = missionManager.getMissionInfo("", 10).catch(function (err){ + let mission = missionManager.getMissionInfo('', 10).catch(function (err){ console.log(err); }); } catch (paramError) { - console.log("error: " + paramError.code + ", " + paramError.message); + console.log('error: ' + paramError.code + ', ' + paramError.message); } ``` @@ -259,13 +259,13 @@ getMissionInfos(deviceId: string, numMax: number, callback: AsyncCallback<Arr import missionManager from '@ohos.app.ability.missionManager' try { - missionManager.getMissionInfos("", 10, (error, missions) => { - console.log("getMissionInfos is called, error.code = " + error.code); - console.log("size = " + missions.length); - console.log("missions = " + JSON.stringify(missions)); + missionManager.getMissionInfos('', 10, (error, missions) => { + console.log('getMissionInfos is called, error.code = ' + error.code); + console.log('size = ' + missions.length); + console.log('missions = ' + JSON.stringify(missions)); }) } catch (paramError) { - console.log("error: " + paramError.code + ", " + paramError.message); + console.log('error: ' + paramError.code + ', ' + paramError.message); } ``` @@ -301,11 +301,11 @@ getMissionInfos(deviceId: string, numMax: number): Promise<Array<MissionIn import missionManager from '@ohos.app.ability.missionManager' try { - let allMissions = missionManager.getMissionInfos("", 10).catch(function (err){ + let allMissions = missionManager.getMissionInfos('', 10).catch(function (err){ console.log(err); }); } catch (paramError) { - console.log("error: " + paramError.code + ", " + paramError.message); + console.log('error: ' + paramError.code + ', ' + paramError.message); } ``` @@ -336,19 +336,19 @@ getMissionSnapShot(deviceId: string, missionId: number, callback: AsyncCallback& import missionManager from '@ohos.app.ability.missionManager' try { - missionManager.getMissionInfos("", 10, (error, missions) => { - console.log("getMissionInfos is called, error.code = " + error.code); - console.log("size = " + missions.length); - console.log("missions = " + JSON.stringify(missions)); + missionManager.getMissionInfos('', 10, (error, missions) => { + console.log('getMissionInfos is called, error.code = ' + error.code); + console.log('size = ' + missions.length); + console.log('missions = ' + JSON.stringify(missions)); let id = missions[0].missionId; - missionManager.getMissionSnapShot("", id, (error, snapshot) => { - console.log("getMissionSnapShot is called, error.code = " + error.code); - console.log("bundleName = " + snapshot.ability.bundleName); + missionManager.getMissionSnapShot('', id, (error, snapshot) => { + console.log('getMissionSnapShot is called, error.code = ' + error.code); + console.log('bundleName = ' + snapshot.ability.bundleName); }) }) } catch (paramError) { - console.log("error: " + paramError.code + ", " + paramError.message); + console.log('error: ' + paramError.code + ', ' + paramError.message); } ``` @@ -381,22 +381,22 @@ getMissionSnapShot(deviceId: string, missionId: number): Promise<MissionSnaps **示例:** ```ts - import missionManager from '@ohos.app.ability.missionManager' + import missionManager from '@ohos.app.ability.missionManager'; try { let allMissions; - missionManager.getMissionInfos("",10).then(function(res){ + missionManager.getMissionInfos('',10).then(function(res){ allMissions=res; }).catch(function(err){console.log(err);}); - console.log("size = " + allMissions.length); - console.log("missions = " + JSON.stringify(allMissions)); + console.log('size = ' + allMissions.length); + console.log('missions = ' + JSON.stringify(allMissions)); let id = allMissions[0].missionId; - let snapshot = missionManager.getMissionSnapShot("", id).catch(function (err){ + let snapshot = missionManager.getMissionSnapShot('', id).catch(function (err){ console.log(err); }); } catch (paramError) { - console.log("error: " + paramError.code + ", " + paramError.message); + console.log('error: ' + paramError.code + ', ' + paramError.message); } ``` @@ -423,22 +423,22 @@ getLowResolutionMissionSnapShot(deviceId: string, missionId: number, callback: A **示例:** ```ts - import missionManager from '@ohos.app.ability.missionManager' + import missionManager from '@ohos.app.ability.missionManager'; try { - missionManager.getMissionInfos("", 10, (error, missions) => { - console.log("getMissionInfos is called, error.code = " + error.code); - console.log("size = " + missions.length); - console.log("missions = " + JSON.stringify(missions)); + missionManager.getMissionInfos('', 10, (error, missions) => { + console.log('getMissionInfos is called, error.code = ' + error.code); + console.log('size = ' + missions.length); + console.log('missions = ' + JSON.stringify(missions)); let id = missions[0].missionId; - missionManager.getLowResolutionMissionSnapShot("", id, (error, snapshot) => { - console.log("getLowResolutionMissionSnapShot is called, error.code = " + error.code); - console.log("bundleName = " + snapshot.ability.bundleName); + missionManager.getLowResolutionMissionSnapShot('', id, (error, snapshot) => { + console.log('getLowResolutionMissionSnapShot is called, error.code = ' + error.code); + console.log('bundleName = ' + snapshot.ability.bundleName); }) }) } catch (paramError) { - console.log("error: " + paramError.code + ", " + paramError.message); + console.log('error: ' + paramError.code + ', ' + paramError.message); } ``` @@ -471,22 +471,22 @@ getLowResolutionMissionSnapShot(deviceId: string, missionId: number): Promise\ { - console.log("getMissionInfos is called, error.code = " + error.code); - console.log("size = " + missions.length); - console.log("missions = " + JSON.stringify(missions)); + missionManager.getMissionInfos('', 10, (error, missions) => { + console.log('getMissionInfos is called, error.code = ' + error.code); + console.log('size = ' + missions.length); + console.log('missions = ' + JSON.stringify(missions)); let id = missions[0].missionId; missionManager.lockMission(id).then(() => { - console.log("lockMission is called "); + console.log('lockMission is called '); }); }); } catch (paramError) { - console.log("error: " + paramError.code + ", " + paramError.message); + console.log('error: ' + paramError.code + ', ' + paramError.message); } ``` @@ -559,22 +559,22 @@ lockMission(missionId: number): Promise<void>; **示例:** ```ts - import missionManager from '@ohos.app.ability.missionManager' + import missionManager from '@ohos.app.ability.missionManager'; try { let allMissions; - missionManager.getMissionInfos("",10).then(function(res){ + missionManager.getMissionInfos('',10).then(function(res){ allMissions=res; }).catch(function(err){console.log(err);}); - console.log("size = " + allMissions.length); - console.log("missions = " + JSON.stringify(allMissions)); + console.log('size = ' + allMissions.length); + console.log('missions = ' + JSON.stringify(allMissions)); let id = allMissions[0].missionId; missionManager.lockMission(id).catch(function (err){ console.log(err); }); } catch (paramError) { - console.log("error: " + paramError.code + ", " + paramError.message); + console.log('error: ' + paramError.code + ', ' + paramError.message); } ``` @@ -601,21 +601,21 @@ unlockMission(missionId: number, callback: AsyncCallback<void>): void; **示例:** ```ts - import missionManager from '@ohos.app.ability.missionManager' + import missionManager from '@ohos.app.ability.missionManager'; try { - missionManager.getMissionInfos("", 10, (error, missions) => { - console.log("getMissionInfos is called, error.code = " + error.code); - console.log("size = " + missions.length); - console.log("missions = " + JSON.stringify(missions)); + missionManager.getMissionInfos('', 10, (error, missions) => { + console.log('getMissionInfos is called, error.code = ' + error.code); + console.log('size = ' + missions.length); + console.log('missions = ' + JSON.stringify(missions)); let id = missions[0].missionId; missionManager.unlockMission(id).then(() => { - console.log("unlockMission is called "); + console.log('unlockMission is called '); }); }); } catch (paramError) { - console.log("error: " + paramError.code + ", " + paramError.message); + console.log('error: ' + paramError.code + ', ' + paramError.message); } ``` @@ -647,15 +647,15 @@ unlockMission(missionId: number): Promise<void>; **示例:** ```ts - import missionManager from '@ohos.app.ability.missionManager' + import missionManager from '@ohos.app.ability.missionManager'; try { let allMissions; - missionManager.getMissionInfos("",10).then(function(res){ + missionManager.getMissionInfos('',10).then(function(res){ allMissions=res; }).catch(function(err){console.log(err);}); - console.log("size = " + allMissions.length); - console.log("missions = " + JSON.stringify(allMissions)); + console.log('size = ' + allMissions.length); + console.log('missions = ' + JSON.stringify(allMissions)); let id = allMissions[0].missionId; missionManager.lockMission(id).catch(function (err){ @@ -665,7 +665,7 @@ unlockMission(missionId: number): Promise<void>; console.log(err); }); } catch (paramError) { - console.log("error: " + paramError.code + ", " + paramError.message); + console.log('error: ' + paramError.code + ', ' + paramError.message); } ``` @@ -692,21 +692,21 @@ clearMission(missionId: number, callback: AsyncCallback<void>): void; **示例:** ```ts - import missionManager from '@ohos.app.ability.missionManager' + import missionManager from '@ohos.app.ability.missionManager'; try { - missionManager.getMissionInfos("", 10, (error, missions) => { - console.log("getMissionInfos is called, error.code = " + error.code); - console.log("size = " + missions.length); - console.log("missions = " + JSON.stringify(missions)); + missionManager.getMissionInfos('', 10, (error, missions) => { + console.log('getMissionInfos is called, error.code = ' + error.code); + console.log('size = ' + missions.length); + console.log('missions = ' + JSON.stringify(missions)); let id = missions[0].missionId; missionManager.clearMission(id).then(() => { - console.log("clearMission is called "); + console.log('clearMission is called '); }); }); } catch (paramError) { - console.log("error: " + paramError.code + ", " + paramError.message); + console.log('error: ' + paramError.code + ', ' + paramError.message); } ``` @@ -738,22 +738,22 @@ clearMission(missionId: number): Promise<void>; **示例:** ```ts - import missionManager from '@ohos.app.ability.missionManager' + import missionManager from '@ohos.app.ability.missionManager'; try { let allMissions; - missionManager.getMissionInfos("",10).then(function(res){ + missionManager.getMissionInfos('',10).then(function(res){ allMissions=res; }).catch(function(err){console.log(err);}); - console.log("size = " + allMissions.length); - console.log("missions = " + JSON.stringify(allMissions)); + console.log('size = ' + allMissions.length); + console.log('missions = ' + JSON.stringify(allMissions)); let id = allMissions[0].missionId; missionManager.clearMission(id).catch(function (err){ console.log(err); }); } catch (paramError) { - console.log("error: " + paramError.code + ", " + paramError.message); + console.log('error: ' + paramError.code + ', ' + paramError.message); } ``` @@ -773,10 +773,10 @@ clearAllMissions(callback: AsyncCallback<void>): void; **示例:** ```ts - import missionManager from '@ohos.app.ability.missionManager' + import missionManager from '@ohos.app.ability.missionManager'; missionManager.clearAllMissions().then(() => { - console.log("clearAllMissions is called "); + console.log('clearAllMissions is called '); }); ``` @@ -802,7 +802,7 @@ clearAllMissions(): Promise<void>; **示例:** ```ts - import missionManager from '@ohos.app.ability.missionManager' + import missionManager from '@ohos.app.ability.missionManager'; missionManager.clearAllMissions().catch(function (err){ console.log(err); }); @@ -831,21 +831,21 @@ moveMissionToFront(missionId: number, callback: AsyncCallback<void>): void **示例:** ```ts - import missionManager from '@ohos.app.ability.missionManager' + import missionManager from '@ohos.app.ability.missionManager'; try { - missionManager.getMissionInfos("", 10, (error, missions) => { - console.log("getMissionInfos is called, error.code = " + error.code); - console.log("size = " + missions.length); - console.log("missions = " + JSON.stringify(missions)); + missionManager.getMissionInfos('', 10, (error, missions) => { + console.log('getMissionInfos is called, error.code = ' + error.code); + console.log('size = ' + missions.length); + console.log('missions = ' + JSON.stringify(missions)); let id = missions[0].missionId; missionManager.moveMissionToFront(id).then(() => { - console.log("moveMissionToFront is called "); + console.log('moveMissionToFront is called '); }); }); } catch (paramError) { - console.log("error: " + paramError.code + ", " + paramError.message); + console.log('error: ' + paramError.code + ', ' + paramError.message); } ``` @@ -873,21 +873,21 @@ moveMissionToFront(missionId: number, options: StartOptions, callback: AsyncCall **示例:** ```ts - import missionManager from '@ohos.app.ability.missionManager' + import missionManager from '@ohos.app.ability.missionManager'; try { - missionManager.getMissionInfos("", 10, (error, missions) => { - console.log("getMissionInfos is called, error.code = " + error.code); - console.log("size = " + missions.length); - console.log("missions = " + JSON.stringify(missions)); + missionManager.getMissionInfos('', 10, (error, missions) => { + console.log('getMissionInfos is called, error.code = ' + error.code); + console.log('size = ' + missions.length); + console.log('missions = ' + JSON.stringify(missions)); let id = missions[0].missionId; missionManager.moveMissionToFront(id,{windowMode : 101}).then(() => { - console.log("moveMissionToFront is called "); + console.log('moveMissionToFront is called '); }); }); } catch (paramError) { - console.log("error: " + paramError.code + ", " + paramError.message); + console.log('error: ' + paramError.code + ', ' + paramError.message); } ``` @@ -920,21 +920,21 @@ moveMissionToFront(missionId: number, options?: StartOptions): Promise<void&g **示例:** ```ts - import missionManager from '@ohos.app.ability.missionManager' + import missionManager from '@ohos.app.ability.missionManager'; try { let allMissions; - missionManager.getMissionInfos("",10).then(function(res){ + missionManager.getMissionInfos('',10).then(function(res){ allMissions=res; }).catch(function(err){console.log(err);}); - console.log("size = " + allMissions.length); - console.log("missions = " + JSON.stringify(allMissions)); + console.log('size = ' + allMissions.length); + console.log('missions = ' + JSON.stringify(allMissions)); let id = allMissions[0].missionId; missionManager.moveMissionToFront(id).catch(function (err){ console.log(err); }); } catch (paramError) { - console.log("error: " + paramError.code + ", " + paramError.message); + console.log('error: ' + paramError.code + ', ' + paramError.message); } ``` diff --git a/zh-cn/application-dev/reference/apis/js-apis-app-ability-quickFixManager.md b/zh-cn/application-dev/reference/apis/js-apis-app-ability-quickFixManager.md index 7800555679d6e4708229cbfe0ca715dc9ee56ca3..e591625968c624a21693064438e5cd38d68416cb 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-app-ability-quickFixManager.md +++ b/zh-cn/application-dev/reference/apis/js-apis-app-ability-quickFixManager.md @@ -67,19 +67,19 @@ applyQuickFix(hapModuleQuickFixFiles: Array\, callback: AsyncCallback\ { if (error) { - console.info( `applyQuickFix failed with error + ${error}`) + console.info( `applyQuickFix failed with error + ${error}`); } else { - console.info( 'applyQuickFix success') + console.info( 'applyQuickFix success'); } }) } catch (paramError) { - console.log("error: " + paramError.code + ", " + paramError.message); + console.log('error: ' + paramError.code + ', ' + paramError.message); } ``` @@ -110,17 +110,17 @@ applyQuickFix(hapModuleQuickFixFiles: Array\): Promise\; **示例:** ```ts - import quickFixManager from '@ohos.app.ability.quickFixManager' + import quickFixManager from '@ohos.app.ability.quickFixManager'; - let hapModuleQuickFixFiles = ["/data/storage/el2/base/entry.hqf"] + let hapModuleQuickFixFiles = ['/data/storage/el2/base/entry.hqf']; try { quickFixManager.applyQuickFix(hapModuleQuickFixFiles).then(() => { - console.info('applyQuickFix success') + console.info('applyQuickFix success'); }).catch((error) => { - console.info(`applyQuickFix err: + ${error}`) + console.info(`applyQuickFix err: + ${error}`); }) } catch (paramError) { - console.log("error: " + paramError.code + ", " + paramError.message); + console.log('error: ' + paramError.code + ', ' + paramError.message); } ``` @@ -146,19 +146,19 @@ getApplicationQuickFixInfo(bundleName: string, callback: AsyncCallback\ { if (error) { - console.info(`getApplicationQuickFixInfo error: + ${error}`) + console.info(`getApplicationQuickFixInfo error: + ${error}`); } else { - console.info(`getApplicationQuickFixInfo success: + ${data}`) + console.info(`getApplicationQuickFixInfo success: + ${data}`); } }) } catch (paramError) { - console.log("error: " + paramError.code + ", " + paramError.message); + console.log('error: ' + paramError.code + ', ' + paramError.message); } ``` @@ -189,16 +189,16 @@ getApplicationQuickFixInfo(bundleName: string): Promise\ { - console.info(`getApplicationQuickFixInfo success: + ${data}`) + console.info(`getApplicationQuickFixInfo success: + ${data}`); }).catch((error) => { - console.info(`getApplicationQuickFixInfo err: + ${error}`) + console.info(`getApplicationQuickFixInfo err: + ${error}`); }) } catch (paramError) { - console.log("error: " + paramError.code + ", " + paramError.message); + console.log('error: ' + paramError.code + ', ' + paramError.message); } ``` diff --git a/zh-cn/application-dev/reference/apis/js-apis-app-ability-serviceExtensionAbility.md b/zh-cn/application-dev/reference/apis/js-apis-app-ability-serviceExtensionAbility.md index 2f5ef57a128cf21539b5d4c18a3e78fc85ea155f..ddda0b602d0f544c5c43047cfa4da9cefe01d161 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-app-ability-serviceExtensionAbility.md +++ b/zh-cn/application-dev/reference/apis/js-apis-app-ability-serviceExtensionAbility.md @@ -129,7 +129,7 @@ Extension生命周期回调,如果是connectAbility拉起的服务,会在onC **示例:** ```ts - import rpc from '@ohos.rpc' + import rpc from '@ohos.rpc'; class StubTest extends rpc.RemoteObject{ constructor(des) { super(des); @@ -140,7 +140,7 @@ Extension生命周期回调,如果是connectAbility拉起的服务,会在onC class ServiceExt extends ServiceExtension { onConnect(want) { console.log('onConnect , want:' + want.abilityName); - return new StubTest("test"); + return new StubTest('test'); } } ``` @@ -246,7 +246,7 @@ onDump(params: Array\): Array\; class ServiceExt extends ServiceExtension { onDump(params) { console.log('dump, params:' + JSON.stringify(params)); - return ["params"] + return ['params']; } } ``` diff --git a/zh-cn/application-dev/reference/apis/js-apis-app-ability-startOptions.md b/zh-cn/application-dev/reference/apis/js-apis-app-ability-startOptions.md index 75be4ed54cd66d8704a3e904c616994c0803e778..363e3453f874c59f99db7c0af1bf58f04f4cb36a 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-app-ability-startOptions.md +++ b/zh-cn/application-dev/reference/apis/js-apis-app-ability-startOptions.md @@ -29,14 +29,14 @@ import StartOptions from '@ohos.app.ability.StartOptions'; import missionManager from '@ohos.app.ability.missionManager'; try { - missionManager.getMissionInfos("", 10, (error, missions) => { + missionManager.getMissionInfos('', 10, (error, missions) => { if (error.code) { - console.log("getMissionInfos failed, error.code:" + JSON.stringify(error.code) + - "error.message:" + JSON.stringify(error.message)); + console.log('getMissionInfos failed, error.code:' + JSON.stringify(error.code) + + 'error.message:' + JSON.stringify(error.message)); return; } - console.log("size = " + missions.length); - console.log("missions = " + JSON.stringify(missions)); + console.log('size = ' + missions.length); + console.log('missions = ' + JSON.stringify(missions)); let id = missions[0].missionId; let startOptions = { @@ -44,10 +44,10 @@ import StartOptions from '@ohos.app.ability.StartOptions'; displayId: 0 }; missionManager.moveMissionToFront(id, startOptions).then(() => { - console.log("moveMissionToFront is called "); + console.log('moveMissionToFront is called '); }); }); } catch (paramError) { - console.log("error: " + paramError.code + ", " + paramError.message); + console.log('error: ' + paramError.code + ', ' + paramError.message); } ``` diff --git a/zh-cn/application-dev/reference/apis/js-apis-app-ability-uiAbility.md b/zh-cn/application-dev/reference/apis/js-apis-app-ability-uiAbility.md index 1a2866d05b592418dd2016e8f206ebeb77059533..367e94498822e7665b0bc583372475d581ce7077 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-app-ability-uiAbility.md +++ b/zh-cn/application-dev/reference/apis/js-apis-app-ability-uiAbility.md @@ -204,11 +204,11 @@ onContinue(wantParam : {[key: string]: any}): AbilityConstant.OnContinueResult; **示例:** ```ts - import AbilityConstant from "@ohos.app.ability.AbilityConstant" + import AbilityConstant from '@ohos.app.ability.AbilityConstant'; class MyUIAbility extends UIAbility { onContinue(wantParams) { console.log('onContinue'); - wantParams["myData"] = "my1234567"; + wantParams['myData'] = 'my1234567'; return AbilityConstant.OnContinueResult.AGREE; } } @@ -261,7 +261,7 @@ onDump(params: Array\): Array\; class myAbility extends Ability { onDump(params) { console.log('dump, params:' + JSON.stringify(params)); - return ["params"] + return ['params']; } } ``` @@ -291,12 +291,12 @@ onSaveState(reason: AbilityConstant.StateType, wantParam : {[key: string]: any}) **示例:** ```ts -import AbilityConstant from '@ohos.app.ability.AbilityConstant' +import AbilityConstant from '@ohos.app.ability.AbilityConstant'; class MyUIAbility extends UIAbility { onSaveState(reason, wantParam) { console.log('onSaveState'); - wantParam["myData"] = "my1234567"; + wantParam['myData'] = 'my1234567'; return AbilityConstant.OnSaveResult.RECOVERY_AGREE; } } @@ -341,8 +341,8 @@ call(method: string, data: rpc.Sequenceable): Promise<void>; ```ts import Ability from '@ohos.app.ability.UIAbility'; class MyMessageAble{ // 自定义的Sequenceable数据结构 - name:"" - str:"" + name:'' + str:'' num: 1 constructor(name, str) { this.name = name; @@ -366,12 +366,12 @@ call(method: string, data: rpc.Sequenceable): Promise<void>; export default class MainAbility extends Ability { onWindowStageCreate(windowStage) { this.context.startAbilityByCall({ - bundleName: "com.example.myservice", - abilityName: "MainAbility", - deviceId: "" + bundleName: 'com.example.myservice', + abilityName: 'MainAbility', + deviceId: '' }).then((obj) => { caller = obj; - let msg = new MyMessageAble("msg", "world"); // 参考Sequenceable数据定义 + let msg = new MyMessageAble('msg', 'world'); // 参考Sequenceable数据定义 caller.call(method, msg) .then(() => { console.log('Caller call() called'); @@ -422,8 +422,8 @@ callWithResult(method: string, data: rpc.Sequenceable): Promise<rpc.MessagePa ```ts import Ability from '@ohos.app.ability.UIAbility'; class MyMessageAble{ - name:"" - str:"" + name:'' + str:'' num: 1 constructor(name, str) { this.name = name; @@ -447,16 +447,16 @@ callWithResult(method: string, data: rpc.Sequenceable): Promise<rpc.MessagePa export default class MainAbility extends Ability { onWindowStageCreate(windowStage) { this.context.startAbilityByCall({ - bundleName: "com.example.myservice", - abilityName: "MainAbility", - deviceId: "" + bundleName: 'com.example.myservice', + abilityName: 'MainAbility', + deviceId: '' }).then((obj) => { caller = obj; - let msg = new MyMessageAble(1, "world"); + let msg = new MyMessageAble(1, 'world'); caller.callWithResult(method, msg) .then((data) => { console.log('Caller callWithResult() called'); - let retmsg = new MyMessageAble(0, ""); + let retmsg = new MyMessageAble(0, ''); data.readSequenceable(retmsg); }) .catch((callErr) => { @@ -497,9 +497,9 @@ release(): void; export default class MainAbility extends Ability { onWindowStageCreate(windowStage) { this.context.startAbilityByCall({ - bundleName: "com.example.myservice", - abilityName: "MainAbility", - deviceId: "" + bundleName: 'com.example.myservice', + abilityName: 'MainAbility', + deviceId: '' }).then((obj) => { caller = obj; try { @@ -538,9 +538,9 @@ release(): void; export default class MainAbility extends Ability { onWindowStageCreate(windowStage) { this.context.startAbilityByCall({ - bundleName: "com.example.myservice", - abilityName: "MainAbility", - deviceId: "" + bundleName: 'com.example.myservice', + abilityName: 'MainAbility', + deviceId: '' }).then((obj) => { caller = obj; try { @@ -561,7 +561,7 @@ release(): void; ## Caller.on - on(type: "release", callback: OnReleaseCallback): void; + on(type: 'release', callback: OnReleaseCallback): void; 注册通用组件服务端Stub(桩)断开监听通知。 @@ -589,13 +589,13 @@ release(): void; export default class MainAbility extends Ability { onWindowStageCreate(windowStage) { this.context.startAbilityByCall({ - bundleName: "com.example.myservice", - abilityName: "MainAbility", - deviceId: "" + bundleName: 'com.example.myservice', + abilityName: 'MainAbility', + deviceId: '' }).then((obj) => { caller = obj; try { - caller.on("release", (str) => { + caller.on('release', (str) => { console.log(' Caller OnRelease CallBack is called ' + str); }); } catch (error) { @@ -612,7 +612,7 @@ release(): void; ## Caller.off -off(type: "release", callback: OnReleaseCallback): void; +off(type: 'release', callback: OnReleaseCallback): void; 取消注册通用组件服务端Stub(桩)断开监听通知。预留能力,当前暂未支持。 @@ -639,17 +639,17 @@ off(type: "release", callback: OnReleaseCallback): void; export default class MainUIAbility extends UIAbility { onWindowStageCreate(windowStage) { this.context.startAbilityByCall({ - bundleName: "com.example.myservice", - abilityName: "MainUIAbility", - deviceId: "" + bundleName: 'com.example.myservice', + abilityName: 'MainUIAbility', + deviceId: '' }).then((obj) => { caller = obj; try { let onReleaseCallBack = (str) => { console.log(' Caller OnRelease CallBack is called ' + str); }; - caller.on("release", onReleaseCallBack); - caller.off("release", onReleaseCallBack); + caller.on('release', onReleaseCallBack); + caller.off('release', onReleaseCallBack); } catch (error) { console.log('Caller.on or Caller.off catch error, error.code: ' + JSON.stringify(error.code) + ' error.message: ' + JSON.stringify(error.message)); @@ -664,7 +664,7 @@ off(type: "release", callback: OnReleaseCallback): void; ## Caller.off -off(type: "release"): void; +off(type: 'release'): void; 取消注册通用组件服务端Stub(桩)断开监听通知。预留能力,当前暂未支持。 @@ -690,17 +690,17 @@ off(type: "release"): void; export default class MainUIAbility extends UIAbility { onWindowStageCreate(windowStage) { this.context.startAbilityByCall({ - bundleName: "com.example.myservice", - abilityName: "MainUIAbility", - deviceId: "" + bundleName: 'com.example.myservice', + abilityName: 'MainUIAbility', + deviceId: '' }).then((obj) => { caller = obj; try { let onReleaseCallBack = (str) => { console.log(' Caller OnRelease CallBack is called ' + str); }; - caller.on("release", onReleaseCallBack); - caller.off("release"); + caller.on('release', onReleaseCallBack); + caller.off('release'); } catch (error) { console.error('Caller.on or Caller.off catch error, error.code: ' + JSON.stringify(error.code) + ' error.message: ' + JSON.stringify(error.message)); @@ -744,8 +744,8 @@ on(method: string, callback: CalleeCallback): void; ```ts import Ability from '@ohos.app.ability.UIAbility'; class MyMessageAble{ - name:"" - str:"" + name:'' + str:'' num: 1 constructor(name, str) { this.name = name; @@ -767,9 +767,9 @@ on(method: string, callback: CalleeCallback): void; let method = 'call_Function'; function funcCallBack(pdata) { console.log('Callee funcCallBack is called ' + pdata); - let msg = new MyMessageAble("test", ""); + let msg = new MyMessageAble('test', ''); pdata.readSequenceable(msg); - return new MyMessageAble("test1", "Callee test"); + return new MyMessageAble('test1', 'Callee test'); } export default class MainAbility extends Ability { onCreate(want, launchParam) { diff --git a/zh-cn/application-dev/reference/apis/js-apis-app-ability-want.md b/zh-cn/application-dev/reference/apis/js-apis-app-ability-want.md index 79cb1a5f4a26454cdb17b87860355a953dfb6646..410875922ba693173d32285fd98183838b43858c 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-app-ability-want.md +++ b/zh-cn/application-dev/reference/apis/js-apis-app-ability-want.md @@ -22,7 +22,7 @@ import Want from '@ohos.app.ability.Want'; | bundleName | string | 否 | 表示包描述。如果在Want中同时指定了BundleName和AbilityName,则Want可以直接匹配到指定的Ability。 | | abilityName | string | 否 | 表示待启动的Ability名称。如果在Want中该字段同时指定了BundleName和AbilityName,则Want可以直接匹配到指定的Ability。AbilityName需要在一个应用的范围内保证唯一。 | | uri | string | 否 | 表示Uri描述。如果在Want中指定了Uri,则Want将匹配指定的Uri信息,包括scheme, schemeSpecificPart, authority和path信息。 | -| type | string | 否 | 表示MIME type类型描述,打开文件的类型,主要用于文管打开文件。比如:"text/xml" 、 "image/*"等,MIME定义参考:https://www.iana.org/assignments/media-types/media-types.xhtml?utm_source=ld246.com。 | +| type | string | 否 | 表示MIME type类型描述,打开文件的类型,主要用于文管打开文件。比如:'text/xml' 、 'image/*'等,MIME定义参考:https://www.iana.org/assignments/media-types/media-types.xhtml?utm_source=ld246.com。 | | flags | number | 否 | 表示处理Want的方式。默认传数字,具体参考:[flags说明](js-apis-ability-wantConstant.md#wantConstant.Flags)。 | | action | string | 否 | 表示要执行的通用操作(如:查看、分享、应用详情)。在隐式Want中,您可以定义该字段,配合uri或parameters来表示对数据要执行的操作。 | | parameters | {[key: string]: any} | 否 | 表示WantParams描述,由开发者自行决定传入的键值对。默认会携带以下key值:
- ohos.aafwk.callerPid:表示拉起方的pid。
- ohos.aafwk.param.callerToken:表示拉起方的token。
- ohos.aafwk.param.callerUid:表示[BundleInfo](js-apis-bundleManager-bundleInfo.md#bundleinfo-1)中的uid,应用包里应用程序的uid。
- component.startup.newRules:表示是否启用新的管控规则。
- moduleName:表示拉起方的模块名,该字段的值即使定义成其他字符串,在传递到另一端时会被修改为正确的值。
- ohos.dlp.params.sandbox:表示dlp文件才会有。 | | @@ -35,14 +35,14 @@ import Want from '@ohos.app.ability.Want'; ```ts var want = { - "deviceId": "", // deviceId为空表示本设备 - "bundleName": "com.extreme.test", - "abilityName": "MainAbility", - "moduleName": "entry" // moduleName非必选 + 'deviceId': '', // deviceId为空表示本设备 + 'bundleName': 'com.extreme.test', + 'abilityName': 'MainAbility', + 'moduleName': 'entry' // moduleName非必选 }; this.context.startAbility(want, (error) => { // 显式拉起Ability,通过bundleName、abilityName和moduleName可以唯一确定一个Ability - console.log("error.code = " + error.code) + console.log('error.code = ' + error.code); }) ``` @@ -51,84 +51,84 @@ import Want from '@ohos.app.ability.Want'; * 字符串(String) ```ts let want = { - bundleName: "com.example.demo", - abilityName: "com.example.demo.MainAbility", + bundleName: 'com.example.demo', + abilityName: 'com.example.demo.MainAbility', parameters: { - keyForString: "str", + keyForString: 'str', }, - } + }; ``` * 数字(Number) ```ts let want = { - bundleName: "com.example.demo", - abilityName: "com.example.demo.MainAbility", + bundleName: 'com.example.demo', + abilityName: 'com.example.demo.MainAbility', parameters: { keyForInt: 100, keyForDouble: 99.99, }, - } + }; ``` * 布尔(Boolean) ```ts let want = { - bundleName: "com.example.demo", - abilityName: "com.example.demo.MainAbility", + bundleName: 'com.example.demo', + abilityName: 'com.example.demo.MainAbility', parameters: { keyForBool: true, }, - } + }; ``` * 对象(Object) ```ts let want = { - bundleName: "com.example.demo", - abilityName: "com.example.demo.MainAbility", + bundleName: 'com.example.demo', + abilityName: 'com.example.demo.MainAbility', parameters: { keyForObject: { - keyForObjectString: "str", + keyForObjectString: 'str', keyForObjectInt: -200, keyForObjectDouble: 35.5, keyForObjectBool: false, }, }, - } + }; ``` * 数组(Array) ```ts let want = { - bundleName: "com.example.demo", - abilityName: "com.example.demo.MainAbility", + bundleName: 'com.example.demo', + abilityName: 'com.example.demo.MainAbility', parameters: { - keyForArrayString: ["str1", "str2", "str3"], + keyForArrayString: ['str1', 'str2', 'str3'], keyForArrayInt: [100, 200, 300, 400], keyForArrayDouble: [0.1, 0.2], - keyForArrayObject: [{obj1: "aaa"}, {obj2: 100}], + keyForArrayObject: [{obj1: 'aaa'}, {obj2: 100}], }, - } + }; ``` * 文件描述符(FD) ```ts import fileio from '@ohos.fileio'; var fd; try { - fd = fileio.openSync("/data/storage/el2/base/haps/pic.png"); + fd = fileio.openSync('/data/storage/el2/base/haps/pic.png'); } catch(e) { - console.log("openSync fail:" + JSON.stringify(e)); + console.log('openSync fail:' + JSON.stringify(e)); } var want = { - "deviceId": "", // deviceId为空表示本设备 - "bundleName": "com.extreme.test", - "abilityName": "MainAbility", - "moduleName": "entry", // moduleName非必选 - "parameters": { - "keyFd":{"type":"FD", "value":fd} // {"type":"FD", "value":fd}是固定用法,用于表示该数据是FD + 'deviceId': '', // deviceId为空表示本设备 + 'bundleName': 'com.extreme.test', + 'abilityName': 'MainAbility', + 'moduleName': 'entry', // moduleName非必选 + 'parameters': { + 'keyFd':{'type':'FD', 'value':fd} // {'type':'FD', 'value':fd}是固定用法,用于表示该数据是FD } }; this.context.startAbility(want, (error) => { // 显式拉起Ability,通过bundleName、abilityName和moduleName可以唯一确定一个Ability - console.log("error.code = " + error.code) - }) + console.log('error.code = ' + error.code); + }); ``` diff --git a/zh-cn/application-dev/reference/apis/js-apis-app-ability-wantAgent.md b/zh-cn/application-dev/reference/apis/js-apis-app-ability-wantAgent.md index 5aadd796d7e3f4dbc33f9805fa100642d07e0d1b..d453a654a8879fde7c6ebe6eeb94dda615479339 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-app-ability-wantAgent.md +++ b/zh-cn/application-dev/reference/apis/js-apis-app-ability-wantAgent.md @@ -34,27 +34,27 @@ import WantAgent from '@ohos.app.ability.wantAgent'; //getWantAgent回调 function getWantAgentCallback(err, data) { - console.info("==========================>getWantAgentCallback=======================>"); + console.info('==========================>getWantAgentCallback=======================>'); } //WantAgentInfo对象 var wantAgentInfo = { wants: [ { - deviceId: "deviceId", - bundleName: "com.neu.setResultOnAbilityResultTest1", - abilityName: "com.example.test.MainAbility", - action: "action1", - entities: ["entity1"], - type: "MIMETYPE", - uri: "key={true,true,false}", + deviceId: 'deviceId', + bundleName: 'com.neu.setResultOnAbilityResultTest1', + abilityName: 'com.example.test.MainAbility', + action: 'action1', + entities: ['entity1'], + type: 'MIMETYPE', + uri: 'key={true,true,false}', parameters: { mykey0: 2222, mykey1: [1, 2, 3], - mykey2: "[1, 2, 3]", - mykey3: "ssssssssssssssssssssssssss", + mykey2: '[1, 2, 3]', + mykey3: 'ssssssssssssssssssssssssss', mykey4: [false, true, false], - mykey5: ["qqqqq", "wwwwww", "aaaaaaaaaaaaaaaaa"], + mykey5: ['qqqqq', 'wwwwww', 'aaaaaaaaaaaaaaaaa'], mykey6: true, } } @@ -65,9 +65,9 @@ var wantAgentInfo = { } try { - WantAgent.getWantAgent(wantAgentInfo, getWantAgentCallback) + WantAgent.getWantAgent(wantAgentInfo, getWantAgentCallback); } catch (paramError) { - console.log("error: " + paramError.code + ", " + paramError.message); + console.log('error: ' + paramError.code + ', ' + paramError.message); } ``` @@ -103,21 +103,21 @@ import WantAgent from '@ohos.app.ability.wantAgent'; var wantAgentInfo = { wants: [ { - deviceId: "deviceId", - bundleName: "com.neu.setResultOnAbilityResultTest1", - abilityName: "com.example.test.MainAbility", - action: "action1", - entities: ["entity1"], - type: "MIMETYPE", - uri: "key={true,true,false}", + deviceId: 'deviceId', + bundleName: 'com.neu.setResultOnAbilityResultTest1', + abilityName: 'com.example.test.MainAbility', + action: 'action1', + entities: ['entity1'], + type: 'MIMETYPE', + uri: 'key={true,true,false}', parameters: { mykey0: 2222, mykey1: [1, 2, 3], - mykey2: "[1, 2, 3]", - mykey3: "ssssssssssssssssssssssssss", + mykey2: '[1, 2, 3]', + mykey3: 'ssssssssssssssssssssssssss', mykey4: [false, true, false], - mykey5: ["qqqqq", "wwwwww", "aaaaaaaaaaaaaaaaa"], + mykey5: ['qqqqq', 'wwwwww', 'aaaaaaaaaaaaaaaaa'], mykey6: true, } } @@ -125,14 +125,14 @@ var wantAgentInfo = { operationType: WantAgent.OperationType.START_ABILITIES, requestCode: 0, wantAgentFlags:[WantAgent.WantAgentFlags.UPDATE_PRESENT_FLAG] -} +}; try { WantAgent.getWantAgent(wantAgentInfo).then((data) => { - console.info("==========================>getWantAgentCallback=======================>"); + console.info('==========================>getWantAgentCallback=======================>'); }); } catch (paramError) { - console.log("error: " + paramError.code + ", " + paramError.message); + console.log('error: ' + paramError.code + ', ' + paramError.message); } ``` @@ -164,7 +164,7 @@ var wantAgent; //getWantAgent回调 function getWantAgentCallback(err, data) { - console.info("==========================>getWantAgentCallback=======================>"); + console.info('==========================>getWantAgentCallback=======================>'); if (err.code == 0) { wantAgent = data; } else { @@ -175,21 +175,21 @@ function getWantAgentCallback(err, data) { var wantAgentInfo = { wants: [ { - deviceId: "deviceId", - bundleName: "com.neu.setResultOnAbilityResultTest1", - abilityName: "com.example.test.MainAbility", - action: "action1", - entities: ["entity1"], - type: "MIMETYPE", - uri: "key={true,true,false}", + deviceId: 'deviceId', + bundleName: 'com.neu.setResultOnAbilityResultTest1', + abilityName: 'com.example.test.MainAbility', + action: 'action1', + entities: ['entity1'], + type: 'MIMETYPE', + uri: 'key={true,true,false}', parameters: { mykey0: 2222, mykey1: [1, 2, 3], - mykey2: "[1, 2, 3]", - mykey3: "ssssssssssssssssssssssssss", + mykey2: '[1, 2, 3]', + mykey3: 'ssssssssssssssssssssssssss', mykey4: [false, true, false], - mykey5: ["qqqqq", "wwwwww", "aaaaaaaaaaaaaaaaa"], + mykey5: ['qqqqq', 'wwwwww', 'aaaaaaaaaaaaaaaaa'], mykey6: true, } } @@ -197,18 +197,18 @@ var wantAgentInfo = { operationType: WantAgent.OperationType.START_ABILITIES, requestCode: 0, wantAgentFlags:[WantAgent.WantAgentFlags.UPDATE_PRESENT_FLAG] -} +}; try { - WantAgent.getWantAgent(wantAgentInfo, getWantAgentCallback) + WantAgent.getWantAgent(wantAgentInfo, getWantAgentCallback); //getBundleName回调 function getBundleNameCallback(err, data) { - console.info("==========================>getBundleNameCallback=======================>"); + console.info('==========================>getBundleNameCallback=======================>'); } - WantAgent.getBundleName(wantAgent, getBundleNameCallback) + WantAgent.getBundleName(wantAgent, getBundleNameCallback); } catch (paramError) { - console.log("error: " + paramError.code + ", " + paramError.message); + console.log('error: ' + paramError.code + ', ' + paramError.message); } ``` @@ -247,21 +247,21 @@ var wantAgent; var wantAgentInfo = { wants: [ { - deviceId: "deviceId", - bundleName: "com.neu.setResultOnAbilityResultTest1", - abilityName: "com.example.test.MainAbility", - action: "action1", - entities: ["entity1"], - type: "MIMETYPE", - uri: "key={true,true,false}", + deviceId: 'deviceId', + bundleName: 'com.neu.setResultOnAbilityResultTest1', + abilityName: 'com.example.test.MainAbility', + action: 'action1', + entities: ['entity1'], + type: 'MIMETYPE', + uri: 'key={true,true,false}', parameters: { mykey0: 2222, mykey1: [1, 2, 3], - mykey2: "[1, 2, 3]", - mykey3: "ssssssssssssssssssssssssss", + mykey2: '[1, 2, 3]', + mykey3: 'ssssssssssssssssssssssssss', mykey4: [false, true, false], - mykey5: ["qqqqq", "wwwwww", "aaaaaaaaaaaaaaaaa"], + mykey5: ['qqqqq', 'wwwwww', 'aaaaaaaaaaaaaaaaa'], mykey6: true, } } @@ -269,19 +269,19 @@ var wantAgentInfo = { operationType: WantAgent.OperationType.START_ABILITIES, requestCode: 0, wantAgentFlags:[WantAgent.WantAgentFlags.UPDATE_PRESENT_FLAG] -} +}; try { WantAgent.getWantAgent(wantAgentInfo).then((data) => { - console.info("==========================>getWantAgentCallback=======================>"); + console.info('==========================>getWantAgentCallback=======================>'); wantAgent = data; }); WantAgent.getBundleName(wantAgent).then((data) => { - console.info("==========================>getBundleNameCallback=======================>"); + console.info('==========================>getBundleNameCallback=======================>'); }); } catch (paramError) { - console.log("error: " + paramError.code + ", " + paramError.message); + console.log('error: ' + paramError.code + ', ' + paramError.message); } ``` @@ -313,7 +313,7 @@ var wantAgent; //getWantAgent回调 function getWantAgentCallback(err, data) { - console.info("==========================>getWantAgentCallback=======================>"); + console.info('==========================>getWantAgentCallback=======================>'); if (err.code == 0) { wantAgent = data; } else { @@ -324,21 +324,21 @@ function getWantAgentCallback(err, data) { var wantAgentInfo = { wants: [ { - deviceId: "deviceId", - bundleName: "com.neu.setResultOnAbilityResultTest1", - abilityName: "com.example.test.MainAbility", - action: "action1", - entities: ["entity1"], - type: "MIMETYPE", - uri: "key={true,true,false}", + deviceId: 'deviceId', + bundleName: 'com.neu.setResultOnAbilityResultTest1', + abilityName: 'com.example.test.MainAbility', + action: 'action1', + entities: ['entity1'], + type: 'MIMETYPE', + uri: 'key={true,true,false}', parameters: { mykey0: 2222, mykey1: [1, 2, 3], - mykey2: "[1, 2, 3]", - mykey3: "ssssssssssssssssssssssssss", + mykey2: '[1, 2, 3]', + mykey3: 'ssssssssssssssssssssssssss', mykey4: [false, true, false], - mykey5: ["qqqqq", "wwwwww", "aaaaaaaaaaaaaaaaa"], + mykey5: ['qqqqq', 'wwwwww', 'aaaaaaaaaaaaaaaaa'], mykey6: true, } } @@ -346,18 +346,18 @@ var wantAgentInfo = { operationType: WantAgent.OperationType.START_ABILITIES, requestCode: 0, wantAgentFlags:[WantAgent.WantAgentFlags.UPDATE_PRESENT_FLAG] -} +}; try { - WantAgent.getWantAgent(wantAgentInfo, getWantAgentCallback) + WantAgent.getWantAgent(wantAgentInfo, getWantAgentCallback); //getUid回调 function getUidCallback(err, data) { - console.info("==========================>getUidCallback=======================>"); + console.info('==========================>getUidCallback=======================>'); } - WantAgent.getUid(wantAgent, getUidCallback) + WantAgent.getUid(wantAgent, getUidCallback); } catch (paramError) { - console.log("error: " + paramError.code + ", " + paramError.message); + console.log('error: ' + paramError.code + ', ' + paramError.message); } ``` @@ -396,21 +396,21 @@ var wantAgent; var wantAgentInfo = { wants: [ { - deviceId: "deviceId", - bundleName: "com.neu.setResultOnAbilityResultTest1", - abilityName: "com.example.test.MainAbility", - action: "action1", - entities: ["entity1"], - type: "MIMETYPE", - uri: "key={true,true,false}", + deviceId: 'deviceId', + bundleName: 'com.neu.setResultOnAbilityResultTest1', + abilityName: 'com.example.test.MainAbility', + action: 'action1', + entities: ['entity1'], + type: 'MIMETYPE', + uri: 'key={true,true,false}', parameters: { mykey0: 2222, mykey1: [1, 2, 3], - mykey2: "[1, 2, 3]", - mykey3: "ssssssssssssssssssssssssss", + mykey2: '[1, 2, 3]', + mykey3: 'ssssssssssssssssssssssssss', mykey4: [false, true, false], - mykey5: ["qqqqq", "wwwwww", "aaaaaaaaaaaaaaaaa"], + mykey5: ['qqqqq', 'wwwwww', 'aaaaaaaaaaaaaaaaa'], mykey6: true, } } @@ -418,19 +418,19 @@ var wantAgentInfo = { operationType: WantAgent.OperationType.START_ABILITIES, requestCode: 0, wantAgentFlags:[WantAgent.WantAgentFlags.UPDATE_PRESENT_FLAG] -} +}; try { WantAgent.getWantAgent(wantAgentInfo).then((data) => { - console.info("==========================>getWantAgentCallback=======================>"); + console.info('==========================>getWantAgentCallback=======================>'); wantAgent = data; }); WantAgent.getUid(wantAgent).then((data) => { - console.info("==========================>getUidCallback=======================>"); + console.info('==========================>getUidCallback=======================>'); }); } catch (paramError) { - console.log("error: " + paramError.code + ", " + paramError.message); + console.log('error: ' + paramError.code + ', ' + paramError.message); } ``` @@ -464,7 +464,7 @@ var wantAgent; //getWantAgent回调 function getWantAgentCallback(err, data) { - console.info("==========================>getWantAgentCallback=======================>"); + console.info('==========================>getWantAgentCallback=======================>'); if (err.code == 0) { wantAgent = data; } else { @@ -475,21 +475,21 @@ function getWantAgentCallback(err, data) { var wantAgentInfo = { wants: [ { - deviceId: "deviceId", - bundleName: "com.neu.setResultOnAbilityResultTest1", - abilityName: "com.example.test.MainAbility", - action: "action1", - entities: ["entity1"], - type: "MIMETYPE", - uri: "key={true,true,false}", + deviceId: 'deviceId', + bundleName: 'com.neu.setResultOnAbilityResultTest1', + abilityName: 'com.example.test.MainAbility', + action: 'action1', + entities: ['entity1'], + type: 'MIMETYPE', + uri: 'key={true,true,false}', parameters: { mykey0: 2222, mykey1: [1, 2, 3], - mykey2: "[1, 2, 3]", - mykey3: "ssssssssssssssssssssssssss", + mykey2: '[1, 2, 3]', + mykey3: 'ssssssssssssssssssssssssss', mykey4: [false, true, false], - mykey5: ["qqqqq", "wwwwww", "aaaaaaaaaaaaaaaaa"], + mykey5: ['qqqqq', 'wwwwww', 'aaaaaaaaaaaaaaaaa'], mykey6: true, } } @@ -497,18 +497,18 @@ var wantAgentInfo = { operationType: WantAgent.OperationType.START_ABILITIES, requestCode: 0, wantAgentFlags:[WantAgent.WantAgentFlags.UPDATE_PRESENT_FLAG] -} +}; try { - WantAgent.getWantAgent(wantAgentInfo, getWantAgentCallback) + WantAgent.getWantAgent(wantAgentInfo, getWantAgentCallback); //getWant回调 function getWantCallback(err, data) { - console.info("==========================>getWantCallback=======================>"); + console.info('==========================>getWantCallback=======================>'); } - WantAgent.getWant(wantAgent, getWantCallback) + WantAgent.getWant(wantAgent, getWantCallback); } catch (paramError) { - console.log("error: " + paramError.code + ", " + paramError.message); + console.log('error: ' + paramError.code + ', ' + paramError.message); } ``` @@ -549,21 +549,21 @@ var wantAgent; var wantAgentInfo = { wants: [ { - deviceId: "deviceId", - bundleName: "com.neu.setResultOnAbilityResultTest1", - abilityName: "com.example.test.MainAbility", - action: "action1", - entities: ["entity1"], - type: "MIMETYPE", - uri: "key={true,true,false}", + deviceId: 'deviceId', + bundleName: 'com.neu.setResultOnAbilityResultTest1', + abilityName: 'com.example.test.MainAbility', + action: 'action1', + entities: ['entity1'], + type: 'MIMETYPE', + uri: 'key={true,true,false}', parameters: { mykey0: 2222, mykey1: [1, 2, 3], - mykey2: "[1, 2, 3]", - mykey3: "ssssssssssssssssssssssssss", + mykey2: '[1, 2, 3]', + mykey3: 'ssssssssssssssssssssssssss', mykey4: [false, true, false], - mykey5: ["qqqqq", "wwwwww", "aaaaaaaaaaaaaaaaa"], + mykey5: ['qqqqq', 'wwwwww', 'aaaaaaaaaaaaaaaaa'], mykey6: true, } } @@ -571,19 +571,19 @@ var wantAgentInfo = { operationType: WantAgent.OperationType.START_ABILITIES, requestCode: 0, wantAgentFlags:[WantAgent.WantAgentFlags.UPDATE_PRESENT_FLAG] -} +}; try { WantAgent.getWantAgent(wantAgentInfo).then((data) => { - console.info("==========================>getWantAgentCallback=======================>"); + console.info('==========================>getWantAgentCallback=======================>'); wantAgent = data; }); WantAgent.getWant(wantAgent).then((data) => { - console.info("==========================>getWantCallback=======================>"); + console.info('==========================>getWantCallback=======================>'); }); } catch (paramError) { - console.log("error: " + paramError.code + ", " + paramError.message); + console.log('error: ' + paramError.code + ', ' + paramError.message); } ``` @@ -615,7 +615,7 @@ var wantAgent; //getWantAgent回调 function getWantAgentCallback(err, data) { - console.info("==========================>getWantAgentCallback=======================>"); + console.info('==========================>getWantAgentCallback=======================>'); if (err.code == 0) { wantAgent = data; } else { @@ -626,21 +626,21 @@ function getWantAgentCallback(err, data) { var wantAgentInfo = { wants: [ { - deviceId: "deviceId", - bundleName: "com.neu.setResultOnAbilityResultTest1", - abilityName: "com.example.test.MainAbility", - action: "action1", - entities: ["entity1"], - type: "MIMETYPE", - uri: "key={true,true,false}", + deviceId: 'deviceId', + bundleName: 'com.neu.setResultOnAbilityResultTest1', + abilityName: 'com.example.test.MainAbility', + action: 'action1', + entities: ['entity1'], + type: 'MIMETYPE', + uri: 'key={true,true,false}', parameters: { mykey0: 2222, mykey1: [1, 2, 3], - mykey2: "[1, 2, 3]", - mykey3: "ssssssssssssssssssssssssss", + mykey2: '[1, 2, 3]', + mykey3: 'ssssssssssssssssssssssssss', mykey4: [false, true, false], - mykey5: ["qqqqq", "wwwwww", "aaaaaaaaaaaaaaaaa"], + mykey5: ['qqqqq', 'wwwwww', 'aaaaaaaaaaaaaaaaa'], mykey6: true, } } @@ -648,18 +648,18 @@ var wantAgentInfo = { operationType: WantAgent.OperationType.START_ABILITIES, requestCode: 0, wantAgentFlags:[WantAgent.WantAgentFlags.UPDATE_PRESENT_FLAG] -} +}; try { - WantAgent.getWantAgent(wantAgentInfo, getWantAgentCallback) + WantAgent.getWantAgent(wantAgentInfo, getWantAgentCallback); //cancel回调 function cancelCallback(err, data) { - console.info("==========================>cancelCallback=======================>"); + console.info('==========================>cancelCallback=======================>'); } - WantAgent.cancel(wantAgent, cancelCallback) + WantAgent.cancel(wantAgent, cancelCallback); } catch (paramError) { - console.log("error: " + paramError.code + ", " + paramError.message); + console.log('error: ' + paramError.code + ', ' + paramError.message); } ``` @@ -698,21 +698,21 @@ var wantAgent; var wantAgentInfo = { wants: [ { - deviceId: "deviceId", - bundleName: "com.neu.setResultOnAbilityResultTest1", - abilityName: "com.example.test.MainAbility", - action: "action1", - entities: ["entity1"], - type: "MIMETYPE", - uri: "key={true,true,false}", + deviceId: 'deviceId', + bundleName: 'com.neu.setResultOnAbilityResultTest1', + abilityName: 'com.example.test.MainAbility', + action: 'action1', + entities: ['entity1'], + type: 'MIMETYPE', + uri: 'key={true,true,false}', parameters: { mykey0: 2222, mykey1: [1, 2, 3], - mykey2: "[1, 2, 3]", - mykey3: "ssssssssssssssssssssssssss", + mykey2: '[1, 2, 3]', + mykey3: 'ssssssssssssssssssssssssss', mykey4: [false, true, false], - mykey5: ["qqqqq", "wwwwww", "aaaaaaaaaaaaaaaaa"], + mykey5: ['qqqqq', 'wwwwww', 'aaaaaaaaaaaaaaaaa'], mykey6: true, } } @@ -720,19 +720,19 @@ var wantAgentInfo = { operationType: WantAgent.OperationType.START_ABILITIES, requestCode: 0, wantAgentFlags:[WantAgent.WantAgentFlags.UPDATE_PRESENT_FLAG] -} +}; try { WantAgent.getWantAgent(wantAgentInfo).then((data) => { - console.info("==========================>getWantAgentCallback=======================>"); + console.info('==========================>getWantAgentCallback=======================>'); wantAgent = data; }); WantAgent.cancel(wantAgent).then((data) => { - console.info("==========================>cancelCallback=======================>"); + console.info('==========================>cancelCallback=======================>'); }); } catch (paramError) { - console.log("error: " + paramError.code + ", " + paramError.message); + console.log('error: ' + paramError.code + ', ' + paramError.message); } ``` @@ -765,7 +765,7 @@ var wantAgent; //getWantAgent回调 function getWantAgentCallback(err, data) { - console.info("==========================>getWantAgentCallback=======================>"); + console.info('==========================>getWantAgentCallback=======================>'); if (err.code == 0) { wantAgent = data; } else { @@ -776,21 +776,21 @@ function getWantAgentCallback(err, data) { var wantAgentInfo = { wants: [ { - deviceId: "deviceId", - bundleName: "com.neu.setResultOnAbilityResultTest1", - abilityName: "com.example.test.MainAbility", - action: "action1", - entities: ["entity1"], - type: "MIMETYPE", - uri: "key={true,true,false}", + deviceId: 'deviceId', + bundleName: 'com.neu.setResultOnAbilityResultTest1', + abilityName: 'com.example.test.MainAbility', + action: 'action1', + entities: ['entity1'], + type: 'MIMETYPE', + uri: 'key={true,true,false}', parameters: { mykey0: 2222, mykey1: [1, 2, 3], - mykey2: "[1, 2, 3]", - mykey3: "ssssssssssssssssssssssssss", + mykey2: '[1, 2, 3]', + mykey3: 'ssssssssssssssssssssssssss', mykey4: [false, true, false], - mykey5: ["qqqqq", "wwwwww", "aaaaaaaaaaaaaaaaa"], + mykey5: ['qqqqq', 'wwwwww', 'aaaaaaaaaaaaaaaaa'], mykey6: true, } } @@ -798,23 +798,23 @@ var wantAgentInfo = { operationType: WantAgent.OperationType.START_ABILITIES, requestCode: 0, wantAgentFlags:[WantAgent.WantAgentFlags.UPDATE_PRESENT_FLAG] -} +}; try { - WantAgent.getWantAgent(wantAgentInfo, getWantAgentCallback) + WantAgent.getWantAgent(wantAgentInfo, getWantAgentCallback); //trigger回调 function triggerCallback(data) { - console.info("==========================>triggerCallback=======================>"); + console.info('==========================>triggerCallback=======================>'); } var triggerInfo = { code:0 - } - WantAgent.trigger(wantAgent, triggerInfo, triggerCallback) + }; + WantAgent.trigger(wantAgent, triggerInfo, triggerCallback); } catch (paramError) { - console.log("error: " + paramError.code + ", " + paramError.message); + console.log('error: ' + paramError.code + ', ' + paramError.message); } ``` @@ -848,7 +848,7 @@ var wantAgent2; //getWantAgent回调 function getWantAgentCallback(err, data) { - console.info("==========================>getWantAgentCallback=======================>"); + console.info('==========================>getWantAgentCallback=======================>'); if (err.code == 0) { wantAgent1 = data; wantAgent2 = data; @@ -860,21 +860,21 @@ function getWantAgentCallback(err, data) { var wantAgentInfo = { wants: [ { - deviceId: "deviceId", - bundleName: "com.neu.setResultOnAbilityResultTest1", - abilityName: "com.example.test.MainAbility", - action: "action1", - entities: ["entity1"], - type: "MIMETYPE", - uri: "key={true,true,false}", + deviceId: 'deviceId', + bundleName: 'com.neu.setResultOnAbilityResultTest1', + abilityName: 'com.example.test.MainAbility', + action: 'action1', + entities: ['entity1'], + type: 'MIMETYPE', + uri: 'key={true,true,false}', parameters: { mykey0: 2222, mykey1: [1, 2, 3], - mykey2: "[1, 2, 3]", - mykey3: "ssssssssssssssssssssssssss", + mykey2: '[1, 2, 3]', + mykey3: 'ssssssssssssssssssssssssss', mykey4: [false, true, false], - mykey5: ["qqqqq", "wwwwww", "aaaaaaaaaaaaaaaaa"], + mykey5: ['qqqqq', 'wwwwww', 'aaaaaaaaaaaaaaaaa'], mykey6: true, } } @@ -882,18 +882,18 @@ var wantAgentInfo = { operationType: WantAgent.OperationType.START_ABILITIES, requestCode: 0, wantAgentFlags:[WantAgent.WantAgentFlags.UPDATE_PRESENT_FLAG] -} +}; try { - WantAgent.getWantAgent(wantAgentInfo, getWantAgentCallback) + WantAgent.getWantAgent(wantAgentInfo, getWantAgentCallback); //equal回调 function equalCallback(err, data) { - console.info("==========================>equalCallback=======================>"); + console.info('==========================>equalCallback=======================>'); } - WantAgent.equal(wantAgent1, wantAgent2, equalCallback) + WantAgent.equal(wantAgent1, wantAgent2, equalCallback); } catch (paramError) { - console.log("error: " + paramError.code + ", " + paramError.message); + console.log('error: ' + paramError.code + ', ' + paramError.message); } ``` @@ -934,21 +934,21 @@ var wantAgent2; var wantAgentInfo = { wants: [ { - deviceId: "deviceId", - bundleName: "com.neu.setResultOnAbilityResultTest1", - abilityName: "com.example.test.MainAbility", - action: "action1", - entities: ["entity1"], - type: "MIMETYPE", - uri: "key={true,true,false}", + deviceId: 'deviceId', + bundleName: 'com.neu.setResultOnAbilityResultTest1', + abilityName: 'com.example.test.MainAbility', + action: 'action1', + entities: ['entity1'], + type: 'MIMETYPE', + uri: 'key={true,true,false}', parameters: { mykey0: 2222, mykey1: [1, 2, 3], - mykey2: "[1, 2, 3]", - mykey3: "ssssssssssssssssssssssssss", + mykey2: '[1, 2, 3]', + mykey3: 'ssssssssssssssssssssssssss', mykey4: [false, true, false], - mykey5: ["qqqqq", "wwwwww", "aaaaaaaaaaaaaaaaa"], + mykey5: ['qqqqq', 'wwwwww', 'aaaaaaaaaaaaaaaaa'], mykey6: true, } } @@ -956,20 +956,20 @@ var wantAgentInfo = { operationType: WantAgent.OperationType.START_ABILITIES, requestCode: 0, wantAgentFlags:[WantAgent.WantAgentFlags.UPDATE_PRESENT_FLAG] -} +}; try { WantAgent.getWantAgent(wantAgentInfo).then((data) => { - console.info("==========================>getWantAgentCallback=======================>"); + console.info('==========================>getWantAgentCallback=======================>'); wantAgent1 = data; wantAgent2 = data; }); WantAgent.equal(wantAgent1, wantAgent2).then((data) => { - console.info("==========================>equalCallback=======================>"); + console.info('==========================>equalCallback=======================>'); }); } catch (paramError) { - console.log("error: " + paramError.code + ", " + paramError.message); + console.log('error: ' + paramError.code + ', ' + paramError.message); } ``` @@ -1000,21 +1000,21 @@ var wantAgent; var wantAgentInfo = { wants: [ { - deviceId: "deviceId", - bundleName: "com.neu.setResultOnAbilityResultTest1", - abilityName: "com.example.test.MainAbility", - action: "action1", - entities: ["entity1"], - type: "MIMETYPE", - uri: "key={true,true,false}", + deviceId: 'deviceId', + bundleName: 'com.neu.setResultOnAbilityResultTest1', + abilityName: 'com.example.test.MainAbility', + action: 'action1', + entities: ['entity1'], + type: 'MIMETYPE', + uri: 'key={true,true,false}', parameters: { mykey0: 2222, mykey1: [1, 2, 3], - mykey2: "[1, 2, 3]", - mykey3: "ssssssssssssssssssssssssss", + mykey2: '[1, 2, 3]', + mykey3: 'ssssssssssssssssssssssssss', mykey4: [false, true, false], - mykey5: ["qqqqq", "wwwwww", "aaaaaaaaaaaaaaaaa"], + mykey5: ['qqqqq', 'wwwwww', 'aaaaaaaaaaaaaaaaa'], mykey6: true, } } @@ -1022,11 +1022,11 @@ var wantAgentInfo = { operationType: WantAgent.OperationType.START_ABILITIES, requestCode: 0, wantAgentFlags:[WantAgent.WantAgentFlags.UPDATE_PRESENT_FLAG] -} +}; try { WantAgent.getWantAgent(wantAgentInfo).then((data) => { - console.info("==========================>getWantAgentCallback=======================>"); + console.info('==========================>getWantAgentCallback=======================>'); wantAgent = data; }); @@ -1034,7 +1034,7 @@ try { console.log('----------- getOperationType ----------, OperationType: ' + OperationType); }) } catch (paramError) { - console.log("error: " + paramError.code + ", " + paramError.message); + console.log('error: ' + paramError.code + ', ' + paramError.message); } ``` @@ -1070,21 +1070,21 @@ var wantAgent; var wantAgentInfo = { wants: [ { - deviceId: "deviceId", - bundleName: "com.neu.setResultOnAbilityResultTest1", - abilityName: "com.example.test.MainAbility", - action: "action1", - entities: ["entity1"], - type: "MIMETYPE", - uri: "key={true,true,false}", + deviceId: 'deviceId', + bundleName: 'com.neu.setResultOnAbilityResultTest1', + abilityName: 'com.example.test.MainAbility', + action: 'action1', + entities: ['entity1'], + type: 'MIMETYPE', + uri: 'key={true,true,false}', parameters: { mykey0: 2222, mykey1: [1, 2, 3], - mykey2: "[1, 2, 3]", - mykey3: "ssssssssssssssssssssssssss", + mykey2: '[1, 2, 3]', + mykey3: 'ssssssssssssssssssssssssss', mykey4: [false, true, false], - mykey5: ["qqqqq", "wwwwww", "aaaaaaaaaaaaaaaaa"], + mykey5: ['qqqqq', 'wwwwww', 'aaaaaaaaaaaaaaaaa'], mykey6: true, } } @@ -1092,11 +1092,11 @@ var wantAgentInfo = { operationType: WantAgent.OperationType.START_ABILITIES, requestCode: 0, wantAgentFlags:[WantAgent.WantAgentFlags.UPDATE_PRESENT_FLAG] -} +}; try { WantAgent.getWantAgent(wantAgentInfo).then((data) => { - console.info("==========================>getWantAgentCallback=======================>"); + console.info('==========================>getWantAgentCallback=======================>'); wantAgent = data; }); @@ -1106,7 +1106,7 @@ try { console.log('getOperationType fail, err: ' + err); }) } catch (paramError) { - console.log("error: " + paramError.code + ", " + paramError.message); + console.log('error: ' + paramError.code + ', ' + paramError.message); } ``` diff --git a/zh-cn/application-dev/reference/apis/js-apis-app-ability-wantConstant.md b/zh-cn/application-dev/reference/apis/js-apis-app-ability-wantConstant.md index 91383bd62de559f15313821736fd0281ca8029f6..357114c71e4fac2d58f432791e9b557e2b100c47 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-app-ability-wantConstant.md +++ b/zh-cn/application-dev/reference/apis/js-apis-app-ability-wantConstant.md @@ -8,7 +8,7 @@ wantConstant模块提供want中操作want常数和解释Flags说明的能力。 ## 导入模块 -```js +```ts import wantConstant from '@ohos.app.ability.wantConstant'; ``` diff --git a/zh-cn/application-dev/reference/apis/js-apis-app-form-formBindingData.md b/zh-cn/application-dev/reference/apis/js-apis-app-form-formBindingData.md index 6a9acda6c88e5b6d0199ff1077cfbedc66bed8d8..c801a37b16339fafbfc682c031f80b84f5fb96a4 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-app-form-formBindingData.md +++ b/zh-cn/application-dev/reference/apis/js-apis-app-form-formBindingData.md @@ -35,7 +35,7 @@ createFormBindingData(obj?: Object | string): FormBindingData | 参数名 | 类型 | 必填 | 说明 | | ------ | -------------- | ---- | ------------------------------------------------------------ | -| obj | Object\|string | 否 | js卡片要展示的数据。可以是包含若干键值对的Object或者 json 格式的字符串。其中图片数据以"formImages"作为标识,内容为图片标识与图片文件描述符的键值对{"formImages": {"key1": fd1, "key2": fd2}} | +| obj | Object\|string | 否 | js卡片要展示的数据。可以是包含若干键值对的Object或者 json 格式的字符串。其中图片数据以'formImages'作为标识,内容为图片标识与图片文件描述符的键值对{'formImages': {'key1': fd1, 'key2': fd2}} | **返回值:** @@ -52,11 +52,11 @@ import featureAbility from '@ohos.ability.featureAbility'; import fileio from '@ohos.fileio'; let context=featureAbility.getContext(); context.getOrCreateLocalDir((err,data)=>{ - let path=data+"/xxx.jpg"; + let path=data+'/xxx.jpg'; let fd = fileio.openSync(path); let obj = { - "temperature": "21°", - "formImages": {"image": fd} + 'temperature': '21°', + 'formImages': {'image': fd} }; try { formBindingData.createFormBindingData(obj); diff --git a/zh-cn/application-dev/reference/apis/js-apis-app-form-formExtensionAbility.md b/zh-cn/application-dev/reference/apis/js-apis-app-form-formExtensionAbility.md index 6520391748d7593bba343086ca2438fc253dbf71..7cc5a26b23c12e0f5143981d4862ba5ba1650e12 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-app-form-formExtensionAbility.md +++ b/zh-cn/application-dev/reference/apis/js-apis-app-form-formExtensionAbility.md @@ -49,8 +49,8 @@ export default class MyFormExtensionAbility extends FormExtensionAbility { onAddForm(want) { console.log('FormExtensionAbility onAddForm, want:' + want.abilityName); let dataObj1 = { - temperature:"11c", - "time":"11:00" + temperature:'11c', + 'time':'11:00' }; let obj1 = formBindingData.createFormBindingData(dataObj1); return obj1; @@ -99,11 +99,11 @@ onUpdateForm(formId: string): void **示例:** ```ts -import formBindingData from '@ohos.app.form.formBindingData' +import formBindingData from '@ohos.app.form.formBindingData'; export default class MyFormExtensionAbility extends FormExtensionAbility { onUpdateForm(formId) { console.log('FormExtensionAbility onUpdateForm, formId:' + formId); - let obj2 = formBindingData.createFormBindingData({temperature:"22c", time:"22:00"}); + let obj2 = formBindingData.createFormBindingData({temperature:'22c', time:'22:00'}); this.context.updateForm(formId, obj2).then((data)=>{ console.log('FormExtensionAbility context updateForm, data:' + data); }).catch((error) => { @@ -129,14 +129,14 @@ onChangeFormVisibility(newStatus: { [key: string]: number }): void **示例:** ```ts -import formBindingData from '@ohos.app.form.formBindingData' +import formBindingData from '@ohos.app.form.formBindingData'; export default class MyFormExtensionAbility extends FormExtensionAbility { onChangeFormVisibility(newStatus) { console.log('FormExtensionAbility onChangeFormVisibility, newStatus:' + newStatus); - let obj2 = formBindingData.createFormBindingData({temperature:"22c", time:"22:00"}); + let obj2 = formBindingData.createFormBindingData({temperature:'22c', time:'22:00'}); for (let key in newStatus) { - console.log('FormExtensionAbility onChangeFormVisibility, key:' + key + ", value=" + newStatus[key]); + console.log('FormExtensionAbility onChangeFormVisibility, key:' + key + ', value=' + newStatus[key]); this.context.updateForm(key, obj2).then((data)=>{ console.log('FormExtensionAbility context updateForm, data:' + data); }).catch((error) => { @@ -166,7 +166,7 @@ onFormEvent(formId: string, message: string): void ```ts export default class MyFormExtension extends FormExtensionAbility { onFormEvent(formId, message) { - console.log('FormExtensionAbility onFormEvent, formId:' + formId + ", message:" + message); + console.log('FormExtensionAbility onFormEvent, formId:' + formId + ', message:' + message); } } ``` @@ -274,8 +274,8 @@ class MyFormExtensionAbility extends FormExtensionAbility { onShareForm(formId) { console.log('FormExtensionAbility onShareForm, formId:' + formId); let wantParams = { - "temperature":"20", - "time":"2022-8-8 09:59", + 'temperature':'20', + 'time':'2022-8-8 09:59', }; return wantParams; } diff --git a/zh-cn/application-dev/reference/apis/js-apis-app-form-formHost.md b/zh-cn/application-dev/reference/apis/js-apis-app-form-formHost.md index f7e0324ca30d9fc23fb7eeda1bb7d12731c1f9ad..d48bf0a55a5effc9bfe03df88a467d03e19afd19 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-app-form-formHost.md +++ b/zh-cn/application-dev/reference/apis/js-apis-app-form-formHost.md @@ -41,7 +41,7 @@ deleteForm(formId: string, callback: AsyncCallback<void>): void ```ts try { - var formId = "12400633174999288"; + var formId = '12400633174999288'; formHost.deleteForm(formId, (error, data) => { if (error) { console.log('formHost deleteForm, error:' + JSON.stringify(error)); @@ -89,7 +89,7 @@ deleteForm(formId: string): Promise<void> ```ts try { - var formId = "12400633174999288"; + var formId = '12400633174999288'; formHost.deleteForm(formId).then(() => { console.log('formHost deleteForm success'); }).catch((error) => { @@ -128,7 +128,7 @@ releaseForm(formId: string, callback: AsyncCallback<void>): void ```ts try { - var formId = "12400633174999288"; + var formId = '12400633174999288'; formHost.releaseForm(formId, (error, data) => { if (error) { console.log('formHost releaseForm, error:' + JSON.stringify(error)); @@ -168,7 +168,7 @@ releaseForm(formId: string, isReleaseCache: boolean, callback: AsyncCallback< ```ts try { - var formId = "12400633174999288"; + var formId = '12400633174999288'; formHost.releaseForm(formId, true, (error, data) => { if (error) { console.log('formHost releaseForm, error:' + JSON.stringify(error)); @@ -213,7 +213,7 @@ releaseForm(formId: string, isReleaseCache?: boolean): Promise<void> ```ts try { - var formId = "12400633174999288"; + var formId = '12400633174999288'; formHost.releaseForm(formId, true).then(() => { console.log('formHost releaseForm success'); }).catch((error) => { @@ -252,7 +252,7 @@ requestForm(formId: string, callback: AsyncCallback<void>): void ```ts try { - var formId = "12400633174999288"; + var formId = '12400633174999288'; formHost.requestForm(formId, (error, data) => { if (error) { console.log('formHost requestForm, error:' + JSON.stringify(error)); @@ -296,7 +296,7 @@ requestForm(formId: string): Promise<void> ```ts try { - var formId = "12400633174999288"; + var formId = '12400633174999288'; formHost.requestForm(formId).then(() => { console.log('formHost requestForm success'); }).catch((error) => { @@ -336,7 +336,7 @@ castToNormalForm(formId: string, callback: AsyncCallback<void>): void ```ts try { - var formId = "12400633174999288"; + var formId = '12400633174999288'; formHost.castToNormalForm(formId, (error, data) => { if (error) { console.log('formHost castTempForm, error:' + JSON.stringify(error)); @@ -380,7 +380,7 @@ castToNormalForm(formId: string): Promise<void> ```ts try { - var formId = "12400633174999288"; + var formId = '12400633174999288'; formHost.castToNormalForm(formId).then(() => { console.log('formHost castTempForm success'); }).catch((error) => { @@ -419,7 +419,7 @@ notifyVisibleForms(formIds: Array<string>, callback: AsyncCallback<void ```ts try { - var formId = ["12400633174999288"]; + var formId = ['12400633174999288']; formHost.notifyVisibleForms(formId, (error, data) => { if (error) { console.log('formHost notifyVisibleForms, error:' + JSON.stringify(error)); @@ -463,7 +463,7 @@ notifyVisibleForms(formIds: Array<string>): Promise<void> ```ts try { - var formId = ["12400633174999288"]; + var formId = ['12400633174999288']; formHost.notifyVisibleForms(formId).then(() => { console.log('formHost notifyVisibleForms success'); }).catch((error) => { @@ -502,7 +502,7 @@ notifyInvisibleForms(formIds: Array<string>, callback: AsyncCallback<vo ```ts try { - var formId = ["12400633174999288"]; + var formId = ['12400633174999288']; formHost.notifyInvisibleForms(formId, (error, data) => { if (error) { console.log('formHost notifyInvisibleForms, error:' + JSON.stringify(error)); @@ -546,7 +546,7 @@ notifyInvisibleForms(formIds: Array<string>): Promise<void> ```ts try { - var formId = ["12400633174999288"]; + var formId = ['12400633174999288']; formHost.notifyInvisibleForms(formId).then(() => { console.log('formHost notifyInvisibleForms success'); }).catch((error) => { @@ -585,7 +585,7 @@ enableFormsUpdate(formIds: Array<string>, callback: AsyncCallback<void& ```ts try { - var formId = ["12400633174999288"]; + var formId = ['12400633174999288']; formHost.enableFormsUpdate(formId, (error, data) => { if (error) { console.log('formHost enableFormsUpdate, error:' + JSON.stringify(error)); @@ -629,7 +629,7 @@ enableFormsUpdate(formIds: Array<string>): Promise<void> ```ts try { - var formId = ["12400633174999288"]; + var formId = ['12400633174999288']; formHost.enableFormsUpdate(formId).then(() => { console.log('formHost enableFormsUpdate success'); }).catch((error) => { @@ -668,7 +668,7 @@ disableFormsUpdate(formIds: Array<string>, callback: AsyncCallback<void ```ts try { - var formId = ["12400633174999288"]; + var formId = ['12400633174999288']; formHost.disableFormsUpdate(formId, (error, data) => { if (error) { console.log('formHost disableFormsUpdate, error:' + JSON.stringify(error)); @@ -712,7 +712,7 @@ disableFormsUpdate(formIds: Array<string>): Promise<void> ```ts try { - var formId = ["12400633174999288"]; + var formId = ['12400633174999288']; formHost.disableFormsUpdate(formId).then(() => { console.log('formHost disableFormsUpdate success'); }).catch((error) => { @@ -741,7 +741,7 @@ isSystemReady(callback: AsyncCallback<void>): void ```ts try { - var formId = "12400633174999288"; + var formId = '12400633174999288'; formHost.isSystemReady((error, data) => { if (error) { console.log('formHost isSystemReady, error:' + JSON.stringify(error)); @@ -770,7 +770,7 @@ isSystemReady(): Promise<void> ```ts try { - var formId = "12400633174999288"; + var formId = '12400633174999288'; formHost.isSystemReady().then(() => { console.log('formHost isSystemReady success'); }).catch((error) => { @@ -871,7 +871,7 @@ getFormsInfo(bundleName: string, callback: AsyncCallback<Array<formInfo.Fo ```ts try { - formHost.getFormsInfo("com.example.ohos.formjsdemo", (error, data) => { + formHost.getFormsInfo('com.example.ohos.formjsdemo', (error, data) => { if (error) { console.log('formHost getFormsInfo, error:' + JSON.stringify(error)); } else { @@ -912,7 +912,7 @@ getFormsInfo(bundleName: string, moduleName: string, callback: AsyncCallback< ```ts try { - formHost.getFormsInfo("com.example.ohos.formjsdemo", "entry", (error, data) => { + formHost.getFormsInfo('com.example.ohos.formjsdemo', 'entry', (error, data) => { if (error) { console.log('formHost getFormsInfo, error:' + JSON.stringify(error)); } else { @@ -958,7 +958,7 @@ getFormsInfo(bundleName: string, moduleName?: string): Promise<Array<formI ```ts try { - formHost.getFormsInfo("com.example.ohos.formjsdemo", "entry").then((data) => { + formHost.getFormsInfo('com.example.ohos.formjsdemo', 'entry').then((data) => { console.log('formHost getFormsInfo, data:' + JSON.stringify(data)); }).catch((error) => { console.log('formHost getFormsInfo, error:' + JSON.stringify(error)); @@ -989,7 +989,7 @@ deleteInvalidForms(formIds: Array<string>, callback: AsyncCallback<numb ```ts try { - var formIds = new Array("12400633174999288", "12400633174999289"); + var formIds = new Array('12400633174999288', '12400633174999289'); formHost.deleteInvalidForms(formIds, (error, data) => { if (error) { console.log('formHost deleteInvalidForms, error:' + JSON.stringify(error)); @@ -1028,7 +1028,7 @@ deleteInvalidForms(formIds: Array<string>): Promise<number> ```ts try { - var formIds = new Array("12400633174999288", "12400633174999289"); + var formIds = new Array('12400633174999288', '12400633174999289'); formHost.deleteInvalidForms(formIds).then((data) => { console.log('formHost deleteInvalidForms, data:' + JSON.stringify(data)); }).catch((error) => { @@ -1067,13 +1067,13 @@ acquireFormState(want: Want, callback: AsyncCallback<formInfo.FormStateInfo&g ```ts var want = { - "deviceId": "", - "bundleName": "ohos.samples.FormApplication", - "abilityName": "FormAbility", - "parameters": { - "ohos.extra.param.key.module_name": "entry", - "ohos.extra.param.key.form_name": "widget", - "ohos.extra.param.key.form_dimension": 2 + 'deviceId': '', + 'bundleName': 'ohos.samples.FormApplication', + 'abilityName': 'FormAbility', + 'parameters': { + 'ohos.extra.param.key.module_name': 'entry', + 'ohos.extra.param.key.form_name': 'widget', + 'ohos.extra.param.key.form_dimension': 2 } }; try { @@ -1122,13 +1122,13 @@ acquireFormState(want: Want): Promise<formInfo.FormStateInfo> ```ts var want = { - "deviceId": "", - "bundleName": "ohos.samples.FormApplication", - "abilityName": "FormAbility", - "parameters": { - "ohos.extra.param.key.module_name": "entry", - "ohos.extra.param.key.form_name": "widget", - "ohos.extra.param.key.form_dimension": 2 + 'deviceId': '', + 'bundleName': 'ohos.samples.FormApplication', + 'abilityName': 'FormAbility', + 'parameters': { + 'ohos.extra.param.key.module_name': 'entry', + 'ohos.extra.param.key.form_name': 'widget', + 'ohos.extra.param.key.form_dimension': 2 } }; try { @@ -1142,9 +1142,9 @@ try { } ``` -## on("formUninstall") +## on('formUninstall') -on(type: "formUninstall", callback: Callback<string>): void +on(type: 'formUninstall', callback: Callback<string>): void 订阅卡片卸载事件。使用callback异步回调。 @@ -1154,7 +1154,7 @@ on(type: "formUninstall", callback: Callback<string>): void | 参数名 | 类型 | 必填 | 说明 | | ------ | ------ | ---- | ------- | -| type | string | 是 | 填写"formUninstall",表示卡片卸载事件。 | +| type | string | 是 | 填写'formUninstall',表示卡片卸载事件。 | | callback | Callback<string> | 是 | 回调函数。返回卡片标识。 | **示例:** @@ -1163,12 +1163,12 @@ on(type: "formUninstall", callback: Callback<string>): void let callback = function(formId) { console.log('formHost on formUninstall, formId:' + formId); } -formHost.on("formUninstall", callback); +formHost.on('formUninstall', callback); ``` -## off("formUninstall") +## off('formUninstall') -off(type: "formUninstall", callback?: Callback<string>): void +off(type: 'formUninstall', callback?: Callback<string>): void 取消订阅卡片卸载事件。使用callback异步回调。 @@ -1178,7 +1178,7 @@ off(type: "formUninstall", callback?: Callback<string>): void | 参数名 | 类型 | 必填 | 说明 | | ------ | ------ | ---- | ------- | -| type | string | 是 | 填写"formUninstall",表示卡片卸载事件。 | +| type | string | 是 | 填写'formUninstall',表示卡片卸载事件。 | | callback | Callback<string> | 否 | 回调函数。返回卡片标识。缺省时,表示注销所有已注册事件回调。 | **示例:** @@ -1187,7 +1187,7 @@ off(type: "formUninstall", callback?: Callback<string>): void let callback = function(formId) { console.log('formHost on formUninstall, formId:' + formId); } -formHost.off("formUninstall", callback); +formHost.off('formUninstall', callback); ``` ## notifyFormsVisible @@ -1218,7 +1218,7 @@ notifyFormsVisible(formIds: Array<string>, isVisible: boolean, callback: A **示例:** ```ts -var formIds = new Array("12400633174999288", "12400633174999289"); +var formIds = new Array('12400633174999288', '12400633174999289'); try { formHost.notifyFormsVisible(formIds, true, (error, data) => { if (error) { @@ -1263,7 +1263,7 @@ notifyFormsVisible(formIds: Array<string>, isVisible: boolean): Promise< **示例:** ```ts -var formIds = new Array("12400633174999288", "12400633174999289"); +var formIds = new Array('12400633174999288', '12400633174999289'); try { formHost.notifyFormsVisible(formIds, true).then(() => { console.log('formHost notifyFormsVisible success'); @@ -1303,7 +1303,7 @@ notifyFormsEnableUpdate(formIds: Array<string>, isEnableUpdate: boolean, c **示例:** ```ts -var formIds = new Array("12400633174999288", "12400633174999289"); +var formIds = new Array('12400633174999288', '12400633174999289'); try { formHost.notifyFormsEnableUpdate(formIds, true, (error, data) => { if (error) { @@ -1348,7 +1348,7 @@ notifyFormsEnableUpdate(formIds: Array<string>, isEnableUpdate: boolean): **示例:** ```ts -var formIds = new Array("12400633174999288", "12400633174999289"); +var formIds = new Array('12400633174999288', '12400633174999289'); try { formHost.notifyFormsEnableUpdate(formIds, true).then(() => { console.log('formHost notifyFormsEnableUpdate success'); @@ -1388,8 +1388,8 @@ shareForm(formId: string, deviceId: string, callback: AsyncCallback<void>) **示例:** ```ts -var formId = "12400633174999288"; -var deviceId = "EFC11C0C53628D8CC2F8CB5052477E130D075917034613B9884C55CD22B3DEF2"; +var formId = '12400633174999288'; +var deviceId = 'EFC11C0C53628D8CC2F8CB5052477E130D075917034613B9884C55CD22B3DEF2'; try { formHost.shareForm(formId, deviceId, (error, data) => { if (error) { @@ -1434,8 +1434,8 @@ shareForm(formId: string, deviceId: string): Promise<void> **参数:** ```ts -var formId = "12400633174999288"; -var deviceId = "EFC11C0C53628D8CC2F8CB5052477E130D075917034613B9884C55CD22B3DEF2"; +var formId = '12400633174999288'; +var deviceId = 'EFC11C0C53628D8CC2F8CB5052477E130D075917034613B9884C55CD22B3DEF2'; try { formHost.shareForm(formId, deviceId).then(() => { console.log('formHost shareForm success'); @@ -1463,7 +1463,7 @@ notifyFormsPrivacyProtected(formIds: Array\, isProtected: boolean, callb | deviceId | string | 是 | 远程设备标识。 | ```ts -var formIds = new Array("12400633174999288", "12400633174999289"); +var formIds = new Array('12400633174999288', '12400633174999289'); try { formHost.notifyFormsPrivacyProtected(formIds, true).then(() => { console.log('formHost shareForm success'); diff --git a/zh-cn/application-dev/reference/apis/js-apis-app-form-formProvider.md b/zh-cn/application-dev/reference/apis/js-apis-app-form-formProvider.md index 04ccf2a32fbba0447f651c3129d3835857f60a8c..81b5b8fa9c541ea575842f552b7ff2d35161e451 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-app-form-formProvider.md +++ b/zh-cn/application-dev/reference/apis/js-apis-app-form-formProvider.md @@ -37,7 +37,7 @@ setFormNextRefreshTime(formId: string, minute: number, callback: AsyncCallback&l **示例:** ```ts -var formId = "12400633174999288"; +var formId = '12400633174999288'; try { formProvider.setFormNextRefreshTime(formId, 5, (error, data) => { if (error) { @@ -47,7 +47,7 @@ try { } }); } catch (error) { - console.log("error" + JSON.stringify(error)) + console.log('error' + JSON.stringify(error)) } ``` @@ -82,7 +82,7 @@ setFormNextRefreshTime(formId: string, minute: number): Promise<void> **示例:** ```ts -var formId = "12400633174999288"; +var formId = '12400633174999288'; try { formProvider.setFormNextRefreshTime(formId, 5).then(() => { console.log('formProvider setFormNextRefreshTime success'); @@ -121,9 +121,9 @@ updateForm(formId: string, formBindingData: formBindingData.FormBindingData,call ```ts import formBindingData from '@ohos.application.formBindingData'; -var formId = "12400633174999288"; +var formId = '12400633174999288'; try { - let obj = formBindingData.createFormBindingData({temperature:"22c", time:"22:00"}); + let obj = formBindingData.createFormBindingData({temperature:'22c', time:'22:00'}); formProvider.updateForm(formId, obj, (error, data) => { if (error) { console.log('formProvider updateForm, error:' + JSON.stringify(error)); @@ -168,8 +168,8 @@ updateForm(formId: string, formBindingData: formBindingData.FormBindingData): Pr ```ts import formBindingData from '@ohos.application.formBindingData'; -var formId = "12400633174999288"; -let obj = formBindingData.createFormBindingData({temperature:"22c", time:"22:00"}); +var formId = '12400633174999288'; +let obj = formBindingData.createFormBindingData({temperature:'22c', time:'22:00'}); try { formProvider.updateForm(formId, obj).then(() => { console.log('formProvider updateForm success'); @@ -246,7 +246,7 @@ getFormsInfo(filter: formInfo.FormInfoFilter, callback: AsyncCallback<Array&l import formInfo from '@ohos.application.formInfo'; const filter : formInfo.FormInfoFilter = { // get info of forms belong to module entry. - moduleName : "entry" + moduleName : 'entry' }; try { formProvider.getFormsInfo(filter, (error, data) => { @@ -294,7 +294,7 @@ getFormsInfo(filter?: formInfo.FormInfoFilter): Promise<Array<formInfo.For import formInfo from '@ohos.application.formInfo'; const filter : formInfo.FormInfoFilter = { // get info of forms belong to module entry. - moduleName : "entry" + moduleName : 'entry' }; try { formProvider.getFormsInfo(filter).then((data) => { @@ -321,7 +321,7 @@ requestPublishForm(want: Want, formBindingData: formBindingData.FormBindingData, | 参数名 | 类型 | 必填 | 说明 | | ------ | ---------------------------------------------------------------------- | ---- | ---------------- | -| want | [Want](js-apis-application-want.md) | 是 | 发布请求。需包含以下字段。
abilityName: 目标卡片ability
parameters:
"ohos.extra.param.key.form_dimension"
"ohos.extra.param.key.form_name"
"ohos.extra.param.key.module_name" | +| want | [Want](js-apis-application-want.md) | 是 | 发布请求。需包含以下字段。
abilityName: 目标卡片ability
parameters:
'ohos.extra.param.key.form_dimension'
'ohos.extra.param.key.form_name'
'ohos.extra.param.key.module_name' | | formBindingData.FormBindingData | [FormBindingData](js-apis-app-form-formBindingData.md#formbindingdata) | 是 | 创建卡片的数据。 | | callback | AsyncCallback<string> | 是 | 回调函数。返回卡片标识。 | @@ -337,15 +337,15 @@ requestPublishForm(want: Want, formBindingData: formBindingData.FormBindingData, ```ts import formBindingData from '@ohos.application.formBindingData'; var want = { - abilityName: "FormAbility", + abilityName: 'FormAbility', parameters: { - "ohos.extra.param.key.form_dimension": 2, - "ohos.extra.param.key.form_name": "widget", - "ohos.extra.param.key.module_name": "entry" + 'ohos.extra.param.key.form_dimension': 2, + 'ohos.extra.param.key.form_name': 'widget', + 'ohos.extra.param.key.module_name': 'entry' } }; try { - let obj = formBindingData.createFormBindingData({temperature:"22c", time:"22:00"}); + let obj = formBindingData.createFormBindingData({temperature:'22c', time:'22:00'}); formProvider.requestPublishForm(want, obj, (error, data) => { if (error) { console.log('formProvider requestPublishForm, error: ' + JSON.stringify(error)); @@ -372,7 +372,7 @@ requestPublishForm(want: Want, callback: AsyncCallback<string>): void | 参数名 | 类型 | 必填 | 说明 | | -------- | ----------------------------------- | ---- | ------------------------------------------------------------ | -| want | [Want](js-apis-application-want.md) | 是 | 发布请求。需包含以下字段。
abilityName: 目标卡片ability
parameters:
"ohos.extra.param.key.form_dimension"
"ohos.extra.param.key.form_name"
"ohos.extra.param.key.module_name" | +| want | [Want](js-apis-application-want.md) | 是 | 发布请求。需包含以下字段。
abilityName: 目标卡片ability
parameters:
'ohos.extra.param.key.form_dimension'
'ohos.extra.param.key.form_name'
'ohos.extra.param.key.module_name' | | callback | AsyncCallback<string> | 是 | 回调函数。返回卡片标识。 | **错误码:** @@ -386,11 +386,11 @@ requestPublishForm(want: Want, callback: AsyncCallback<string>): void ```ts var want = { - abilityName: "FormAbility", + abilityName: 'FormAbility', parameters: { - "ohos.extra.param.key.form_dimension": 2, - "ohos.extra.param.key.form_name": "widget", - "ohos.extra.param.key.module_name": "entry" + 'ohos.extra.param.key.form_dimension': 2, + 'ohos.extra.param.key.form_name': 'widget', + 'ohos.extra.param.key.module_name': 'entry' } }; try { @@ -421,7 +421,7 @@ requestPublishForm(want: Want, formBindingData?: formBindingData.FormBindingData | 参数名 | 类型 | 必填 | 说明 | | --------------- | ------------------------------------------------------------ | ---- | ------------------------------------------------------------ | -| want | [Want](js-apis-application-want.md) | 是 | 发布请求。需包含以下字段。
abilityName: 目标卡片ability
parameters:
"ohos.extra.param.key.form_dimension"
"ohos.extra.param.key.form_name"
"ohos.extra.param.key.module_name" | +| want | [Want](js-apis-application-want.md) | 是 | 发布请求。需包含以下字段。
abilityName: 目标卡片ability
parameters:
'ohos.extra.param.key.form_dimension'
'ohos.extra.param.key.form_name'
'ohos.extra.param.key.module_name' | | formBindingData.FormBindingData | [FormBindingData](js-apis-app-form-formBindingData.md#formbindingdata) | 否 | 创建卡片的数据。 | **返回值:** @@ -441,11 +441,11 @@ requestPublishForm(want: Want, formBindingData?: formBindingData.FormBindingData ```ts var want = { - abilityName: "FormAbility", + abilityName: 'FormAbility', parameters: { - "ohos.extra.param.key.form_dimension": 2, - "ohos.extra.param.key.form_name": "widget", - "ohos.extra.param.key.module_name": "entry" + 'ohos.extra.param.key.form_dimension': 2, + 'ohos.extra.param.key.form_name': 'widget', + 'ohos.extra.param.key.module_name': 'entry' } }; try { @@ -485,11 +485,11 @@ try { } else { if (isSupported) { var want = { - abilityName: "FormAbility", + abilityName: 'FormAbility', parameters: { - "ohos.extra.param.key.form_dimension": 2, - "ohos.extra.param.key.form_name": "widget", - "ohos.extra.param.key.module_name": "entry" + 'ohos.extra.param.key.form_dimension': 2, + 'ohos.extra.param.key.form_name': 'widget', + 'ohos.extra.param.key.module_name': 'entry' } }; try { @@ -535,11 +535,11 @@ try { formProvider.isRequestPublishFormSupported().then((isSupported) => { if (isSupported) { var want = { - abilityName: "FormAbility", + abilityName: 'FormAbility', parameters: { - "ohos.extra.param.key.form_dimension": 2, - "ohos.extra.param.key.form_name": "widget", - "ohos.extra.param.key.module_name": "entry" + 'ohos.extra.param.key.form_dimension': 2, + 'ohos.extra.param.key.form_name': 'widget', + 'ohos.extra.param.key.module_name': 'entry' } }; try { diff --git a/zh-cn/application-dev/reference/apis/js-apis-application-ability.md b/zh-cn/application-dev/reference/apis/js-apis-application-ability.md index ba7425428945eb12aada1253c191a19330591d3e..cc1fc06eafbad04401ab943489cb38e8e5bd67f3 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-application-ability.md +++ b/zh-cn/application-dev/reference/apis/js-apis-application-ability.md @@ -204,11 +204,11 @@ onContinue(wantParam : {[key: string]: any}): AbilityConstant.OnContinueResult; **示例:** ```ts - import AbilityConstant from "@ohos.application.AbilityConstant" + import AbilityConstant from '@ohos.application.AbilityConstant'; class myAbility extends Ability { onContinue(wantParams) { console.log('onContinue'); - wantParams["myData"] = "my1234567"; + wantParams['myData'] = 'my1234567'; return AbilityConstant.OnContinueResult.AGREE; } } @@ -285,7 +285,7 @@ dump(params: Array\): Array\; class myAbility extends Ability { dump(params) { console.log('dump, params:' + JSON.stringify(params)); - return ["params"] + return ['params'] } } ``` @@ -338,12 +338,12 @@ onSaveState(reason: AbilityConstant.StateType, wantParam : {[key: string]: any}) **示例:** ```ts -import AbilityConstant from '@ohos.application.AbilityConstant' +import AbilityConstant from '@ohos.application.AbilityConstant'; class myAbility extends Ability { onSaveState(reason, wantParam) { console.log('onSaveState'); - wantParam["myData"] = "my1234567"; + wantParam['myData'] = 'my1234567'; return AbilityConstant.OnSaveResult.RECOVERY_AGREE; } } @@ -391,8 +391,8 @@ call(method: string, data: rpc.Sequenceable): Promise<void>; ```ts import Ability from '@ohos.application.Ability'; class MyMessageAble{ // 自定义的Sequenceable数据结构 - name:"" - str:"" + name:'' + str:'' num: 1 constructor(name, str) { this.name = name; @@ -416,12 +416,12 @@ call(method: string, data: rpc.Sequenceable): Promise<void>; export default class MainAbility extends Ability { onWindowStageCreate(windowStage) { this.context.startAbilityByCall({ - bundleName: "com.example.myservice", - abilityName: "MainAbility", - deviceId: "" + bundleName: 'com.example.myservice', + abilityName: 'MainAbility', + deviceId: '' }).then((obj) => { caller = obj; - let msg = new MyMessageAble("msg", "world"); // 参考Sequenceable数据定义 + let msg = new MyMessageAble('msg', 'world'); // 参考Sequenceable数据定义 caller.call(method, msg) .then(() => { console.log('Caller call() called'); @@ -475,8 +475,8 @@ callWithResult(method: string, data: rpc.Sequenceable): Promise<rpc.MessagePa ```ts import Ability from '@ohos.application.Ability'; class MyMessageAble{ - name:"" - str:"" + name:'' + str:'' num: 1 constructor(name, str) { this.name = name; @@ -500,16 +500,16 @@ callWithResult(method: string, data: rpc.Sequenceable): Promise<rpc.MessagePa export default class MainAbility extends Ability { onWindowStageCreate(windowStage) { this.context.startAbilityByCall({ - bundleName: "com.example.myservice", - abilityName: "MainAbility", - deviceId: "" + bundleName: 'com.example.myservice', + abilityName: 'MainAbility', + deviceId: '' }).then((obj) => { caller = obj; - let msg = new MyMessageAble(1, "world"); + let msg = new MyMessageAble(1, 'world'); caller.callWithResult(method, msg) .then((data) => { console.log('Caller callWithResult() called'); - let retmsg = new MyMessageAble(0, ""); + let retmsg = new MyMessageAble(0, ''); data.readSequenceable(retmsg); }) .catch((callErr) => { @@ -550,9 +550,9 @@ release(): void; export default class MainAbility extends Ability { onWindowStageCreate(windowStage) { this.context.startAbilityByCall({ - bundleName: "com.example.myservice", - abilityName: "MainAbility", - deviceId: "" + bundleName: 'com.example.myservice', + abilityName: 'MainAbility', + deviceId: '' }).then((obj) => { caller = obj; try { @@ -591,9 +591,9 @@ release(): void; export default class MainAbility extends Ability { onWindowStageCreate(windowStage) { this.context.startAbilityByCall({ - bundleName: "com.example.myservice", - abilityName: "MainAbility", - deviceId: "" + bundleName: 'com.example.myservice', + abilityName: 'MainAbility', + deviceId: '' }).then((obj) => { caller = obj; try { @@ -645,8 +645,8 @@ on(method: string, callback: CalleeCallBack): void; ```ts import Ability from '@ohos.application.Ability'; class MyMessageAble{ - name:"" - str:"" + name:'' + str:'' num: 1 constructor(name, str) { this.name = name; @@ -668,9 +668,9 @@ on(method: string, callback: CalleeCallBack): void; let method = 'call_Function'; function funcCallBack(pdata) { console.log('Callee funcCallBack is called ' + pdata); - let msg = new MyMessageAble("test", ""); + let msg = new MyMessageAble('test', ''); pdata.readSequenceable(msg); - return new MyMessageAble("test1", "Callee test"); + return new MyMessageAble('test1', 'Callee test'); } export default class MainAbility extends Ability { onCreate(want, launchParam) { diff --git a/zh-cn/application-dev/reference/apis/js-apis-application-abilityDelegatorRegistry.md b/zh-cn/application-dev/reference/apis/js-apis-application-abilityDelegatorRegistry.md index 1d5a6b763f438966e57aa075085f47a6aa2b433e..c060055846b1fc9567c2365423bff44c0199a62c 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-application-abilityDelegatorRegistry.md +++ b/zh-cn/application-dev/reference/apis/js-apis-application-abilityDelegatorRegistry.md @@ -66,7 +66,7 @@ getArguments(): AbilityDelegatorArgs ```ts let args = AbilityDelegatorRegistry.getArguments(); -console.info("getArguments bundleName:" + args.bundleName); -console.info("getArguments testCaseNames:" + args.testCaseNames); -console.info("getArguments testRunnerClassName:" + args.testRunnerClassName); +console.info('getArguments bundleName:' + args.bundleName); +console.info('getArguments testCaseNames:' + args.testCaseNames); +console.info('getArguments testRunnerClassName:' + args.testRunnerClassName); ``` diff --git a/zh-cn/application-dev/reference/apis/js-apis-application-abilityLifecycleCallback.md b/zh-cn/application-dev/reference/apis/js-apis-application-abilityLifecycleCallback.md index ed03531bf9656276c822294678dac2f383978897..28d011e41aceefb70c7260fe5f08f243c9ce14cc 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-application-abilityLifecycleCallback.md +++ b/zh-cn/application-dev/reference/apis/js-apis-application-abilityLifecycleCallback.md @@ -11,7 +11,7 @@ AbilityLifecycleCallback模块提供应用上下文ApplicationContext的生命 ## 导入模块 ```ts -import AbilityLifecycleCallback from "@ohos.application.AbilityLifecycleCallback"; +import AbilityLifecycleCallback from '@ohos.application.AbilityLifecycleCallback'; ``` @@ -157,56 +157,56 @@ onAbilityContinue(ability: Ability): void; ```ts -import AbilityStage from "@ohos.application.AbilityStage"; +import AbilityStage from '@ohos.application.AbilityStage'; let lifecycleid; export default class MyAbilityStage extends AbilityStage { onCreate() { - console.log("MyAbilityStage onCreate") + console.log('MyAbilityStage onCreate') let AbilityLifecycleCallback = { onAbilityCreate(ability){ - console.log("AbilityLifecycleCallback onAbilityCreate ability:" + JSON.stringify(ability)); + console.log('AbilityLifecycleCallback onAbilityCreate ability:' + JSON.stringify(ability)); }, onWindowStageCreate(ability, windowStage){ - console.log("AbilityLifecycleCallback onWindowStageCreate ability:" + JSON.stringify(ability)); - console.log("AbilityLifecycleCallback onWindowStageCreate windowStage:" + JSON.stringify(windowStage)); + console.log('AbilityLifecycleCallback onWindowStageCreate ability:' + JSON.stringify(ability)); + console.log('AbilityLifecycleCallback onWindowStageCreate windowStage:' + JSON.stringify(windowStage)); }, onWindowStageActive(ability, windowStage){ - console.log("AbilityLifecycleCallback onWindowStageActive ability:" + JSON.stringify(ability)); - console.log("AbilityLifecycleCallback onWindowStageActive windowStage:" + JSON.stringify(windowStage)); + console.log('AbilityLifecycleCallback onWindowStageActive ability:' + JSON.stringify(ability)); + console.log('AbilityLifecycleCallback onWindowStageActive windowStage:' + JSON.stringify(windowStage)); }, onWindowStageInactive(ability, windowStage){ - console.log("AbilityLifecycleCallback onWindowStageInactive ability:" + JSON.stringify(ability)); - console.log("AbilityLifecycleCallback onWindowStageInactive windowStage:" + JSON.stringify(windowStage)); + console.log('AbilityLifecycleCallback onWindowStageInactive ability:' + JSON.stringify(ability)); + console.log('AbilityLifecycleCallback onWindowStageInactive windowStage:' + JSON.stringify(windowStage)); }, onWindowStageDestroy(ability, windowStage){ - console.log("AbilityLifecycleCallback onWindowStageDestroy ability:" + JSON.stringify(ability)); - console.log("AbilityLifecycleCallback onWindowStageDestroy windowStage:" + JSON.stringify(windowStage)); + console.log('AbilityLifecycleCallback onWindowStageDestroy ability:' + JSON.stringify(ability)); + console.log('AbilityLifecycleCallback onWindowStageDestroy windowStage:' + JSON.stringify(windowStage)); }, onAbilityDestroy(ability){ - console.log("AbilityLifecycleCallback onAbilityDestroy ability:" + JSON.stringify(ability)); + console.log('AbilityLifecycleCallback onAbilityDestroy ability:' + JSON.stringify(ability)); }, onAbilityForeground(ability){ - console.log("AbilityLifecycleCallback onAbilityForeground ability:" + JSON.stringify(ability)); + console.log('AbilityLifecycleCallback onAbilityForeground ability:' + JSON.stringify(ability)); }, onAbilityBackground(ability){ - console.log("AbilityLifecycleCallback onAbilityBackground ability:" + JSON.stringify(ability)); + console.log('AbilityLifecycleCallback onAbilityBackground ability:' + JSON.stringify(ability)); }, onAbilityContinue(ability){ - console.log("AbilityLifecycleCallback onAbilityContinue ability:" + JSON.stringify(ability)); + console.log('AbilityLifecycleCallback onAbilityContinue ability:' + JSON.stringify(ability)); } } // 1.通过context属性获取applicationContext let applicationContext = this.context.getApplicationContext(); // 2.通过applicationContext注册监听应用内生命周期 lifecycleid = applicationContext.registerAbilityLifecycleCallback(AbilityLifecycleCallback); - console.log("registerAbilityLifecycleCallback number: " + JSON.stringify(lifecycleid)); + console.log('registerAbilityLifecycleCallback number: ' + JSON.stringify(lifecycleid)); } onDestroy() { let applicationContext = this.context.getApplicationContext(); applicationContext.unregisterAbilityLifecycleCallback(lifecycleid, (error, data) => { - console.log("unregisterAbilityLifecycleCallback success, err: " + JSON.stringify(error)); + console.log('unregisterAbilityLifecycleCallback success, err: ' + JSON.stringify(error)); }); } } diff --git a/zh-cn/application-dev/reference/apis/js-apis-application-abilityManager.md b/zh-cn/application-dev/reference/apis/js-apis-application-abilityManager.md index cfd957798884eb47998a9dca6d1a3bebd0f618f3..ca431b5275e6c793c6823e5d3e929c29e21efcc6 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-application-abilityManager.md +++ b/zh-cn/application-dev/reference/apis/js-apis-application-abilityManager.md @@ -10,7 +10,7 @@ AbilityManager模块提供对Ability相关信息和状态信息进行获取、 ## 导入模块 ```ts -import AbilityManager from '@ohos.application.abilityManager' +import AbilityManager from '@ohos.application.abilityManager'; ``` ## AbilityState @@ -53,7 +53,7 @@ import abilitymanager from '@ohos.application.abilityManager'; let config = { language: 'chinese' -} +}; abilitymanager.updateConfiguration(config, () => { console.log('------------ updateConfiguration -----------'); @@ -89,7 +89,7 @@ import abilitymanager from '@ohos.application.abilityManager'; let config = { language: 'chinese' -} +}; abilitymanager.updateConfiguration(config).then(() => { console.log('updateConfiguration success'); @@ -146,8 +146,8 @@ getAbilityRunningInfos(): Promise\> import abilitymanager from '@ohos.application.abilityManager'; abilitymanager.getAbilityRunningInfos().then((data) => { - console.log("getAbilityRunningInfos data: " + JSON.stringify(data)) + console.log("getAbilityRunningInfos data: " + JSON.stringify(data)); }).catch((err) => { - console.log("getAbilityRunningInfos err: " + err) + console.log("getAbilityRunningInfos err: " + err); }); ``` \ No newline at end of file diff --git a/zh-cn/application-dev/reference/apis/js-apis-application-accessibilityExtensionAbility.md b/zh-cn/application-dev/reference/apis/js-apis-application-accessibilityExtensionAbility.md index ef6a02866bd167e79d6f7bd148403401b1daaec7..bb37534a86ff2831456083701d8fd21d39e1389a 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-application-accessibilityExtensionAbility.md +++ b/zh-cn/application-dev/reference/apis/js-apis-application-accessibilityExtensionAbility.md @@ -9,7 +9,7 @@ ## 导入模块 ```ts -import AccessibilityExtensionAbility from '@ohos.application.AccessibilityExtensionAbility' +import AccessibilityExtensionAbility from '@ohos.application.AccessibilityExtensionAbility'; ``` ## 属性 @@ -137,7 +137,7 @@ onAccessibilityEvent(event: AccessibilityEvent): void; class MyAccessibilityExtensionAbility extends AccessibilityExtensionAbility { onAccessibilityEvent(event) { console.log('AxExtensionAbility onAccessibilityEvent'); - if (event.eventType == 'click') { + if (event.eventType === 'click') { console.log('AxExtensionAbility onAccessibilityEvent: click'); } } @@ -164,7 +164,7 @@ onKeyEvent(keyEvent: KeyEvent): boolean; class MyAccessibilityExtensionAbility extends AccessibilityExtensionAbility { onKeyEvent(keyEvent) { console.log('AxExtensionAbility onKeyEvent'); - if (keyEvent.keyCode == 22) { + if (keyEvent.keyCode === 22) { console.log('AxExtensionAbility onKeyEvent: intercept 22'); return true; } diff --git a/zh-cn/application-dev/reference/apis/js-apis-application-appManager.md b/zh-cn/application-dev/reference/apis/js-apis-application-appManager.md index b90614f6931bb50cc4fe1057ed3e51f98201a20c..e39da5c1feab6201afa4ba68fdefcfcfefd0e8c7 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-application-appManager.md +++ b/zh-cn/application-dev/reference/apis/js-apis-application-appManager.md @@ -32,7 +32,7 @@ static isRunningInStabilityTest(callback: AsyncCallback<boolean>): void import app from '@ohos.application.appManager'; app.isRunningInStabilityTest((err, flag) => { console.log('startAbility result:' + JSON.stringify(err)); - }) + }); ``` @@ -106,7 +106,7 @@ isRamConstrainedDevice(callback: AsyncCallback\): void; app.isRamConstrainedDevice((err, data) => { console.log('startAbility result failed:' + JSON.stringify(err)); console.log('startAbility result success:' + JSON.stringify(data)); - }) + }); ``` ## appManager.getAppMemorySize @@ -153,7 +153,7 @@ getAppMemorySize(callback: AsyncCallback\): void; app.getAppMemorySize((err, data) => { console.log('startAbility result failed :' + JSON.stringify(err)); console.log('startAbility result success:' + JSON.stringify(data)); - }) + }); ``` ## appManager.getProcessRunningInfos(deprecated) @@ -258,7 +258,7 @@ getProcessRunningInformation(callback: AsyncCallback\ { console.log('startAbility result failed :' + JSON.stringify(err)); console.log('startAbility result success:' + JSON.stringify(data)); - }) + }); ``` ## appManager.registerApplicationStateObserver8+ @@ -298,7 +298,7 @@ registerApplicationStateObserver(observer: ApplicationStateObserver): number; onProcessStateChanged(processData) { console.log('------------ onProcessStateChanged -----------', processData); } - } + }; const observerCode = app.registerApplicationStateObserver(applicationStateObserver); console.log('-------- observerCode: ---------', observerCode); ``` @@ -341,7 +341,7 @@ registerApplicationStateObserver(observer: ApplicationStateObserver, bundleNameL onProcessStateChanged(processData) { console.log('------------ onProcessStateChanged -----------', processData); } - } + }; let bundleNameList = ['bundleName1', 'bundleName2']; const observerCode = app.registerApplicationStateObserver(applicationStateObserver, bundleNameList); console.log('-------- observerCode: ---------', observerCode); @@ -413,7 +413,7 @@ unregisterApplicationStateObserver(observerId: number): Promise\; }) .catch((err) => { console.log('----------- unregisterApplicationStateObserver fail ----------', err); - }) + }); ``` ## appManager.getForegroundApplications8+ @@ -474,7 +474,7 @@ getForegroundApplications(): Promise\>; }) .catch((err) => { console.log('--------- getForegroundApplications fail -------', err); - }) + }); ``` ## appManager.killProcessWithAccount8+ @@ -507,7 +507,7 @@ app.killProcessWithAccount(bundleName, accountId) }) .catch((err) => { console.log('------------ killProcessWithAccount fail ------------', err); - }) + }); ``` @@ -613,7 +613,7 @@ killProcessesByBundleName(bundleName: string): Promise\; }) .catch((err) => { console.log('------------ killProcessesByBundleName fail ------------', err); - }) + }); ``` ## appManager.clearUpApplicationData8+ @@ -683,5 +683,5 @@ clearUpApplicationData(bundleName: string): Promise\; }) .catch((err) => { console.log('------------ clearUpApplicationData fail ------------', err); - }) + }); ``` \ No newline at end of file diff --git a/zh-cn/application-dev/reference/apis/js-apis-application-configuration.md b/zh-cn/application-dev/reference/apis/js-apis-application-configuration.md index 1e4211c7b01b29f38829f231f2b9f054db71b47c..35e87b3c830976d2e596c5a6a4b1446533c843a4 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-application-configuration.md +++ b/zh-cn/application-dev/reference/apis/js-apis-application-configuration.md @@ -32,7 +32,7 @@ export default class MainAbility extends Ability { onWindowStageCreate(windowStage: Window.WindowStage) { let envCallback = { onConfigurationUpdated(config) { - console.info(`envCallback onConfigurationUpdated success: ${JSON.stringify(config)}`) + console.info(`envCallback onConfigurationUpdated success: ${JSON.stringify(config)}`); let language = config.language; let colorMode = config.colorMode; } diff --git a/zh-cn/application-dev/reference/apis/js-apis-application-dataShareExtensionAbility.md b/zh-cn/application-dev/reference/apis/js-apis-application-dataShareExtensionAbility.md index c3844b5182cca13b14e048ceb8144a3fdebb69a9..b13589178ab4ff55a44a90cf1fd65ac20ae44cdf 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-application-dataShareExtensionAbility.md +++ b/zh-cn/application-dev/reference/apis/js-apis-application-dataShareExtensionAbility.md @@ -14,7 +14,7 @@ ## 导入模块 ```ts -import DataShareExtensionAbility from '@ohos.application.DataShareExtensionAbility' +import DataShareExtensionAbility from '@ohos.application.DataShareExtensionAbility'; ``` ## uri命名规则 @@ -65,11 +65,11 @@ DataShare客户端连接DataShareExtensionAbility服务端时,服务端回调 ```ts import rdb from '@ohos.data.relationalStore'; -let DB_NAME = "DB00.db"; -let TBL_NAME = "TBL00"; -let DDL_TBL_CREATE = "CREATE TABLE IF NOT EXISTS " +let DB_NAME = 'DB00.db'; +let TBL_NAME = 'TBL00'; +let DDL_TBL_CREATE = 'CREATE TABLE IF NOT EXISTS ' + TBL_NAME - + " (id INTEGER PRIMARY KEY AUTOINCREMENT, name TEXT, age INTEGER, phoneNumber DOUBLE, isStudent BOOLEAN, Binary BINARY)"; + + ' (id INTEGER PRIMARY KEY AUTOINCREMENT, name TEXT, age INTEGER, phoneNumber DOUBLE, isStudent BOOLEAN, Binary BINARY)'; let rdbStore; export default class DataShareExtAbility extends DataShareExtensionAbility { @@ -112,22 +112,22 @@ insert?(uri: string, valueBucket: ValuesBucket, callback: AsyncCallback<numbe ```ts import rdb from '@ohos.data.relationalStore'; -let DB_NAME = "DB00.db"; -let TBL_NAME = "TBL00"; -let DDL_TBL_CREATE = "CREATE TABLE IF NOT EXISTS " +let DB_NAME = 'DB00.db'; +let TBL_NAME = 'TBL00'; +let DDL_TBL_CREATE = 'CREATE TABLE IF NOT EXISTS ' + TBL_NAME - + " (id INTEGER PRIMARY KEY AUTOINCREMENT, name TEXT, age INTEGER, phoneNumber DOUBLE, isStudent BOOLEAN, Binary BINARY)"; + + ' (id INTEGER PRIMARY KEY AUTOINCREMENT, name TEXT, age INTEGER, phoneNumber DOUBLE, isStudent BOOLEAN, Binary BINARY)'; let rdbStore; export default class DataShareExtAbility extends DataShareExtensionAbility { insert(uri, valueBucket, callback) { - if (valueBucket == null) { + if (valueBucket === null) { console.info('invalid valueBuckets'); return; } rdbStore.insert(TBL_NAME, valueBucket, function (err, ret) { console.info('callback ret:' + ret); - if (callback != undefined) { + if (callback !== undefined) { callback(err, ret); } }); @@ -157,20 +157,20 @@ update?(uri: string, predicates: dataSharePredicates.DataSharePredicates, valueB ```ts import rdb from '@ohos.data.relationalStore'; -let DB_NAME = "DB00.db"; -let TBL_NAME = "TBL00"; -let DDL_TBL_CREATE = "CREATE TABLE IF NOT EXISTS " +let DB_NAME = 'DB00.db'; +let TBL_NAME = 'TBL00'; +let DDL_TBL_CREATE = 'CREATE TABLE IF NOT EXISTS ' + TBL_NAME - + " (id INTEGER PRIMARY KEY AUTOINCREMENT, name TEXT, age INTEGER, phoneNumber DOUBLE, isStudent BOOLEAN, Binary BINARY)"; + + ' (id INTEGER PRIMARY KEY AUTOINCREMENT, name TEXT, age INTEGER, phoneNumber DOUBLE, isStudent BOOLEAN, Binary BINARY)'; let rdbStore; export default class DataShareExtAbility extends DataShareExtensionAbility { update(uri, predicates, valueBucket, callback) { - if (predicates == null || predicates == undefined) { + if (predicates === null || predicates === undefined) { return; } rdbStore.update(TBL_NAME, valueBucket, predicates, function (err, ret) { - if (callback != undefined) { + if (callback !== undefined) { callback(err, ret); } }); @@ -199,20 +199,20 @@ delete?(uri: string, predicates: dataSharePredicates.DataSharePredicates, callba ```ts import rdb from '@ohos.data.relationalStore'; -let DB_NAME = "DB00.db"; -let TBL_NAME = "TBL00"; -let DDL_TBL_CREATE = "CREATE TABLE IF NOT EXISTS " +let DB_NAME = 'DB00.db'; +let TBL_NAME = 'TBL00'; +let DDL_TBL_CREATE = 'CREATE TABLE IF NOT EXISTS ' + TBL_NAME - + " (id INTEGER PRIMARY KEY AUTOINCREMENT, name TEXT, age INTEGER, phoneNumber DOUBLE, isStudent BOOLEAN, Binary BINARY)"; + + ' (id INTEGER PRIMARY KEY AUTOINCREMENT, name TEXT, age INTEGER, phoneNumber DOUBLE, isStudent BOOLEAN, Binary BINARY)'; let rdbStore; export default class DataShareExtAbility extends DataShareExtensionAbility { delete(uri, predicates, callback) { - if (predicates == null || predicates == undefined) { + if (predicates === null || predicates === undefined) { return; } rdbStore.delete(TBL_NAME, predicates, function (err, ret) { - if (callback != undefined) { + if (callback !== undefined) { callback(err, ret); } }); @@ -242,23 +242,23 @@ query?(uri: string, predicates: dataSharePredicates.DataSharePredicates, columns ```ts import rdb from '@ohos.data.relationalStore'; -let DB_NAME = "DB00.db"; -let TBL_NAME = "TBL00"; -let DDL_TBL_CREATE = "CREATE TABLE IF NOT EXISTS " +let DB_NAME = 'DB00.db'; +let TBL_NAME = 'TBL00'; +let DDL_TBL_CREATE = 'CREATE TABLE IF NOT EXISTS ' + TBL_NAME - + " (id INTEGER PRIMARY KEY AUTOINCREMENT, name TEXT, age INTEGER, phoneNumber DOUBLE, isStudent BOOLEAN, Binary BINARY)"; + + ' (id INTEGER PRIMARY KEY AUTOINCREMENT, name TEXT, age INTEGER, phoneNumber DOUBLE, isStudent BOOLEAN, Binary BINARY)'; let rdbStore; export default class DataShareExtAbility extends DataShareExtensionAbility { query(uri, predicates, columns, callback) { - if (predicates == null || predicates == undefined) { + if (predicates === null || predicates === undefined) { return; } rdbStore.query(TBL_NAME, predicates, columns, function (err, resultSet) { - if (resultSet != undefined) { + if (resultSet !== undefined) { console.info('resultSet.rowCount: ' + resultSet.rowCount); } - if (callback != undefined) { + if (callback !== undefined) { callback(err, resultSet); } }); @@ -287,23 +287,23 @@ batchInsert?(uri: string, valueBuckets: Array<ValuesBucket>, callback: Asy ```ts import rdb from '@ohos.data.relationalStore'; -let DB_NAME = "DB00.db"; -let TBL_NAME = "TBL00"; -let DDL_TBL_CREATE = "CREATE TABLE IF NOT EXISTS " +let DB_NAME = 'DB00.db'; +let TBL_NAME = 'TBL00'; +let DDL_TBL_CREATE = 'CREATE TABLE IF NOT EXISTS ' + TBL_NAME - + " (id INTEGER PRIMARY KEY AUTOINCREMENT, name TEXT, age INTEGER, phoneNumber DOUBLE, isStudent BOOLEAN, Binary BINARY)"; + + ' (id INTEGER PRIMARY KEY AUTOINCREMENT, name TEXT, age INTEGER, phoneNumber DOUBLE, isStudent BOOLEAN, Binary BINARY)'; let rdbStore; export default class DataShareExtAbility extends DataShareExtensionAbility { batchInsert(uri, valueBuckets, callback) { - if (valueBuckets == null || valueBuckets.length == undefined) { + if (valueBuckets === null || valueBuckets.length === undefined) { console.info('invalid valueBuckets'); return; } - let resultNum = valueBuckets.length + let resultNum = valueBuckets.length; valueBuckets.forEach(vb => { rdbStore.insert(TBL_NAME, vb, function (err, ret) { - if (callback != undefined) { + if (callback !== undefined) { callback(err, resultNum); } }); @@ -332,8 +332,8 @@ normalizeUri?(uri: string, callback: AsyncCallback<string>): void ```ts export default class DataShareExtAbility extends DataShareExtensionAbility { normalizeUri(uri, callback) { - let err = {"code":0}; - let ret = "normalize+" + uri; + let err = {'code':0}; + let ret = 'normalize+' + uri; callback(err, ret); } }; @@ -359,8 +359,8 @@ denormalizeUri?(uri: string, callback: AsyncCallback<string>): void ```ts export default class DataShareExtAbility extends DataShareExtensionAbility { denormalizeUri(uri, callback) { - let err = {"code":0}; - let ret = "denormalize+" + uri; + let err = {'code':0}; + let ret = 'denormalize+' + uri; callback(err, ret); } }; diff --git a/zh-cn/application-dev/reference/apis/js-apis-application-environmentCallback.md b/zh-cn/application-dev/reference/apis/js-apis-application-environmentCallback.md index 00483e42a205167dcd62722f40c576a4e745e276..fabdcdd3cbc450530ff8bd5e01790354781e7cf2 100755 --- a/zh-cn/application-dev/reference/apis/js-apis-application-environmentCallback.md +++ b/zh-cn/application-dev/reference/apis/js-apis-application-environmentCallback.md @@ -11,7 +11,7 @@ EnvironmentCallback模块提供应用上下文ApplicationContext对系统环境 ## 导入模块 ```ts -import EnvironmentCallback from "@ohos.application.EnvironmentCallback"; +import EnvironmentCallback from '@ohos.application.EnvironmentCallback'; ``` @@ -33,29 +33,29 @@ onConfigurationUpdated(config: Configuration): void; ```ts -import Ability from "@ohos.application.Ability"; +import Ability from '@ohos.application.Ability'; let callbackId; export default class MyAbility extends Ability { onCreate() { - console.log("MyAbility onCreate") + console.log('MyAbility onCreate'); globalThis.applicationContext = this.context.getApplicationContext(); let EnvironmentCallback = { onConfigurationUpdated(config){ - console.log("onConfigurationUpdated config:" + JSON.stringify(config)); + console.log('onConfigurationUpdated config:' + JSON.stringify(config)); }, - } + }; // 1.获取applicationContext let applicationContext = globalThis.applicationContext; // 2.通过applicationContext注册监听应用内生命周期 callbackId = applicationContext.registerEnvironmentCallback(EnvironmentCallback); - console.log("registerEnvironmentCallback number: " + JSON.stringify(callbackId)); + console.log('registerEnvironmentCallback number: ' + JSON.stringify(callbackId)); } onDestroy() { let applicationContext = globalThis.applicationContext; applicationContext.unregisterEnvironmentCallback(callbackId, (error, data) => { - console.log("unregisterEnvironmentCallback success, err: " + JSON.stringify(error)); + console.log('unregisterEnvironmentCallback success, err: ' + JSON.stringify(error)); }); } } diff --git a/zh-cn/application-dev/reference/apis/js-apis-application-errorManager.md b/zh-cn/application-dev/reference/apis/js-apis-application-errorManager.md index f70378719e985d1f44f1c963b9cc83e773ffb9de..6741c39b527d174dc5b4fd480be3d51809b4ce80 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-application-errorManager.md +++ b/zh-cn/application-dev/reference/apis/js-apis-application-errorManager.md @@ -30,7 +30,7 @@ registerErrorObserver(observer: ErrorObserver): number; ```ts let observer = { onUnhandledException(errorMsg) { - console.log('onUnhandledException, errorMsg: ', errorMsg) + console.log('onUnhandledException, errorMsg: ', errorMsg); } } errorManager.registerErrorObserver(observer) @@ -95,6 +95,6 @@ errorManager.unregisterErrorObserver(observerId) }) .catch((err) => { console.log('----------- unregisterErrorObserver fail ----------', err); -}) +}); ``` \ No newline at end of file diff --git a/zh-cn/application-dev/reference/apis/js-apis-application-formBindingData.md b/zh-cn/application-dev/reference/apis/js-apis-application-formBindingData.md index 75dca031bbae7c6ebd325800839335a4d3495df9..d5530374881e3cdd23895360ff550e0469c6fa04 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-application-formBindingData.md +++ b/zh-cn/application-dev/reference/apis/js-apis-application-formBindingData.md @@ -35,7 +35,7 @@ createFormBindingData(obj?: Object | string): FormBindingData | 参数名 | 类型 | 必填 | 说明 | | ------ | -------------- | ---- | ------------------------------------------------------------ | -| obj | Object\|string | 否 | js卡片要展示的数据。可以是包含若干键值对的Object或者 json 格式的字符串。其中图片数据以"formImages"作为标识,内容为图片标识与图片文件描述符的键值对{"formImages": {"key1": fd1, "key2": fd2}} | +| obj | Object\|string | 否 | js卡片要展示的数据。可以是包含若干键值对的Object或者 json 格式的字符串。其中图片数据以'formImages'作为标识,内容为图片标识与图片文件描述符的键值对{'formImages': {'key1': fd1, 'key2': fd2}} | **返回值:** @@ -52,12 +52,12 @@ import featureAbility from '@ohos.ability.featureAbility'; import fileio from '@ohos.fileio'; let context=featureAbility.getContext(); context.getOrCreateLocalDir((err,data)=>{ - let path=data+"/xxx.jpg"; + let path=data+'/xxx.jpg'; let fd = fileio.openSync(path); let obj = { - "temperature": "21°", - "formImages": {"image": fd} + 'temperature': '21°', + 'formImages': {'image': fd} }; let formBindingDataObj = formBindingData.createFormBindingData(obj); -}) +}); ``` diff --git a/zh-cn/application-dev/reference/apis/js-apis-application-formHost.md b/zh-cn/application-dev/reference/apis/js-apis-application-formHost.md index 1badfbc1f6ebf92f5643f34377fced401ad0c102..466db099a179a3960bf4971192ba474016d5689b 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-application-formHost.md +++ b/zh-cn/application-dev/reference/apis/js-apis-application-formHost.md @@ -34,7 +34,7 @@ deleteForm(formId: string, callback: AsyncCallback<void>): void **示例:** ```ts -var formId = "12400633174999288"; +var formId = '12400633174999288'; formHost.deleteForm(formId, (error, data) => { if (error.code) { console.log('formHost deleteForm, error:' + JSON.stringify(error)); @@ -67,7 +67,7 @@ deleteForm(formId: string): Promise<void> **参数:** ```ts -var formId = "12400633174999288"; +var formId = '12400633174999288'; formHost.deleteForm(formId).then(() => { console.log('formHost deleteForm success'); }).catch((error) => { @@ -95,7 +95,7 @@ releaseForm(formId: string, callback: AsyncCallback<void>): void **示例:** ```ts -var formId = "12400633174999288"; +var formId = '12400633174999288'; formHost.releaseForm(formId, (error, data) => { if (error.code) { console.log('formHost releaseForm, error:' + JSON.stringify(error)); @@ -124,7 +124,7 @@ releaseForm(formId: string, isReleaseCache: boolean, callback: AsyncCallback< **示例:** ```ts -var formId = "12400633174999288"; +var formId = '12400633174999288'; formHost.releaseForm(formId, true, (error, data) => { if (error.code) { console.log('formHost releaseForm, error:' + JSON.stringify(error)); @@ -158,7 +158,7 @@ releaseForm(formId: string, isReleaseCache?: boolean): Promise<void> **示例:** ```ts -var formId = "12400633174999288"; +var formId = '12400633174999288'; formHost.releaseForm(formId, true).then(() => { console.log('formHost releaseForm success'); }).catch((error) => { @@ -186,7 +186,7 @@ requestForm(formId: string, callback: AsyncCallback<void>): void **示例:** ```ts -var formId = "12400633174999288"; +var formId = '12400633174999288'; formHost.requestForm(formId, (error, data) => { if (error.code) { console.log('formHost requestForm, error:' + JSON.stringify(error)); @@ -219,7 +219,7 @@ requestForm(formId: string): Promise<void> **示例:** ```ts -var formId = "12400633174999288"; +var formId = '12400633174999288'; formHost.requestForm(formId).then(() => { console.log('formHost requestForm success'); }).catch((error) => { @@ -247,7 +247,7 @@ castTempForm(formId: string, callback: AsyncCallback<void>): void **示例:** ```ts -var formId = "12400633174999288"; +var formId = '12400633174999288'; formHost.castTempForm(formId, (error, data) => { if (error.code) { console.log('formHost castTempForm, error:' + JSON.stringify(error)); @@ -280,7 +280,7 @@ castTempForm(formId: string): Promise<void> **示例:** ```ts -var formId = "12400633174999288"; +var formId = '12400633174999288'; formHost.castTempForm(formId).then(() => { console.log('formHost castTempForm success'); }).catch((error) => { @@ -308,7 +308,7 @@ notifyVisibleForms(formIds: Array<string>, callback: AsyncCallback<void **示例:** ```ts -var formId = ["12400633174999288"]; +var formId = ['12400633174999288']; formHost.notifyVisibleForms(formId, (error, data) => { if (error.code) { console.log('formHost notifyVisibleForms, error:' + JSON.stringify(error)); @@ -341,7 +341,7 @@ notifyVisibleForms(formIds: Array<string>): Promise<void> **示例:** ```ts -var formId = ["12400633174999288"]; +var formId = ['12400633174999288']; formHost.notifyVisibleForms(formId).then(() => { console.log('formHost notifyVisibleForms success'); }).catch((error) => { @@ -369,7 +369,7 @@ notifyInvisibleForms(formIds: Array<string>, callback: AsyncCallback<vo **示例:** ```ts -var formId = ["12400633174999288"]; +var formId = ['12400633174999288']; formHost.notifyInvisibleForms(formId, (error, data) => { if (error.code) { console.log('formHost notifyInvisibleForms, error:' + JSON.stringify(error)); @@ -402,7 +402,7 @@ notifyInvisibleForms(formIds: Array<string>): Promise<void> **示例:** ```ts -var formId = ["12400633174999288"]; +var formId = ['12400633174999288']; formHost.notifyInvisibleForms(formId).then(() => { console.log('formHost notifyInvisibleForms success'); }).catch((error) => { @@ -430,7 +430,7 @@ enableFormsUpdate(formIds: Array<string>, callback: AsyncCallback<void& **示例:** ```ts -var formId = ["12400633174999288"]; +var formId = ['12400633174999288']; formHost.enableFormsUpdate(formId, (error, data) => { if (error.code) { console.log('formHost enableFormsUpdate, error:' + JSON.stringify(error)); @@ -463,7 +463,7 @@ enableFormsUpdate(formIds: Array<string>): Promise<void> **示例:** ```ts -var formId = ["12400633174999288"]; +var formId = ['12400633174999288']; formHost.enableFormsUpdate(formId).then(() => { console.log('formHost enableFormsUpdate success'); }).catch((error) => { @@ -491,7 +491,7 @@ disableFormsUpdate(formIds: Array<string>, callback: AsyncCallback<void **示例:** ```ts -var formId = ["12400633174999288"]; +var formId = ['12400633174999288']; formHost.disableFormsUpdate(formId, (error, data) => { if (error.code) { console.log('formHost disableFormsUpdate, error:' + JSON.stringify(error)); @@ -524,7 +524,7 @@ disableFormsUpdate(formIds: Array<string>): Promise<void> **示例:** ```ts -var formId = ["12400633174999288"]; +var formId = ['12400633174999288']; formHost.disableFormsUpdate(formId).then(() => { console.log('formHost disableFormsUpdate success'); }).catch((error) => { @@ -549,7 +549,7 @@ isSystemReady(callback: AsyncCallback<void>): void **示例:** ```ts -var formId = "12400633174999288"; +var formId = '12400633174999288'; formHost.isSystemReady((error, data) => { if (error.code) { console.log('formHost isSystemReady, error:' + JSON.stringify(error)); @@ -574,7 +574,7 @@ isSystemReady(): Promise<void> **示例:** ```ts -var formId = "12400633174999288"; +var formId = '12400633174999288'; formHost.isSystemReady().then(() => { console.log('formHost isSystemReady success'); }).catch((error) => { @@ -656,7 +656,7 @@ getFormsInfo(bundleName: string, callback: AsyncCallback<Array<formInfo.Fo **示例:** ```ts -formHost.getFormsInfo("com.example.ohos.formjsdemo", (error, data) => { +formHost.getFormsInfo('com.example.ohos.formjsdemo', (error, data) => { if (error.code) { console.log('formHost getFormsInfo, error:' + JSON.stringify(error)); } else { @@ -686,7 +686,7 @@ getFormsInfo(bundleName: string, moduleName: string, callback: AsyncCallback< **示例:** ```ts -formHost.getFormsInfo("com.example.ohos.formjsdemo", "entry", (error, data) => { +formHost.getFormsInfo('com.example.ohos.formjsdemo', 'entry', (error, data) => { if (error.code) { console.log('formHost getFormsInfo, error:' + JSON.stringify(error)); } else { @@ -721,7 +721,7 @@ getFormsInfo(bundleName: string, moduleName?: string): Promise<Array<formI **示例:** ```ts - formHost.getFormsInfo("com.example.ohos.formjsdemo", "entry").then((data) => { + formHost.getFormsInfo('com.example.ohos.formjsdemo', 'entry').then((data) => { console.log('formHost getFormsInfo, data:' + JSON.stringify(data)); }).catch((error) => { console.log('formHost getFormsInfo, error:' + JSON.stringify(error)); @@ -748,7 +748,7 @@ deleteInvalidForms(formIds: Array<string>, callback: AsyncCallback<numb **示例:** ```ts -var formIds = new Array("12400633174999288", "12400633174999289"); +var formIds = new Array('12400633174999288', '12400633174999289'); formHost.deleteInvalidForms(formIds, (error, data) => { if (error.code) { console.log('formHost deleteInvalidForms, error:' + JSON.stringify(error)); @@ -783,7 +783,7 @@ deleteInvalidForms(formIds: Array<string>): Promise<number> **示例:** ```ts -var formIds = new Array("12400633174999288", "12400633174999289"); +var formIds = new Array('12400633174999288', '12400633174999289'); formHost.deleteInvalidForms(formIds).then((data) => { console.log('formHost deleteInvalidForms, data:' + JSON.stringify(data)); }).catch((error) => { @@ -812,13 +812,13 @@ acquireFormState(want: Want, callback: AsyncCallback<formInfo.FormStateInfo&g ```ts var want = { - "deviceId": "", - "bundleName": "ohos.samples.FormApplication", - "abilityName": "FormAbility", - "parameters": { - "ohos.extra.param.key.module_name": "entry", - "ohos.extra.param.key.form_name": "widget", - "ohos.extra.param.key.form_dimension": 2 + 'deviceId': '', + 'bundleName': 'ohos.samples.FormApplication', + 'abilityName': 'FormAbility', + 'parameters': { + 'ohos.extra.param.key.module_name': 'entry', + 'ohos.extra.param.key.form_name': 'widget', + 'ohos.extra.param.key.form_dimension': 2 } }; formHost.acquireFormState(want, (error, data) => { @@ -856,13 +856,13 @@ acquireFormState(want: Want): Promise<formInfo.FormStateInfo> ```ts var want = { - "deviceId": "", - "bundleName": "ohos.samples.FormApplication", - "abilityName": "FormAbility", - "parameters": { - "ohos.extra.param.key.module_name": "entry", - "ohos.extra.param.key.form_name": "widget", - "ohos.extra.param.key.form_dimension": 2 + 'deviceId': '', + 'bundleName': 'ohos.samples.FormApplication', + 'abilityName': 'FormAbility', + 'parameters': { + 'ohos.extra.param.key.module_name': 'entry', + 'ohos.extra.param.key.form_name': 'widget', + 'ohos.extra.param.key.form_dimension': 2 } }; formHost.acquireFormState(want).then((data) => { @@ -872,9 +872,9 @@ formHost.acquireFormState(want).then((data) => { }); ``` -## on("formUninstall") +## on('formUninstall') -on(type: "formUninstall", callback: Callback<string>): void +on(type: 'formUninstall', callback: Callback<string>): void 订阅卡片卸载事件。使用callback异步回调。 @@ -884,7 +884,7 @@ on(type: "formUninstall", callback: Callback<string>): void | 参数名 | 类型 | 必填 | 说明 | | ------ | ------ | ---- | ------- | -| type | string | 是 | 填写"formUninstall",表示卡片卸载事件。 | +| type | string | 是 | 填写'formUninstall',表示卡片卸载事件。 | | callback | Callback<string> | 是 | 回调函数。返回卡片标识。 | **示例:** @@ -893,12 +893,12 @@ on(type: "formUninstall", callback: Callback<string>): void let callback = function(formId) { console.log('formHost on formUninstall, formId:' + formId); } -formHost.on("formUninstall", callback); +formHost.on('formUninstall', callback); ``` -## off("formUninstall") +## off('formUninstall') -off(type: "formUninstall", callback?: Callback<string>): void +off(type: 'formUninstall', callback?: Callback<string>): void 取消订阅卡片卸载事件。使用callback异步回调。 @@ -908,7 +908,7 @@ off(type: "formUninstall", callback?: Callback<string>): void | 参数名 | 类型 | 必填 | 说明 | | ------ | ------ | ---- | ------- | -| type | string | 是 | 填写"formUninstall",表示卡片卸载事件。 | +| type | string | 是 | 填写'formUninstall',表示卡片卸载事件。 | | callback | Callback<string> | 否 | 回调函数。返回卡片标识。缺省时,表示注销所有已注册事件回调。 | **示例:** @@ -917,7 +917,7 @@ off(type: "formUninstall", callback?: Callback<string>): void let callback = function(formId) { console.log('formHost on formUninstall, formId:' + formId); } -formHost.off("formUninstall", callback); +formHost.off('formUninstall', callback); ``` ## notifyFormsVisible @@ -941,7 +941,7 @@ notifyFormsVisible(formIds: Array<string>, isVisible: boolean, callback: A **示例:** ```ts -var formIds = new Array("12400633174999288", "12400633174999289"); +var formIds = new Array('12400633174999288', '12400633174999289'); formHost.notifyFormsVisible(formIds, true, (error, data) => { if (error.code) { console.log('formHost notifyFormsVisible, error:' + JSON.stringify(error)); @@ -975,7 +975,7 @@ notifyFormsVisible(formIds: Array<string>, isVisible: boolean): Promise< **示例:** ```ts -var formIds = new Array("12400633174999288", "12400633174999289"); +var formIds = new Array('12400633174999288', '12400633174999289'); formHost.notifyFormsVisible(formIds, true).then(() => { console.log('formHost notifyFormsVisible success'); }).catch((error) => { @@ -1004,7 +1004,7 @@ notifyFormsEnableUpdate(formIds: Array<string>, isEnableUpdate: boolean, c **示例:** ```ts -var formIds = new Array("12400633174999288", "12400633174999289"); +var formIds = new Array('12400633174999288', '12400633174999289'); formHost.notifyFormsEnableUpdate(formIds, true, (error, data) => { if (error.code) { console.log('formHost notifyFormsEnableUpdate, error:' + JSON.stringify(error)); @@ -1038,7 +1038,7 @@ notifyFormsEnableUpdate(formIds: Array<string>, isEnableUpdate: boolean): **示例:** ```ts -var formIds = new Array("12400633174999288", "12400633174999289"); +var formIds = new Array('12400633174999288', '12400633174999289'); formHost.notifyFormsEnableUpdate(formIds, true).then(() => { console.log('formHost notifyFormsEnableUpdate success'); }).catch((error) => { @@ -1066,8 +1066,8 @@ shareForm(formId: string, deviceId: string, callback: AsyncCallback<void>) **示例:** ```ts -var formId = "12400633174999288"; -var deviceId = "EFC11C0C53628D8CC2F8CB5052477E130D075917034613B9884C55CD22B3DEF2"; +var formId = '12400633174999288'; +var deviceId = 'EFC11C0C53628D8CC2F8CB5052477E130D075917034613B9884C55CD22B3DEF2'; formHost.shareForm(formId, deviceId, (error, data) => { if (error.code) { console.log('formHost shareForm, error:' + JSON.stringify(error)); @@ -1101,8 +1101,8 @@ shareForm(formId: string, deviceId: string): Promise<void> **参数:** ```ts -var formId = "12400633174999288"; -var deviceId = "EFC11C0C53628D8CC2F8CB5052477E130D075917034613B9884C55CD22B3DEF2"; +var formId = '12400633174999288'; +var deviceId = 'EFC11C0C53628D8CC2F8CB5052477E130D075917034613B9884C55CD22B3DEF2'; formHost.shareForm(formId, deviceId).then(() => { console.log('formHost shareForm success'); }).catch((error) => { @@ -1126,7 +1126,7 @@ notifyFormsPrivacyProtected(formIds: Array\, isProtected: boolean, callb | deviceId | string | 是 | 远程设备标识。 | ```ts -var formIds = new Array("12400633174999288", "12400633174999289"); +var formIds = new Array('12400633174999288', '12400633174999289'); formHost.notifyFormsPrivacyProtected(formIds, true).then(() => { console.log('formHost shareForm success'); }).catch((error) => { diff --git a/zh-cn/application-dev/reference/apis/js-apis-application-formProvider.md b/zh-cn/application-dev/reference/apis/js-apis-application-formProvider.md index 82d3b764a9286ef10eb4107afee0365c13a1ef1b..20de7e5de0135fc1a975a17203e2aaf034b64602 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-application-formProvider.md +++ b/zh-cn/application-dev/reference/apis/js-apis-application-formProvider.md @@ -31,7 +31,7 @@ setFormNextRefreshTime(formId: string, minute: number, callback: AsyncCallback&l **示例:** ```ts - var formId = "12400633174999288"; + var formId = '12400633174999288'; formProvider.setFormNextRefreshTime(formId, 5, (error, data) => { if (error.code) { console.log('formProvider setFormNextRefreshTime, error:' + JSON.stringify(error)); @@ -63,7 +63,7 @@ setFormNextRefreshTime(formId: string, minute: number): Promise<void> **示例:** ```ts - var formId = "12400633174999288"; + var formId = '12400633174999288'; formProvider.setFormNextRefreshTime(formId, 5).then(() => { console.log('formProvider setFormNextRefreshTime success'); }).catch((error) => { @@ -91,8 +91,8 @@ updateForm(formId: string, formBindingData: formBindingData.FormBindingData,call ```ts import formBindingData from '@ohos.application.formBindingData'; - var formId = "12400633174999288"; - let obj = formBindingData.createFormBindingData({temperature:"22c", time:"22:00"}); + var formId = '12400633174999288'; + let obj = formBindingData.createFormBindingData({temperature:'22c', time:'22:00'}); formProvider.updateForm(formId, obj, (error, data) => { if (error.code) { console.log('formProvider updateForm, error:' + JSON.stringify(error)); @@ -125,8 +125,8 @@ updateForm(formId: string, formBindingData: formBindingData.FormBindingData): Pr ```ts import formBindingData from '@ohos.application.formBindingData'; - var formId = "12400633174999288"; - let obj = formBindingData.createFormBindingData({temperature:"22c", time:"22:00"}); + var formId = '12400633174999288'; + let obj = formBindingData.createFormBindingData({temperature:'22c', time:'22:00'}); formProvider.updateForm(formId, obj).then(() => { console.log('formProvider updateForm success'); }).catch((error) => { @@ -180,7 +180,7 @@ getFormsInfo(filter: formInfo.FormInfoFilter, callback: AsyncCallback<Array&l import formInfo from '@ohos.application.formInfo'; const filter : formInfo.FormInfoFilter = { // get info of forms belong to module entry. - moduleName : "entry" + moduleName : 'entry' }; formProvider.getFormsInfo(filter, (error, data) => { if (error.code) { @@ -217,7 +217,7 @@ getFormsInfo(filter?: formInfo.FormInfoFilter): Promise<Array<formInfo.For import formInfo from '@ohos.application.formInfo'; const filter : formInfo.FormInfoFilter = { // get info of forms belong to module entry. - moduleName : "entry" + moduleName : 'entry' }; formProvider.getFormsInfo(filter).then((data) => { console.log('formProvider getFormsInfo, data:' + JSON.stringify(data)); @@ -240,7 +240,7 @@ requestPublishForm(want: Want, formBindingData: formBindingData.FormBindingData, | 参数名 | 类型 | 必填 | 说明 | | ------ | ---------------------------------------------------------------------- | ---- | ---------------- | -| want | [Want](js-apis-application-want.md) | 是 | 发布请求。需包含以下字段。
abilityName: 目标卡片ability
parameters:
"ohos.extra.param.key.form_dimension"
"ohos.extra.param.key.form_name"
"ohos.extra.param.key.module_name" | +| want | [Want](js-apis-application-want.md) | 是 | 发布请求。需包含以下字段。
abilityName: 目标卡片ability
parameters:
'ohos.extra.param.key.form_dimension'
'ohos.extra.param.key.form_name'
'ohos.extra.param.key.module_name' | | formBindingData.FormBindingData | [FormBindingData](js-apis-application-formBindingData.md#formbindingdata) | 是 | 创建卡片的数据。 | | callback | AsyncCallback<string> | 是 | 回调函数。返回卡片标识。 | @@ -249,14 +249,14 @@ requestPublishForm(want: Want, formBindingData: formBindingData.FormBindingData, ```ts import formBindingData from '@ohos.application.formBindingData'; var want = { - abilityName: "FormAbility", + abilityName: 'FormAbility', parameters: { - "ohos.extra.param.key.form_dimension": 2, - "ohos.extra.param.key.form_name": "widget", - "ohos.extra.param.key.module_name": "entry" + 'ohos.extra.param.key.form_dimension': 2, + 'ohos.extra.param.key.form_name': 'widget', + 'ohos.extra.param.key.module_name': 'entry' } }; - let obj = formBindingData.createFormBindingData({temperature:"22c", time:"22:00"}); + let obj = formBindingData.createFormBindingData({temperature:'22c', time:'22:00'}); formProvider.requestPublishForm(want, obj, (error, data) => { if (error.code) { console.log('formProvider requestPublishForm, error: ' + JSON.stringify(error)); @@ -280,18 +280,18 @@ requestPublishForm(want: Want, callback: AsyncCallback<string>): void | 参数名 | 类型 | 必填 | 说明 | | -------- | ----------------------------------- | ---- | ------------------------------------------------------------ | -| want | [Want](js-apis-application-want.md) | 是 | 发布请求。需包含以下字段。
abilityName: 目标卡片ability
parameters:
"ohos.extra.param.key.form_dimension"
"ohos.extra.param.key.form_name"
"ohos.extra.param.key.module_name" | +| want | [Want](js-apis-application-want.md) | 是 | 发布请求。需包含以下字段。
abilityName: 目标卡片ability
parameters:
'ohos.extra.param.key.form_dimension'
'ohos.extra.param.key.form_name'
'ohos.extra.param.key.module_name' | | callback | AsyncCallback<string> | 是 | 回调函数。返回卡片标识。 | **示例:** ```ts var want = { - abilityName: "FormAbility", + abilityName: 'FormAbility', parameters: { - "ohos.extra.param.key.form_dimension": 2, - "ohos.extra.param.key.form_name": "widget", - "ohos.extra.param.key.module_name": "entry" + 'ohos.extra.param.key.form_dimension': 2, + 'ohos.extra.param.key.form_name': 'widget', + 'ohos.extra.param.key.module_name': 'entry' } }; formProvider.requestPublishForm(want, (error, data) => { @@ -317,7 +317,7 @@ requestPublishForm(want: Want, formBindingData?: formBindingData.FormBindingData | 参数名 | 类型 | 必填 | 说明 | | --------------- | ------------------------------------------------------------ | ---- | ------------------------------------------------------------ | -| want | [Want](js-apis-application-want.md) | 是 | 发布请求。需包含以下字段。
abilityName: 目标卡片ability
parameters:
"ohos.extra.param.key.form_dimension"
"ohos.extra.param.key.form_name"
"ohos.extra.param.key.module_name" | +| want | [Want](js-apis-application-want.md) | 是 | 发布请求。需包含以下字段。
abilityName: 目标卡片ability
parameters:
'ohos.extra.param.key.form_dimension'
'ohos.extra.param.key.form_name'
'ohos.extra.param.key.module_name' | | formBindingData.FormBindingData | [FormBindingData](js-apis-application-formBindingData.md#formbindingdata) | 否 | 创建卡片的数据。 | **返回值:** @@ -330,11 +330,11 @@ requestPublishForm(want: Want, formBindingData?: formBindingData.FormBindingData ```ts var want = { - abilityName: "FormAbility", + abilityName: 'FormAbility', parameters: { - "ohos.extra.param.key.form_dimension": 2, - "ohos.extra.param.key.form_name": "widget", - "ohos.extra.param.key.module_name": "entry" + 'ohos.extra.param.key.form_dimension': 2, + 'ohos.extra.param.key.form_name': 'widget', + 'ohos.extra.param.key.module_name': 'entry' } }; formProvider.requestPublishForm(want).then((data) => { @@ -369,11 +369,11 @@ formProvider.isRequestPublishFormSupported((error, isSupported) => { } else { if (isSupported) { var want = { - abilityName: "FormAbility", + abilityName: 'FormAbility', parameters: { - "ohos.extra.param.key.form_dimension": 2, - "ohos.extra.param.key.form_name": "widget", - "ohos.extra.param.key.module_name": "entry" + 'ohos.extra.param.key.form_dimension': 2, + 'ohos.extra.param.key.form_name': 'widget', + 'ohos.extra.param.key.module_name': 'entry' } }; formProvider.requestPublishForm(want, (error, data) => { @@ -410,11 +410,11 @@ isRequestPublishFormSupported(): Promise<boolean> formProvider.isRequestPublishFormSupported().then((isSupported) => { if (isSupported) { var want = { - abilityName: "FormAbility", + abilityName: 'FormAbility', parameters: { - "ohos.extra.param.key.form_dimension": 2, - "ohos.extra.param.key.form_name": "widget", - "ohos.extra.param.key.module_name": "entry" + 'ohos.extra.param.key.form_dimension': 2, + 'ohos.extra.param.key.form_name': 'widget', + 'ohos.extra.param.key.module_name': 'entry' } }; formProvider.requestPublishForm(want).then((data) => { diff --git a/zh-cn/application-dev/reference/apis/js-apis-application-missionManager.md b/zh-cn/application-dev/reference/apis/js-apis-application-missionManager.md index 39bf6bb3888af54ec793b06425ab3334beda3426..88a75e45c94742194f67b0642097657c75cee3e4 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-application-missionManager.md +++ b/zh-cn/application-dev/reference/apis/js-apis-application-missionManager.md @@ -9,7 +9,7 @@ missionManager模块提供系统任务管理能力,包括对系统任务执行 ## 导入模块 ```ts -import missionManager from '@ohos.application.missionManager' +import missionManager from '@ohos.application.missionManager'; ``` ## 权限列表 @@ -44,15 +44,15 @@ registerMissionListener(listener: MissionListener): number; ```ts let listener = { - onMissionCreated: function (mission) {console.log("--------onMissionCreated-------")}, - onMissionDestroyed: function (mission) {console.log("--------onMissionDestroyed-------")}, - onMissionSnapshotChanged: function (mission) {console.log("--------onMissionSnapshotChanged-------")}, - onMissionMovedToFront: function (mission) {console.log("--------onMissionMovedToFront-------")}, - onMissionIconUpdated: function (mission, icon) {console.log("--------onMissionIconUpdated-------")}, - onMissionClosed: function (mission) {console.log("--------onMissionClosed-------")}, - onMissionLabelUpdated: function (mission) {console.log("--------onMissionLabelUpdated-------")} + onMissionCreated: function (mission) {console.log('--------onMissionCreated-------');}, + onMissionDestroyed: function (mission) {console.log('--------onMissionDestroyed-------');}, + onMissionSnapshotChanged: function (mission) {console.log('--------onMissionSnapshotChanged-------');}, + onMissionMovedToFront: function (mission) {console.log('--------onMissionMovedToFront-------');}, + onMissionIconUpdated: function (mission, icon) {console.log('--------onMissionIconUpdated-------');}, + onMissionClosed: function (mission) {console.log('--------onMissionClosed-------');}, + onMissionLabelUpdated: function (mission) {console.log('--------onMissionLabelUpdated-------');} }; -console.log("registerMissionListener") +console.log('registerMissionListener'); let listenerid = missionManager.registerMissionListener(listener); ``` @@ -80,20 +80,20 @@ unregisterMissionListener(listenerId: number, callback: AsyncCallback<void> ```ts let listener = { - onMissionCreated: function (mission) {console.log("--------onMissionCreated-------")}, - onMissionDestroyed: function (mission) {console.log("--------onMissionDestroyed-------")}, - onMissionSnapshotChanged: function (mission) {console.log("--------onMissionSnapshotChanged-------")}, - onMissionMovedToFront: function (mission) {console.log("--------onMissionMovedToFront-------")}, - onMissionIconUpdated: function (mission, icon) {console.log("--------onMissionIconUpdated-------")}, - onMissionClosed: function (mission) {console.log("--------onMissionClosed-------")}, - onMissionLabelUpdated: function (mission) {console.log("--------onMissionLabelUpdated-------")} + onMissionCreated: function (mission) {console.log('--------onMissionCreated-------');}, + onMissionDestroyed: function (mission) {console.log('--------onMissionDestroyed-------');}, + onMissionSnapshotChanged: function (mission) {console.log('--------onMissionSnapshotChanged-------');}, + onMissionMovedToFront: function (mission) {console.log('--------onMissionMovedToFront-------');}, + onMissionIconUpdated: function (mission, icon) {console.log('--------onMissionIconUpdated-------');}, + onMissionClosed: function (mission) {console.log('--------onMissionClosed-------');}, + onMissionLabelUpdated: function (mission) {console.log('--------onMissionLabelUpdated-------');} }; - console.log("registerMissionListener") + console.log('registerMissionListener'); let listenerid = missionManager.registerMissionListener(listener); missionManager.unregisterMissionListener(listenerid, (error) => { - console.log("unregisterMissionListener"); - }) + console.log('unregisterMissionListener'); + }); ``` @@ -125,15 +125,15 @@ unregisterMissionListener(listenerId: number): Promise<void>; ```ts let listener = { - onMissionCreated: function (mission) {console.log("--------onMissionCreated-------")}, - onMissionDestroyed: function (mission) {console.log("--------onMissionDestroyed-------")}, - onMissionSnapshotChanged: function (mission) {console.log("--------onMissionSnapshotChanged-------")}, - onMissionMovedToFront: function (mission) {console.log("--------onMissionMovedToFront-------")}, - onMissionIconUpdated: function (mission, icon) {console.log("--------onMissionIconUpdated-------")}, - onMissionClosed: function (mission) {console.log("--------onMissionClosed-------")}, - onMissionLabelUpdated: function (mission) {console.log("--------onMissionLabelUpdated-------")} + onMissionCreated: function (mission) {console.log('--------onMissionCreated-------');}, + onMissionDestroyed: function (mission) {console.log('--------onMissionDestroyed-------');}, + onMissionSnapshotChanged: function (mission) {console.log('--------onMissionSnapshotChanged-------');}, + onMissionMovedToFront: function (mission) {console.log('--------onMissionMovedToFront-------');}, + onMissionIconUpdated: function (mission, icon) {console.log('--------onMissionIconUpdated-------');}, + onMissionClosed: function (mission) {console.log('--------onMissionClosed-------');}, + onMissionLabelUpdated: function (mission) {console.log('--------onMissionLabelUpdated-------');} }; - console.log("registerMissionListener") + console.log('registerMissionListener'); let listenerid = missionManager.registerMissionListener(listener); missionManager.unregisterMissionListener(listenerid).catch(function (err) { @@ -167,15 +167,15 @@ getMissionInfo(deviceId: string, missionId: number, callback: AsyncCallback<M ```ts import missionManager from '@ohos.application.missionManager' - let allMissions=missionManager.getMissionInfos("",10).catch(function(err){console.log(err);}); - missionManager.getMissionInfo("", allMissions[0].missionId, (error, mission) => { - console.log("getMissionInfo is called, error.code = " + error.code) - console.log("mission.missionId = " + mission.missionId); - console.log("mission.runningState = " + mission.runningState); - console.log("mission.lockedState = " + mission.lockedState); - console.log("mission.timestamp = " + mission.timestamp); - console.log("mission.label = " + mission.label); - console.log("mission.iconPath = " + mission.iconPath); + let allMissions=missionManager.getMissionInfos('',10).catch(function(err){console.log(err);}); + missionManager.getMissionInfo('', allMissions[0].missionId, (error, mission) => { + console.log('getMissionInfo is called, error.code = ' + error.code) + console.log('mission.missionId = ' + mission.missionId); + console.log('mission.runningState = ' + mission.runningState); + console.log('mission.lockedState = ' + mission.lockedState); + console.log('mission.timestamp = ' + mission.timestamp); + console.log('mission.label = ' + mission.label); + console.log('mission.iconPath = ' + mission.iconPath); }); ``` @@ -208,9 +208,9 @@ getMissionInfo(deviceId: string, missionId: number): Promise<MissionInfo>; **示例:** ```ts - import missionManager from '@ohos.application.missionManager' + import missionManager from '@ohos.application.missionManager'; - let mission = missionManager.getMissionInfo("", 10).catch(function (err){ + let mission = missionManager.getMissionInfo('', 10).catch(function (err){ console.log(err); }); ``` @@ -239,13 +239,13 @@ getMissionInfos(deviceId: string, numMax: number, callback: AsyncCallback<Arr **示例:** ```ts - import missionManager from '@ohos.application.missionManager' + import missionManager from '@ohos.application.missionManager'; - missionManager.getMissionInfos("", 10, (error, missions) => { - console.log("getMissionInfos is called, error.code = " + error.code); - console.log("size = " + missions.length); - console.log("missions = " + JSON.stringify(missions)); - }) + missionManager.getMissionInfos('', 10, (error, missions) => { + console.log('getMissionInfos is called, error.code = ' + error.code); + console.log('size = ' + missions.length); + console.log('missions = ' + JSON.stringify(missions)); + }); ``` @@ -277,9 +277,9 @@ getMissionInfos(deviceId: string, numMax: number): Promise<Array<MissionIn **示例:** ```ts - import missionManager from '@ohos.application.missionManager' + import missionManager from '@ohos.application.missionManager'; - let allMissions = missionManager.getMissionInfos("", 10).catch(function (err){ + let allMissions = missionManager.getMissionInfos('', 10).catch(function (err){ console.log(err); }); ``` @@ -308,19 +308,19 @@ getMissionSnapShot(deviceId: string, missionId: number, callback: AsyncCallback& **示例:** ```ts - import missionManager from '@ohos.application.missionManager' + import missionManager from '@ohos.application.missionManager'; - missionManager.getMissionInfos("", 10, (error, missions) => { - console.log("getMissionInfos is called, error.code = " + error.code); - console.log("size = " + missions.length); - console.log("missions = " + JSON.stringify(missions)); + missionManager.getMissionInfos('', 10, (error, missions) => { + console.log('getMissionInfos is called, error.code = ' + error.code); + console.log('size = ' + missions.length); + console.log('missions = ' + JSON.stringify(missions)); let id = missions[0].missionId; - missionManager.getMissionSnapShot("", id, (error, snapshot) => { - console.log("getMissionSnapShot is called, error.code = " + error.code); - console.log("bundleName = " + snapshot.ability.bundleName); - }) - }) + missionManager.getMissionSnapShot('', id, (error, snapshot) => { + console.log('getMissionSnapShot is called, error.code = ' + error.code); + console.log('bundleName = ' + snapshot.ability.bundleName); + }); + }); ``` @@ -352,17 +352,17 @@ getMissionSnapShot(deviceId: string, missionId: number): Promise<MissionSnaps **示例:** ```ts - import missionManager from '@ohos.application.missionManager' + import missionManager from '@ohos.application.missionManager'; let allMissions; - missionManager.getMissionInfos("",10).then(function(res){ + missionManager.getMissionInfos('',10).then(function(res){ allMissions=res; }).catch(function(err){console.log(err);}); - console.log("size = " + allMissions.length); - console.log("missions = " + JSON.stringify(allMissions)); + console.log('size = ' + allMissions.length); + console.log('missions = ' + JSON.stringify(allMissions)); let id = allMissions[0].missionId; - let snapshot = missionManager.getMissionSnapShot("", id).catch(function (err){ + let snapshot = missionManager.getMissionSnapShot('', id).catch(function (err){ console.log(err); }); ``` @@ -390,19 +390,19 @@ getLowResolutionMissionSnapShot(deviceId: string, missionId: number, callback: A **示例:** ```ts - import missionManager from '@ohos.application.missionManager' + import missionManager from '@ohos.application.missionManager'; - missionManager.getMissionInfos("", 10, (error, missions) => { - console.log("getMissionInfos is called, error.code = " + error.code); - console.log("size = " + missions.length); - console.log("missions = " + JSON.stringify(missions)); + missionManager.getMissionInfos('', 10, (error, missions) => { + console.log('getMissionInfos is called, error.code = ' + error.code); + console.log('size = ' + missions.length); + console.log('missions = ' + JSON.stringify(missions)); let id = missions[0].missionId; - missionManager.getLowResolutionMissionSnapShot("", id, (error, snapshot) => { - console.log("getLowResolutionMissionSnapShot is called, error.code = " + error.code); - console.log("bundleName = " + snapshot.ability.bundleName); - }) - }) + missionManager.getLowResolutionMissionSnapShot('', id, (error, snapshot) => { + console.log('getLowResolutionMissionSnapShot is called, error.code = ' + error.code); + console.log('bundleName = ' + snapshot.ability.bundleName); + }); + }); ``` @@ -434,17 +434,17 @@ getLowResolutionMissionSnapShot(deviceId: string, missionId: number): Promise\ { - console.log("getMissionInfos is called, error.code = " + error.code); - console.log("size = " + missions.length); - console.log("missions = " + JSON.stringify(missions)); + missionManager.getMissionInfos('', 10, (error, missions) => { + console.log('getMissionInfos is called, error.code = ' + error.code); + console.log('size = ' + missions.length); + console.log('missions = ' + JSON.stringify(missions)); let id = missions[0].missionId; missionManager.lockMission(id).then(() => { - console.log("lockMission is called "); + console.log('lockMission is called '); }); }); ``` @@ -514,13 +514,13 @@ lockMission(missionId: number): Promise<void>; **示例:** ```ts - import missionManager from '@ohos.application.missionManager' + import missionManager from '@ohos.application.missionManager'; let allMissions; - missionManager.getMissionInfos("",10).then(function(res){ + missionManager.getMissionInfos('',10).then(function(res){ allMissions=res; }).catch(function(err){console.log(err);}); - console.log("size = " + allMissions.length); - console.log("missions = " + JSON.stringify(allMissions)); + console.log('size = ' + allMissions.length); + console.log('missions = ' + JSON.stringify(allMissions)); let id = allMissions[0].missionId; missionManager.lockMission(id).catch(function (err){ @@ -551,16 +551,16 @@ unlockMission(missionId: number, callback: AsyncCallback<void>): void; **示例:** ```ts - import missionManager from '@ohos.application.missionManager' + import missionManager from '@ohos.application.missionManager'; - missionManager.getMissionInfos("", 10, (error, missions) => { - console.log("getMissionInfos is called, error.code = " + error.code); - console.log("size = " + missions.length); - console.log("missions = " + JSON.stringify(missions)); + missionManager.getMissionInfos('', 10, (error, missions) => { + console.log('getMissionInfos is called, error.code = ' + error.code); + console.log('size = ' + missions.length); + console.log('missions = ' + JSON.stringify(missions)); let id = missions[0].missionId; missionManager.unlockMission(id).then(() => { - console.log("unlockMission is called "); + console.log('unlockMission is called '); }); }); ``` @@ -593,14 +593,14 @@ unlockMission(missionId: number): Promise<void>; **示例:** ```ts - import missionManager from '@ohos.application.missionManager' + import missionManager from '@ohos.application.missionManager'; let allMissions; - missionManager.getMissionInfos("",10).then(function(res){ + missionManager.getMissionInfos('',10).then(function(res){ allMissions=res; }).catch(function(err){console.log(err);}); - console.log("size = " + allMissions.length); - console.log("missions = " + JSON.stringify(allMissions)); + console.log('size = ' + allMissions.length); + console.log('missions = ' + JSON.stringify(allMissions)); let id = allMissions[0].missionId; missionManager.lockMission(id).catch(function (err){ @@ -634,16 +634,16 @@ clearMission(missionId: number, callback: AsyncCallback<void>): void; **示例:** ```ts - import missionManager from '@ohos.application.missionManager' + import missionManager from '@ohos.application.missionManager'; - missionManager.getMissionInfos("", 10, (error, missions) => { - console.log("getMissionInfos is called, error.code = " + error.code); - console.log("size = " + missions.length); - console.log("missions = " + JSON.stringify(missions)); + missionManager.getMissionInfos('', 10, (error, missions) => { + console.log('getMissionInfos is called, error.code = ' + error.code); + console.log('size = ' + missions.length); + console.log('missions = ' + JSON.stringify(missions)); let id = missions[0].missionId; missionManager.clearMission(id).then(() => { - console.log("clearMission is called "); + console.log('clearMission is called '); }); }); ``` @@ -676,14 +676,14 @@ clearMission(missionId: number): Promise<void>; **示例:** ```ts - import missionManager from '@ohos.application.missionManager' + import missionManager from '@ohos.application.missionManager'; let allMissions; - missionManager.getMissionInfos("",10).then(function(res){ + missionManager.getMissionInfos('',10).then(function(res){ allMissions=res; }).catch(function(err){console.log(err);}); - console.log("size = " + allMissions.length); - console.log("missions = " + JSON.stringify(allMissions)); + console.log('size = ' + allMissions.length); + console.log('missions = ' + JSON.stringify(allMissions)); let id = allMissions[0].missionId; missionManager.clearMission(id).catch(function (err){ @@ -707,10 +707,10 @@ clearAllMissions(callback: AsyncCallback<void>): void; **示例:** ```ts - import missionManager from '@ohos.application.missionManager' + import missionManager from '@ohos.application.missionManager'; missionManager.clearAllMissions().then(() => { - console.log("clearAllMissions is called "); + console.log('clearAllMissions is called '); }); ``` @@ -736,7 +736,7 @@ clearAllMissions(): Promise<void>; **示例:** ```ts - import missionManager from '@ohos.application.missionManager' + import missionManager from '@ohos.application.missionManager'; missionManager.clearAllMissions().catch(function (err){ console.log(err); }); @@ -765,16 +765,16 @@ moveMissionToFront(missionId: number, callback: AsyncCallback<void>): void **示例:** ```ts - import missionManager from '@ohos.application.missionManager' + import missionManager from '@ohos.application.missionManager'; - missionManager.getMissionInfos("", 10, (error, missions) => { - console.log("getMissionInfos is called, error.code = " + error.code); - console.log("size = " + missions.length); - console.log("missions = " + JSON.stringify(missions)); + missionManager.getMissionInfos('', 10, (error, missions) => { + console.log('getMissionInfos is called, error.code = ' + error.code); + console.log('size = ' + missions.length); + console.log('missions = ' + JSON.stringify(missions)); let id = missions[0].missionId; missionManager.moveMissionToFront(id).then(() => { - console.log("moveMissionToFront is called "); + console.log('moveMissionToFront is called '); }); }); ``` @@ -803,16 +803,16 @@ moveMissionToFront(missionId: number, options: StartOptions, callback: AsyncCall **示例:** ```ts - import missionManager from '@ohos.application.missionManager' + import missionManager from '@ohos.application.missionManager'; - missionManager.getMissionInfos("", 10, (error, missions) => { - console.log("getMissionInfos is called, error.code = " + error.code); - console.log("size = " + missions.length); - console.log("missions = " + JSON.stringify(missions)); + missionManager.getMissionInfos('', 10, (error, missions) => { + console.log('getMissionInfos is called, error.code = ' + error.code); + console.log('size = ' + missions.length); + console.log('missions = ' + JSON.stringify(missions)); let id = missions[0].missionId; missionManager.moveMissionToFront(id,{windowMode : 101}).then(() => { - console.log("moveMissionToFront is called "); + console.log('moveMissionToFront is called '); }); }); ``` @@ -846,14 +846,14 @@ moveMissionToFront(missionId: number, options?: StartOptions): Promise<void&g **示例:** ```ts - import missionManager from '@ohos.application.missionManager' + import missionManager from '@ohos.application.missionManager'; let allMissions; - missionManager.getMissionInfos("",10).then(function(res){ + missionManager.getMissionInfos('',10).then(function(res){ allMissions=res; }).catch(function(err){console.log(err);}); - console.log("size = " + allMissions.length); - console.log("missions = " + JSON.stringify(allMissions)); + console.log('size = ' + allMissions.length); + console.log('missions = ' + JSON.stringify(allMissions)); let id = allMissions[0].missionId; missionManager.moveMissionToFront(id).catch(function (err){ diff --git a/zh-cn/application-dev/reference/apis/js-apis-application-staticSubscriberExtensionAbility.md b/zh-cn/application-dev/reference/apis/js-apis-application-staticSubscriberExtensionAbility.md index db27ea9695657671148f45f203201f4095180466..aeb4b0c9f875d981210c587d3ca23af90817b44f 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-application-staticSubscriberExtensionAbility.md +++ b/zh-cn/application-dev/reference/apis/js-apis-application-staticSubscriberExtensionAbility.md @@ -9,7 +9,7 @@ StaticSubscriberExtensionAbility模块提供静态订阅者ExtensionAbility的 ## 导入模块 ```ts -import StaticSubscriberExtensionAbility from '@ohos.application.StaticSubscriberExtensionAbility' +import StaticSubscriberExtensionAbility from '@ohos.application.StaticSubscriberExtensionAbility'; ``` ## StaticSubscriberExtensionAbility.onReceiveEvent @@ -33,7 +33,7 @@ onReceiveEvent(event: CommonEventData): void; ```ts class MyStaticSubscriberExtensionAbility extends StaticSubscriberExtensionAbility { onReceiveEvent(event) { - console.log("onReceiveEvent, event: " + JSON.stringify(event)) + console.log('onReceiveEvent, event: ' + JSON.stringify(event)); } } ``` \ No newline at end of file diff --git a/zh-cn/application-dev/reference/apis/js-apis-application-testRunner.md b/zh-cn/application-dev/reference/apis/js-apis-application-testRunner.md index 89facd58dceb73394ddd15e8a81f9a9820e82d86..452a1cf96e3829bd278bebdf434561ca390abb54 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-application-testRunner.md +++ b/zh-cn/application-dev/reference/apis/js-apis-application-testRunner.md @@ -11,7 +11,7 @@ TestRunner模块提供了框架测试的能力。包括准备单元测试环境 ## 导入模块 ```ts -import TestRunner from '@ohos.application.testRunner' +import TestRunner from '@ohos.application.testRunner'; ``` ## TestRunner.onPrepare @@ -27,7 +27,7 @@ onPrepare(): void ```ts export default class UserTestRunner implements TestRunner { onPrepare() { - console.log("Trigger onPrepare") + console.log('Trigger onPrepare'); } onRun() {} }; @@ -49,7 +49,7 @@ onRun(): void export default class UserTestRunner implements TestRunner { onPrepare() {} onRun() { - console.log("Trigger onRun") + console.log('Trigger onRun'); } }; ``` diff --git a/zh-cn/application-dev/reference/apis/js-apis-application-want.md b/zh-cn/application-dev/reference/apis/js-apis-application-want.md index 63c9523e66a7cc67b9483aef3b0a4e2a9b713a9a..7845337de12dfe49d9a609946c703c1479dedf56 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-application-want.md +++ b/zh-cn/application-dev/reference/apis/js-apis-application-want.md @@ -22,7 +22,7 @@ import Want from '@ohos.application.Want'; | bundleName | string | 否 | 表示包描述。如果在Want中同时指定了BundleName和AbilityName,则Want可以直接匹配到指定的Ability。 | | abilityName | string | 否 | 表示待启动的Ability名称。如果在Want中该字段同时指定了BundleName和AbilityName,则Want可以直接匹配到指定的Ability。AbilityName需要在一个应用的范围内保证唯一。 | | uri | string | 否 | 表示Uri描述。如果在Want中指定了Uri,则Want将匹配指定的Uri信息,包括scheme, schemeSpecificPart, authority和path信息。 | -| type | string | 否 | 表示MIME type类型描述,打开文件的类型,主要用于文管打开文件。比如:"text/xml" 、 "image/*"等,MIME定义参考:https://www.iana.org/assignments/media-types/media-types.xhtml?utm_source=ld246.com。 | +| type | string | 否 | 表示MIME type类型描述,打开文件的类型,主要用于文管打开文件。比如:'text/xml' 、 'image/*'等,MIME定义参考:https://www.iana.org/assignments/media-types/media-types.xhtml?utm_source=ld246.com。 | | flags | number | 否 | 表示处理Want的方式。默认传数字,具体参考:[flags说明](js-apis-ability-wantConstant.md#wantConstant.Flags)。 | | action | string | 否 | 表示要执行的通用操作(如:查看、分享、应用详情)。在隐式Want中,您可以定义该字段,配合uri或parameters来表示对数据要执行的操作。 | | parameters | {[key: string]: any} | 否 | 表示WantParams描述,由开发者自行决定传入的键值对。默认会携带以下key值:
ohos.aafwk.callerPid 表示拉起方的pid。
ohos.aafwk.param.callerToken 表示拉起方的token。
ohos.aafwk.param.callerUid 表示[bundleInfo](js-apis-bundle-BundleInfo.md#bundleinfo-1)中的uid,应用包里应用程序的uid。
- component.startup.newRules:表示是否启用新的管控规则。
- moduleName:表示拉起方的模块名,该字段的值即使定义成其他字符串,在传递到另一端时会被修改为正确的值。
- ohos.dlp.params.sandbox:表示dlp文件才会有。 | | @@ -35,15 +35,15 @@ import Want from '@ohos.application.Want'; ```ts var want = { - "deviceId": "", // deviceId为空表示本设备 - "bundleName": "com.extreme.test", - "abilityName": "MainAbility", - "moduleName": "entry" // moduleName非必选 + 'deviceId': '', // deviceId为空表示本设备 + 'bundleName': 'com.extreme.test', + 'abilityName': 'MainAbility', + 'moduleName': 'entry' // moduleName非必选 }; this.context.startAbility(want, (error) => { // 显式拉起Ability,通过bundleName、abilityName和moduleName可以唯一确定一个Ability - console.log("error.code = " + error.code) - }) + console.log('error.code = ' + error.code) + }); ``` - 通过自定字段传递数据, 以下为当前支持类型。 @@ -51,84 +51,84 @@ import Want from '@ohos.application.Want'; * 字符串(String) ```ts let want = { - bundleName: "com.example.demo", - abilityName: "com.example.demo.MainAbility", + bundleName: 'com.example.demo', + abilityName: 'com.example.demo.MainAbility', parameters: { - keyForString: "str", + keyForString: 'str', }, - } + }; ``` * 数字(Number) ```ts let want = { - bundleName: "com.example.demo", - abilityName: "com.example.demo.MainAbility", + bundleName: 'com.example.demo', + abilityName: 'com.example.demo.MainAbility', parameters: { keyForInt: 100, keyForDouble: 99.99, }, - } + }; ``` * 布尔(Boolean) ```ts let want = { - bundleName: "com.example.demo", - abilityName: "com.example.demo.MainAbility", + bundleName: 'com.example.demo', + abilityName: 'com.example.demo.MainAbility', parameters: { keyForBool: true, }, - } + }; ``` * 对象(Object) ```ts let want = { - bundleName: "com.example.demo", - abilityName: "com.example.demo.MainAbility", + bundleName: 'com.example.demo', + abilityName: 'com.example.demo.MainAbility', parameters: { keyForObject: { - keyForObjectString: "str", + keyForObjectString: 'str', keyForObjectInt: -200, keyForObjectDouble: 35.5, keyForObjectBool: false, }, }, - } + }; ``` * 数组(Array) ```ts let want = { - bundleName: "com.example.demo", - abilityName: "com.example.demo.MainAbility", + bundleName: 'com.example.demo', + abilityName: 'com.example.demo.MainAbility', parameters: { - keyForArrayString: ["str1", "str2", "str3"], + keyForArrayString: ['str1', 'str2', 'str3'], keyForArrayInt: [100, 200, 300, 400], keyForArrayDouble: [0.1, 0.2], - keyForArrayObject: [{obj1: "aaa"}, {obj2: 100}], + keyForArrayObject: [{obj1: 'aaa'}, {obj2: 100}], }, - } + }; ``` * 文件描述符(FD) ```ts import fileio from '@ohos.fileio'; var fd; try { - fd = fileio.openSync("/data/storage/el2/base/haps/pic.png"); + fd = fileio.openSync('/data/storage/el2/base/haps/pic.png'); } catch(e) { - console.log("openSync fail:" + JSON.stringify(e)); + console.log('openSync fail:' + JSON.stringify(e)); } var want = { - "deviceId": "", // deviceId为空表示本设备 - "bundleName": "com.extreme.test", - "abilityName": "MainAbility", - "moduleName": "entry", // moduleName非必选 - "parameters": { - "keyFd":{"type":"FD", "value":fd} + 'deviceId': '', // deviceId为空表示本设备 + 'bundleName': 'com.extreme.test', + 'abilityName': 'MainAbility', + 'moduleName': 'entry', // moduleName非必选 + 'parameters': { + 'keyFd':{'type':'FD', 'value':fd} } }; this.context.startAbility(want, (error) => { // 显式拉起Ability,通过bundleName、abilityName和moduleName可以唯一确定一个Ability - console.log("error.code = " + error.code) - }) + console.log('error.code = ' + error.code) + }); ``` \ No newline at end of file diff --git a/zh-cn/application-dev/reference/apis/js-apis-inner-ability-connectOptions.md b/zh-cn/application-dev/reference/apis/js-apis-inner-ability-connectOptions.md index 23c699c61844ce162f0f2cce48305b5dfe0aab35..8e08638fac68ba5e8f85406803d9b215789f59f0 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-inner-ability-connectOptions.md +++ b/zh-cn/application-dev/reference/apis/js-apis-inner-ability-connectOptions.md @@ -14,8 +14,8 @@ ```ts let want = { - bundleName: "com.example.myapp", - abilityName: "MyAbility" + bundleName: 'com.example.myapp', + abilityName: 'MyAbility' }; let connectOptions = { @@ -28,7 +28,7 @@ onFailed(code) { console.error('onFailed code: ' + code); } - } + }; let connection = this.context.connectAbility(want, connectOptions); ``` \ No newline at end of file diff --git a/zh-cn/application-dev/reference/apis/js-apis-inner-ability-dataAbilityHelper.md b/zh-cn/application-dev/reference/apis/js-apis-inner-ability-dataAbilityHelper.md index 82d495b626a03a28d0b2911fe44d573df0402fe1..95098d3299d23b8daf191fdcc14e7b3fdacb7d98 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-inner-ability-dataAbilityHelper.md +++ b/zh-cn/application-dev/reference/apis/js-apis-inner-ability-dataAbilityHelper.md @@ -11,8 +11,8 @@ 使用前根据具体情况引入如下模块 ```ts -import ohos_data_ability from '@ohos.data.dataAbility' -import ohos_data_rdb from '@ohos.data.rdb' +import ohos_data_ability from '@ohos.data.dataAbility'; +import ohos_data_rdb from '@ohos.data.rdb'; ``` ## DataAbilityHelper.openFile @@ -34,13 +34,13 @@ openFile(uri: string, mode: string, callback: AsyncCallback\): void **示例:** ```ts -import featureAbility from '@ohos.ability.featureAbility' +import featureAbility from '@ohos.ability.featureAbility'; let DAHelper = featureAbility.acquireDataAbilityHelper( - "dataability:///com.example.DataAbility" + 'dataability:///com.example.DataAbility' ); -let mode = "rwt"; -DAHelper.openFile("dataability:///com.example.DataAbility", mode, (err) => { - console.info("==========================>Called=======================>"); +let mode = 'rwt'; +DAHelper.openFile('dataability:///com.example.DataAbility', mode, (err) => { + console.info('==========================>Called=======================>'); }); ``` @@ -68,13 +68,13 @@ openFile(uri: string, mode: string): Promise\ **示例:** ```ts -import featureAbility from '@ohos.ability.featureAbility' +import featureAbility from '@ohos.ability.featureAbility'; let DAHelper = featureAbility.acquireDataAbilityHelper( - "dataability:///com.example.DataAbility" + 'dataability:///com.example.DataAbility' ); -let mode = "rwt"; -DAHelper.openFile("dataability:///com.example.DataAbility", mode).then((data) => { - console.info("==========================>openFileCallback=======================>"); +let mode = 'rwt'; +DAHelper.openFile('dataability:///com.example.DataAbility', mode).then((data) => { + console.info('==========================>openFileCallback=======================>'); }); ``` @@ -97,18 +97,18 @@ on(type: 'dataChange', uri: string, callback: AsyncCallback\): void **示例:** ```ts -import featureAbility from '@ohos.ability.featureAbility' +import featureAbility from '@ohos.ability.featureAbility'; let helper = featureAbility.acquireDataAbilityHelper( - "dataability:///com.example.DataAbility" + 'dataability:///com.example.DataAbility' ); function onChangeNotify() { - console.info("==========================>onChangeNotify=======================>"); + console.info('==========================>onChangeNotify=======================>'); }; helper.on( - "dataChange", - "dataability:///com.example.DataAbility", + 'dataChange', + 'dataability:///com.example.DataAbility', onChangeNotify -) +); ``` ## DataAbilityHelper.off @@ -130,22 +130,22 @@ off(type: 'dataChange', uri: string, callback?: AsyncCallback\): void **示例:** ```ts -import featureAbility from '@ohos.ability.featureAbility' +import featureAbility from '@ohos.ability.featureAbility'; let helper = featureAbility.acquireDataAbilityHelper( - "dataability:///com.example.DataAbility" + 'dataability:///com.example.DataAbility' ); function onChangeNotify() { - console.info("==========================>onChangeNotify=======================>"); + console.info('==========================>onChangeNotify=======================>'); }; helper.off( - "dataChange", - "dataability:///com.example.DataAbility", -) + 'dataChange', + 'dataability:///com.example.DataAbility', +); helper.off( - "dataChange", - "dataability:///com.example.DataAbility", + 'dataChange', + 'dataability:///com.example.DataAbility', onChangeNotify -) +); ``` ## DataAbilityHelper.getType @@ -166,12 +166,12 @@ getType(uri: string, callback: AsyncCallback\): void **示例:** ```ts -import featureAbility from '@ohos.ability.featureAbility' +import featureAbility from '@ohos.ability.featureAbility'; let DAHelper = featureAbility.acquireDataAbilityHelper( - "dataability:///com.example.DataAbility" + 'dataability:///com.example.DataAbility' ); -DAHelper.getType("dataability:///com.example.DataAbility", (err, data) => { - console.info("==========================>Called=======================>"); +DAHelper.getType('dataability:///com.example.DataAbility', (err, data) => { + console.info('==========================>Called=======================>'); }); ``` @@ -198,12 +198,12 @@ getType(uri: string): Promise\ **示例:** ```ts -import featureAbility from '@ohos.ability.featureAbility' +import featureAbility from '@ohos.ability.featureAbility'; let DAHelper = featureAbility.acquireDataAbilityHelper( - "dataability:///com.example.DataAbility" + 'dataability:///com.example.DataAbility' ); -DAHelper.getType("dataability:///com.example.DataAbility").then((data) => { - console.info("==========================>getTypeCallback=======================>"); +DAHelper.getType('dataability:///com.example.DataAbility').then((data) => { + console.info('==========================>getTypeCallback=======================>'); }); ``` @@ -226,13 +226,13 @@ getFileTypes(uri: string, mimeTypeFilter: string, callback: AsyncCallback { - console.info("==========================>Called=======================>"); +DAHelper.getFileTypes( 'dataability:///com.example.DataAbility', + 'image/*', (err, data) => { + console.info('==========================>Called=======================>'); }); ``` @@ -262,13 +262,13 @@ getFileTypes(uri: string, mimeTypeFilter: string): Promise\> **示例:** ```ts -import featureAbility from '@ohos.ability.featureAbility' +import featureAbility from '@ohos.ability.featureAbility'; let DAHelper = featureAbility.acquireDataAbilityHelper( - "dataability:///com.example.DataAbility" + 'dataability:///com.example.DataAbility' ); -DAHelper.getFileTypes("dataability:///com.example.DataAbility", - "image/*").then((data) => { - console.info("===================>getFileTypesCallback================>"); +DAHelper.getFileTypes('dataability:///com.example.DataAbility', + 'image/*').then((data) => { + console.info('===================>getFileTypesCallback================>'); }); ``` @@ -290,12 +290,12 @@ normalizeUri(uri: string, callback: AsyncCallback\): void **示例:** ```ts -import featureAbility from '@ohos.ability.featureAbility' +import featureAbility from '@ohos.ability.featureAbility'; let DAHelper = featureAbility.acquireDataAbilityHelper( - "dataability:///com.example.DataAbility" + 'dataability:///com.example.DataAbility' ); -DAHelper.normalizeUri("dataability:///com.example.DataAbility", (err, data) => { - console.info("==========================>Called=======================>"); +DAHelper.normalizeUri('dataability:///com.example.DataAbility', (err, data) => { + console.info('==========================>Called=======================>'); }); ``` @@ -322,12 +322,12 @@ normalizeUri(uri: string): Promise\ **示例:** ```ts -import featureAbility from '@ohos.ability.featureAbility' +import featureAbility from '@ohos.ability.featureAbility'; let DAHelper = featureAbility.acquireDataAbilityHelper( - "dataability:///com.example.DataAbility" + 'dataability:///com.example.DataAbility' ); -DAHelper.normalizeUri("dataability:///com.example.DataAbility",).then((data) => { - console.info("=================>normalizeUriCallback=======================>"); +DAHelper.normalizeUri('dataability:///com.example.DataAbility',).then((data) => { + console.info('=================>normalizeUriCallback=======================>'); }); ``` @@ -349,12 +349,12 @@ denormalizeUri(uri: string, callback: AsyncCallback\): void **示例:** ```ts -import featureAbility from '@ohos.ability.featureAbility' +import featureAbility from '@ohos.ability.featureAbility'; let DAHelper = featureAbility.acquireDataAbilityHelper( - "dataability:///com.example.DataAbility" + 'dataability:///com.example.DataAbility' ); -DAHelper.denormalizeUri("dataability:///com.example.DataAbility", (err, data) => { - console.info("==========================>Called=======================>"); +DAHelper.denormalizeUri('dataability:///com.example.DataAbility', (err, data) => { + console.info('==========================>Called=======================>'); }); ``` @@ -383,12 +383,12 @@ denormalizeUri(uri: string): Promise\ **示例:** ```ts -import featureAbility from '@ohos.ability.featureAbility' +import featureAbility from '@ohos.ability.featureAbility'; let DAHelper = featureAbility.acquireDataAbilityHelper( - "dataability:///com.example.DataAbility" + 'dataability:///com.example.DataAbility' ); -DAHelper.denormalizeUri("dataability:///com.example.DataAbility",).then((data) => { - console.info("===============>denormalizeUriCallback=======================>"); +DAHelper.denormalizeUri('dataability:///com.example.DataAbility',).then((data) => { + console.info('===============>denormalizeUriCallback=======================>'); }); ``` @@ -410,12 +410,12 @@ notifyChange(uri: string, callback: AsyncCallback\): void **示例:** ```ts -import featureAbility from '@ohos.ability.featureAbility' +import featureAbility from '@ohos.ability.featureAbility'; let helper = featureAbility.acquireDataAbilityHelper( - "dataability:///com.example.DataAbility" + 'dataability:///com.example.DataAbility' ); -helper.notifyChange("dataability:///com.example.DataAbility", (err) => { - console.info("==========================>Called=======================>"); +helper.notifyChange('dataability:///com.example.DataAbility', (err) => { + console.info('==========================>Called=======================>'); }); ``` @@ -442,12 +442,12 @@ notifyChange(uri: string): Promise\ **示例:** ```ts -import featureAbility from '@ohos.ability.featureAbility' +import featureAbility from '@ohos.ability.featureAbility'; let DAHelper = featureAbility.acquireDataAbilityHelper( - "dataability:///com.example.DataAbility" + 'dataability:///com.example.DataAbility' ); -DAHelper.notifyChange("dataability:///com.example.DataAbility").then(() => { - console.info("================>notifyChangeCallback================>"); +DAHelper.notifyChange('dataability:///com.example.DataAbility').then(() => { + console.info('================>notifyChangeCallback================>'); }); ``` @@ -470,19 +470,19 @@ insert(uri: string, valuesBucket: rdb.ValuesBucket, callback: AsyncCallback\ { - console.info("==========================>Called=======================>"); + console.info('==========================>Called=======================>'); }); ``` @@ -510,18 +510,18 @@ insert(uri: string, valuesBucket: rdb.ValuesBucket): Promise\ **示例:** ```ts -import featureAbility from '@ohos.ability.featureAbility' +import featureAbility from '@ohos.ability.featureAbility'; let DAHelper = featureAbility.acquireDataAbilityHelper( - "dataability:///com.example.DataAbility" + 'dataability:///com.example.DataAbility' ); const valueBucket = { - "name": "rose1", - "age": 221, - "salary": 20.5, - "blobType": "u8", -} -DAHelper.insert("dataability:///com.example.DataAbility", valueBucket).then((data) => { - console.info("====================>insertCallback=======================>"); + 'name': 'rose1', + 'age': 221, + 'salary': 20.5, + 'blobType': 'u8', +}; +DAHelper.insert('dataability:///com.example.DataAbility', valueBucket).then((data) => { + console.info('====================>insertCallback=======================>'); }); ``` @@ -544,16 +544,16 @@ batchInsert(uri: string, valuesBuckets: Array\, callback: Asyn **示例:** ```ts -import featureAbility from '@ohos.ability.featureAbility' +import featureAbility from '@ohos.ability.featureAbility'; let DAHelper = featureAbility.acquireDataAbilityHelper( - "dataability:///com.example.DataAbility" + 'dataability:///com.example.DataAbility' ); -let cars = new Array({"name": "roe11", "age": 21, "salary": 20.5, "blobType": "u8",}, - {"name": "roe12", "age": 21, "salary": 20.5, "blobType": "u8",}, - {"name": "roe13", "age": 21, "salary": 20.5, "blobType": "u8",}) -DAHelper.batchInsert("dataability:///com.example.DataAbility", cars, +let cars = new Array({'name': 'roe11', 'age': 21, 'salary': 20.5, 'blobType': 'u8',}, + {'name': 'roe12', 'age': 21, 'salary': 20.5, 'blobType': 'u8',}, + {'name': 'roe13', 'age': 21, 'salary': 20.5, 'blobType': 'u8',}); +DAHelper.batchInsert('dataability:///com.example.DataAbility', cars, (err, data) => { - console.info("==========================>Called=======================>"); + console.info('==========================>Called=======================>'); }); ``` @@ -581,15 +581,15 @@ batchInsert(uri: string, valuesBuckets: Array): Promise\ { - console.info("==================>batchInsertCallback=======================>"); +let cars = new Array({'name': 'roe11', 'age': 21, 'salary': 20.5, 'blobType': 'u8',}, + {'name': 'roe12', 'age': 21, 'salary': 20.5, 'blobType': 'u8',}, + {'name': 'roe13', 'age': 21, 'salary': 20.5, 'blobType': 'u8',}); +DAHelper.batchInsert('dataability:///com.example.DataAbility', cars).then((data) => { + console.info('==================>batchInsertCallback=======================>'); }); ``` @@ -612,15 +612,15 @@ delete(uri: string, predicates: dataAbility.DataAbilityPredicates, callback: Asy **示例:** ```ts -import featureAbility from '@ohos.ability.featureAbility' -import ohos_data_ability from '@ohos.data.dataAbility' +import featureAbility from '@ohos.ability.featureAbility'; +import ohos_data_ability from '@ohos.data.dataAbility'; let DAHelper = featureAbility.acquireDataAbilityHelper( - "dataability:///com.example.DataAbility" + 'dataability:///com.example.DataAbility' ); -let da = new ohos_data_ability.DataAbilityPredicates() -DAHelper.delete("dataability:///com.example.DataAbility", da, +let da = new ohos_data_ability.DataAbilityPredicates(); +DAHelper.delete('dataability:///com.example.DataAbility', da, (err, data) => { - console.info("==========================>Called=======================>"); + console.info('==========================>Called=======================>'); }); ``` @@ -648,14 +648,14 @@ delete(uri: string, predicates?: dataAbility.DataAbilityPredicates): Promise\ { - console.info("==========================>deleteCallback=======================>"); +let da = new ohos_data_ability.DataAbilityPredicates(); +DAHelper.delete('dataability:///com.example.DataAbility', da).then((data) => { + console.info('==========================>deleteCallback=======================>'); }); ``` @@ -679,20 +679,20 @@ update(uri: string, valuesBucket: rdb.ValuesBucket, predicates: dataAbility.Data **示例:** ```ts -import featureAbility from '@ohos.ability.featureAbility' -import ohos_data_ability from '@ohos.data.dataAbility' +import featureAbility from '@ohos.ability.featureAbility'; +import ohos_data_ability from '@ohos.data.dataAbility'; let DAHelper = featureAbility.acquireDataAbilityHelper( - "dataability:///com.example.DataAbility" + 'dataability:///com.example.DataAbility' ); const va = { - "name": "roe1", - "age": 21, - "salary": 20.5, - "blobType": "u8", -} -let da = new ohos_data_ability.DataAbilityPredicates() -DAHelper.update("dataability:///com.example.DataAbility", va, da, (err, data) => { - console.info("==========================>Called=======================>"); + 'name': 'roe1', + 'age': 21, + 'salary': 20.5, + 'blobType': 'u8', +}; +let da = new ohos_data_ability.DataAbilityPredicates(); +DAHelper.update('dataability:///com.example.DataAbility', va, da, (err, data) => { + console.info('==========================>Called=======================>'); }); ``` @@ -721,20 +721,20 @@ update(uri: string, valuesBucket: rdb.ValuesBucket, predicates?: dataAbility.Dat **示例:** ```ts -import featureAbility from '@ohos.ability.featureAbility' -import ohos_data_ability from '@ohos.data.dataAbility' +import featureAbility from '@ohos.ability.featureAbility'; +import ohos_data_ability from '@ohos.data.dataAbility'; let DAHelper = featureAbility.acquireDataAbilityHelper( - "dataability:///com.example.DataAbility" + 'dataability:///com.example.DataAbility' ); const va = { - "name": "roe1", - "age": 21, - "salary": 20.5, - "blobType": "u8", -} -let da = new ohos_data_ability.DataAbilityPredicates() -DAHelper.update("dataability:///com.example.DataAbility", va, da).then((data) => { - console.info("==========================>updateCallback=======================>"); + 'name': 'roe1', + 'age': 21, + 'salary': 20.5, + 'blobType': 'u8', +}; +let da = new ohos_data_ability.DataAbilityPredicates(); +DAHelper.update('dataability:///com.example.DataAbility', va, da).then((data) => { + console.info('==========================>updateCallback=======================>'); }); ``` @@ -758,15 +758,15 @@ query(uri: string, columns: Array\, predicates: dataAbility.DataAbilityP **示例:** ```ts -import featureAbility from '@ohos.ability.featureAbility' -import ohos_data_ability from '@ohos.data.dataAbility' +import featureAbility from '@ohos.ability.featureAbility'; +import ohos_data_ability from '@ohos.data.dataAbility'; let DAHelper = featureAbility.acquireDataAbilityHelper( - "dataability:///com.example.DataAbility" + 'dataability:///com.example.DataAbility' ); -let cars=new Array("value1", "value2", "value3", "value4"); -let da = new ohos_data_ability.DataAbilityPredicates() -DAHelper.query("dataability:///com.example.DataAbility", cars, da, (err, data) => { - console.info("==========================>Called=======================>"); +let cars=new Array('value1', 'value2', 'value3', 'value4'); +let da = new ohos_data_ability.DataAbilityPredicates(); +DAHelper.query('dataability:///com.example.DataAbility', cars, da, (err, data) => { + console.info('==========================>Called=======================>'); }); ``` @@ -797,15 +797,15 @@ query(uri: string, columns?: Array\, predicates?: dataAbility.DataAbilit **示例:** ```ts -import featureAbility from '@ohos.ability.featureAbility' -import ohos_data_ability from '@ohos.data.dataAbility' +import featureAbility from '@ohos.ability.featureAbility'; +import ohos_data_ability from '@ohos.data.dataAbility'; let DAHelper = featureAbility.acquireDataAbilityHelper( - "dataability:///com.example.DataAbility" + 'dataability:///com.example.DataAbility' ); -let cars = new Array("value1", "value2", "value3", "value4"); -let da = new ohos_data_ability.DataAbilityPredicates() -DAHelper.query("dataability:///com.example.DataAbility", cars, da).then((data) => { - console.info("==========================>queryCallback=======================>"); +let cars = new Array('value1', 'value2', 'value3', 'value4'); +let da = new ohos_data_ability.DataAbilityPredicates(); +DAHelper.query('dataability:///com.example.DataAbility', cars, da).then((data) => { + console.info('==========================>queryCallback=======================>'); }); ``` @@ -821,7 +821,7 @@ call(uri: string, method: string, arg: string, extras: PacMap): Promise\ | 参数名 | 类型 | 必填 | 说明 | | ---------- | --------------------------------- | ---- | ------------------------------------------------ | -| uri | string | 是 | 指定待处理的DataAbility。例:"dataability:///com.example.xxx.xxxx" | +| uri | string | 是 | 指定待处理的DataAbility。例:'dataability:///com.example.xxx.xxxx' | | method | string | 是 | 被调用的方法名。 | | arg | string | 是 |需传入的参数。 | | extras | [PacMap](#pacmap) | 是 | 键值对参数。 | @@ -838,9 +838,9 @@ call(uri: string, method: string, arg: string, extras: PacMap): Promise\ import featureAbility from '@ohos.ability.featureAbility'; let dataAbilityHelper = featureAbility.acquireDataAbilityHelper( - "dataability:///com.example.jsapidemo.UserDataAbility"); -dataAbilityHelper.call("dataability:///com.example.jsapidemo.UserDataAbility", - "method", "arg", {"key1":"value1"}).then((data) => { + 'dataability:///com.example.jsapidemo.UserDataAbility'); +dataAbilityHelper.call('dataability:///com.example.jsapidemo.UserDataAbility', + 'method', 'arg', {'key1':'value1'}).then((data) => { console.info('Operation succeeded: ' + data); }).catch((error) => { console.error('Operation failed. Cause: ' + error); @@ -859,7 +859,7 @@ call(uri: string, method: string, arg: string, extras: PacMap, callback: AsyncCa | 参数名 | 类型 | 必填 | 说明 | | ---------- | --------------------------------- | ---- | ------------------------------------------------ | -| uri | string | 是 | 指定待处理的DataAbility。例:"dataability:///com.example.xxx.xxxx" | +| uri | string | 是 | 指定待处理的DataAbility。例:'dataability:///com.example.xxx.xxxx' | | method | string | 是 | 被调用的方法名。 | | arg | string | 是 |需传入的参数。 | | extras | [PacMap](#pacmap) | 是 | 键值对参数。 | @@ -871,9 +871,9 @@ call(uri: string, method: string, arg: string, extras: PacMap, callback: AsyncCa import featureAbility from '@ohos.ability.featureAbility'; let dataAbilityHelper = featureAbility.acquireDataAbilityHelper( - "dataability:///com.example.jsapidemo.UserDataAbility"); -dataAbilityHelper.call("dataability:///com.example.jsapidemo.UserDataAbility", - "method", "arg", {"key1":"value1"}, (err, data) => { + 'dataability:///com.example.jsapidemo.UserDataAbility'); +dataAbilityHelper.call('dataability:///com.example.jsapidemo.UserDataAbility', + 'method', 'arg', {'key1':'value1'}, (err, data) => { if (err) { console.error('Operation failed. Cause: ' + err); return; @@ -894,7 +894,7 @@ executeBatch(uri: string, operations: Array\, callback: As | 参数名 | 类型 | 必填 | 说明 | | ---------- | --------------------------------- | ---- | ------------------------------------------------ | -| uri | string | 是 | 指定待处理的DataAbility。例:"dataability:///com.example.xxx.xxxx"。| +| uri | string | 是 | 指定待处理的DataAbility。例:'dataability:///com.example.xxx.xxxx'。| | operations | Array\<[DataAbilityOperation](js-apis-inner-ability-dataAbilityOperation.md)> | 是 | 指示数据操作列表,其中可以包含对数据库的多个操作。 | | callback | AsyncCallback\> | 是 |在数组 DataAbilityResult中返回每个操作的结果。 | @@ -906,8 +906,8 @@ import featureAbility from '@ohos.ability.featureAbility'; // 根据DataAbilityOperation列表选择要对数据库做的操作 let op=new Array(); let dataAbilityHelper = featureAbility.acquireDataAbilityHelper( - "dataability:///com.example.jsapidemo.UserDataAbility"); -dataAbilityHelper.executeBatch("dataability:///com.example.jsapidemo.UserDataAbility", + 'dataability:///com.example.jsapidemo.UserDataAbility'); +dataAbilityHelper.executeBatch('dataability:///com.example.jsapidemo.UserDataAbility', op, (err, data) => { if (err) { console.error('Operation failed. Cause: ' + err); @@ -929,7 +929,7 @@ executeBatch(uri: string, operations: Array\): Promise\ | 是 | 指示数据操作列表,其中可以包含对数据库的多个操作。 | **返回值:** @@ -946,8 +946,8 @@ import featureAbility from '@ohos.ability.featureAbility'; // 根据DataAbilityOperation列表选择要对数据库做的操作 let op=new Array(); let dataAbilityHelper = featureAbility.acquireDataAbilityHelper( - "dataability:///com.example.jsapidemo.UserDataAbility"); -dataAbilityHelper.executeBatch("dataability:///com.example.jsapidemo.UserDataAbility", + 'dataability:///com.example.jsapidemo.UserDataAbility'); +dataAbilityHelper.executeBatch('dataability:///com.example.jsapidemo.UserDataAbility', op).then((data) => { console.info('Operation succeeded: ' + data); }).catch((error) => { diff --git a/zh-cn/application-dev/reference/apis/js-apis-inner-ability-dataAbilityResult.md b/zh-cn/application-dev/reference/apis/js-apis-inner-ability-dataAbilityResult.md index 3d4f0ce5236720725fd909ecba27bddae3d1cd8f..4035c9dc2611f1d88923526274d45d94f88d8aff 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-inner-ability-dataAbilityResult.md +++ b/zh-cn/application-dev/reference/apis/js-apis-inner-ability-dataAbilityResult.md @@ -11,15 +11,15 @@ | 名称 | 类型 | 必填 | 说明 | | -------- | -------- | -------- | -------- | -| uri? | string | 否 | 指定待处理的DataAbility。例:"dataability:///com.example.xxx.xxxx"。 | +| uri? | string | 否 | 指定待处理的DataAbility。例:'dataability:///com.example.xxx.xxxx'。 | | count? | number | 否 | 指示受操作影响的行数。 | **示例:** ```ts -import featureAbility from '@ohos.ability.featureAbility' +import featureAbility from '@ohos.ability.featureAbility'; -let dataAbilityUri = ("dataability:///com.example.myapplication.TestDataAbility"); +let dataAbilityUri = ('dataability:///com.example.myapplication.TestDataAbility'); let DAHelper; try { DAHelper = featureAbility.acquireDataAbilityHelper(dataAbilityUri); @@ -33,9 +33,9 @@ try { } let valueBucket = { - "name": "DataAbilityHelperTest", - "age": 24, - "salary": 2024.20, + 'name': 'DataAbilityHelperTest', + 'age': 24, + 'salary': 2024.20, }; let operations = [ { diff --git a/zh-cn/application-dev/reference/apis/js-apis-inner-ability-startAbilityParameter.md b/zh-cn/application-dev/reference/apis/js-apis-inner-ability-startAbilityParameter.md index 0005c2d6e7bb6afaa0de63ba889bb576440f3f65..60f5272f0f7e373fc8f31fed95fdaf24e76f0a26 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-inner-ability-startAbilityParameter.md +++ b/zh-cn/application-dev/reference/apis/js-apis-inner-ability-startAbilityParameter.md @@ -16,29 +16,29 @@ **示例:** ```ts -import featureAbility from '@ohos.ability.featureAbility' +import featureAbility from '@ohos.ability.featureAbility'; let Want = { - bundleName: "com.example.abilityStartSettingApp2", - abilityName: "com.example.abilityStartSettingApp.MainAbility", -} + bundleName: 'com.example.abilityStartSettingApp2', + abilityName: 'com.example.abilityStartSettingApp.MainAbility', +}; let abilityStartSetting ={ [featureAbility.AbilityStartSetting.BOUNDS_KEY] : [100,200,300,400], [featureAbility.AbilityStartSetting.WINDOW_MODE_KEY] : featureAbility.AbilityWindowConfiguration.WINDOW_MODE_UNDEFINED, [featureAbility.AbilityStartSetting.DISPLAY_ID_KEY] : 1, -} +}; let startAbilityParameter = { want : Want, abilityStartSetting : abilityStartSetting -} +}; featureAbility.startAbility(startAbilityParameter, (err, data)=>{ console.log('errCode : ' + JSON.stringify(err)); console.log('data : ' + JSON.stringify(data)); } catch(error) { - console.log("startAbility error: " + JSON.stringify(error)); + console.log('startAbility error: ' + JSON.stringify(error)); } ``` \ No newline at end of file diff --git a/zh-cn/application-dev/reference/apis/js-apis-inner-ability-want.md b/zh-cn/application-dev/reference/apis/js-apis-inner-ability-want.md index 4caa0af24ff66ef7a50d6c8c0df8a302cf51880d..ba09e0be894371f7608a0bdf395ad92ad07df80b 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-inner-ability-want.md +++ b/zh-cn/application-dev/reference/apis/js-apis-inner-ability-want.md @@ -14,7 +14,7 @@ Want是对象间信息传递的载体, 可以用于应用组件间的信息传 | bundleName | string | 否 | 表示包名。如果在Want中同时指定了BundleName和AbilityName,则Want可以直接匹配到指定的Ability。 | | abilityName | string | 否 | 表示待启动的Ability名称。如果在Want中该字段同时指定了BundleName和AbilityName,则Want可以直接匹配到指定的Ability。AbilityName需要在一个应用的范围内保证唯一。 | | uri | string | 否 | 表示Uri。如果在Want中指定了Uri,则Want将匹配指定的Uri信息,包括scheme, schemeSpecificPart, authority和path信息。 | -| type | string | 否 | 表示MIME type类型,打开文件的类型,主要用于文管打开文件。比如:"text/xml" 、 "image/*"等,MIME定义参考:https://www.iana.org/assignments/media-types/media-types.xhtml?utm_source=ld246.com。 | +| type | string | 否 | 表示MIME type类型,打开文件的类型,主要用于文管打开文件。比如:'text/xml' 、 'image/*'等,MIME定义参考:https://www.iana.org/assignments/media-types/media-types.xhtml?utm_source=ld246.com。 | | flags | number | 否 | 表示处理Want的方式。默认传数字,具体参考:[flags说明](js-apis-ability-wantConstant.md#wantConstant.Flags)。 | | action | string | 否 | 表示要执行的通用操作(如:查看、分享、应用详情)。在隐式Want中,您可以定义该字段,配合uri或parameters来表示对数据要执行的操作。 | | parameters | {[key: string]: any} | 否 | 表示WantParams,由开发者自行决定传入的键值对。默认会携带以下key值:
ohos.aafwk.callerPid 表示拉起方的pid。
ohos.aafwk.param.callerToken 表示拉起方的token。
ohos.aafwk.param.callerUid 表示[bundleInfo](js-apis-bundle-BundleInfo.md#bundleinfo-1)中的uid,应用包里应用程序的uid。
- component.startup.newRules:表示是否启用新的管控规则。
- moduleName:表示拉起方的模块名,该字段的值即使定义成其他字符串,在传递到另一端时会被修改为正确的值。
- ohos.dlp.params.sandbox:表示dlp文件才会有。 | | @@ -27,42 +27,42 @@ Want是对象间信息传递的载体, 可以用于应用组件间的信息传 ```ts let want = { - "deviceId": "", // deviceId为空表示本设备 - "bundleName": "com.extreme.test", - "abilityName": "MainAbility", - "moduleName": "entry" // moduleName非必选 + 'deviceId': '', // deviceId为空表示本设备 + 'bundleName': 'com.extreme.test', + 'abilityName': 'MainAbility', + 'moduleName': 'entry' // moduleName非必选 }; this.context.startAbility(want, (error) => { // 显式拉起Ability,通过bundleName、abilityName和moduleName可以唯一确定一个Ability - console.log("error.code = " + error.code) - }) + console.log('error.code = ' + error.code) + }); ``` - 传递FD(文件描述符)数据(在UIAbility对象中调用,其中示例中的context为UIAbility的上下文对象) ```ts - import fileio from '@ohos.fileio'; + import fileio from '@ohos.fileio';; // ... let fd; try { - fd = fileio.openSync("/data/storage/el2/base/haps/pic.png"); + fd = fileio.openSync('/data/storage/el2/base/haps/pic.png'); } catch(e) { - console.log("openSync fail:" + JSON.stringify(e)); + console.log('openSync fail:' + JSON.stringify(e)); } let want = { - "deviceId": "", // deviceId为空表示本设备 - "bundleName": "com.extreme.test", - "abilityName": "MainAbility", - "moduleName": "entry", // moduleName非必选 - "parameters": { - "keyFd":{"type":"FD", "value":fd} + 'deviceId': '', // deviceId为空表示本设备 + 'bundleName': 'com.extreme.test', + 'abilityName': 'MainAbility', + 'moduleName': 'entry', // moduleName非必选 + 'parameters': { + 'keyFd':{'type':'FD', 'value':fd} } }; this.context.startAbility(want, (error) => { // 显式拉起Ability,通过bundleName、abilityName和moduleName可以唯一确定一个Ability - console.log("error.code = " + error.code) - }) + console.log('error.code = ' + error.code) + }); // ... ``` diff --git a/zh-cn/application-dev/reference/apis/js-apis-inner-app-context.md b/zh-cn/application-dev/reference/apis/js-apis-inner-app-context.md index 2a2db17446a8918d850a5b7a143046ea45028379..87ad3a00afdb9d5abec9163e9e55755ac9f53666 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-inner-app-context.md +++ b/zh-cn/application-dev/reference/apis/js-apis-inner-app-context.md @@ -15,7 +15,7 @@ Context对象是在featureAbility中创建实例,并通过featureAbility的[ge import featureAbility from '@ohos.ability.featureAbility'; let context = featureAbility.getContext(); context.getOrCreateLocalDir().then((data) => { - console.info("getOrCreateLocalDir data: " + JSON.stringify(data)); + console.info('getOrCreateLocalDir data: ' + JSON.stringify(data)); }); ``` @@ -41,7 +41,7 @@ getOrCreateLocalDir(callback: AsyncCallback\): void import featureAbility from '@ohos.ability.featureAbility'; let context = featureAbility.getContext(); context.getOrCreateLocalDir((err, data)=>{ - console.info("getOrCreateLocalDir err: " + JSON.stringify(err) + "data: " + JSON.stringify(data)); + console.info('getOrCreateLocalDir err: ' + JSON.stringify(err) + 'data: ' + JSON.stringify(data)); }); ``` @@ -69,7 +69,7 @@ getOrCreateLocalDir(): Promise\ import featureAbility from '@ohos.ability.featureAbility'; let context = featureAbility.getContext(); context.getOrCreateLocalDir().then((data) => { - console.info("getOrCreateLocalDir data: " + JSON.stringify(data)); + console.info('getOrCreateLocalDir data: ' + JSON.stringify(data)); }); ``` @@ -96,8 +96,8 @@ import featureAbility from '@ohos.ability.featureAbility'; import bundle from '@ohos.bundle'; let context = featureAbility.getContext(); bundle.getBundleInfo('com.context.test', 1, (err, datainfo) =>{ - context.verifyPermission("com.example.permission", {uid:datainfo.uid}, (err, data) =>{ - console.info("verifyPermission err: " + JSON.stringify(err) + "data: " + JSON.stringify(data)); + context.verifyPermission('com.example.permission', {uid:datainfo.uid}, (err, data) =>{ + console.info('verifyPermission err: ' + JSON.stringify(err) + 'data: ' + JSON.stringify(data)); }); }); ``` @@ -124,8 +124,8 @@ verifyPermission(permission: string, callback: AsyncCallback\): void ```ts import featureAbility from '@ohos.ability.featureAbility'; let context = featureAbility.getContext(); -context.verifyPermission("com.example.permission", (err, data) =>{ - console.info("verifyPermission err: " + JSON.stringify(err) + "data: " + JSON.stringify(data)); +context.verifyPermission('com.example.permission', (err, data) =>{ + console.info('verifyPermission err: ' + JSON.stringify(err) + 'data: ' + JSON.stringify(data)); }); ``` @@ -157,7 +157,7 @@ import featureAbility from '@ohos.ability.featureAbility'; let context = featureAbility.getContext(); let Permission = {pid:1}; context.verifyPermission('com.context.permission',Permission).then((data) => { - console.info("verifyPermission data: " + JSON.stringify(data)); + console.info('verifyPermission data: ' + JSON.stringify(data)); }); ``` @@ -185,14 +185,14 @@ requestPermissionsFromUser(permissions: Array\, requestCode: number, res import featureAbility from '@ohos.ability.featureAbility'; let context = featureAbility.getContext(); context.requestPermissionsFromUser( - ["com.example.permission1", - "com.example.permission2", - "com.example.permission3", - "com.example.permission4", - "com.example.permission5"], + ['com.example.permission1', + 'com.example.permission2', + 'com.example.permission3', + 'com.example.permission4', + 'com.example.permission5'], 1, (err, data) => { - console.info("requestPermissionsFromUser err: " + JSON.stringify(err) + "data: " + JSON.stringify(data)); + console.info('requestPermissionsFromUser err: ' + JSON.stringify(err) + 'data: ' + JSON.stringify(data)); } ); ``` @@ -225,13 +225,13 @@ requestPermissionsFromUser(permissions: Array\, requestCode: number): Pr import featureAbility from '@ohos.ability.featureAbility'; let context = featureAbility.getContext(); context.requestPermissionsFromUser( - ["com.example.permission1", - "com.example.permission2", - "com.example.permission3", - "com.example.permission4", - "com.example.permission5"], + ['com.example.permission1', + 'com.example.permission2', + 'com.example.permission3', + 'com.example.permission4', + 'com.example.permission5'], 1).then((data)=>{ - console.info("requestPermissionsFromUser data: " + JSON.stringify(data)); + console.info('requestPermissionsFromUser data: ' + JSON.stringify(data)); } ); ``` @@ -258,7 +258,7 @@ getApplicationInfo(callback: AsyncCallback\): void import featureAbility from '@ohos.ability.featureAbility'; let context = featureAbility.getContext(); context.getApplicationInfo((err, data) => { - console.info("getApplicationInfo err: " + JSON.stringify(err) + "data: " + JSON.stringify(data)); + console.info('getApplicationInfo err: ' + JSON.stringify(err) + 'data: ' + JSON.stringify(data)); }); ``` @@ -284,7 +284,7 @@ getApplicationInfo(): Promise\ import featureAbility from '@ohos.ability.featureAbility'; let context = featureAbility.getContext(); context.getApplicationInfo().then((data) => { - console.info("getApplicationInfo data: " + JSON.stringify(data)); + console.info('getApplicationInfo data: ' + JSON.stringify(data)); }); ``` @@ -310,7 +310,7 @@ getBundleName(callback: AsyncCallback\): void import featureAbility from '@ohos.ability.featureAbility'; let context = featureAbility.getContext(); context.getBundleName((err, data) => { - console.info("getBundleName err: " + JSON.stringify(err) + "data: " + JSON.stringify(data)); + console.info('getBundleName err: ' + JSON.stringify(err) + 'data: ' + JSON.stringify(data)); }); ``` @@ -336,7 +336,7 @@ getBundleName(): Promise\ import featureAbility from '@ohos.ability.featureAbility'; let context = featureAbility.getContext(); context.getBundleName().then((data) => { - console.info("getBundleName data: " + JSON.stringify(data)); + console.info('getBundleName data: ' + JSON.stringify(data)); }); ``` @@ -360,7 +360,7 @@ getDisplayOrientation(callback: AsyncCallback\): void import featureAbility from '@ohos.ability.featureAbility'; let context = featureAbility.getContext(); context.getDisplayOrientation((err, data) => { - console.info("getDisplayOrientation err: " + JSON.stringify(err) + "data: " + JSON.stringify(data)); + console.info('getDisplayOrientation err: ' + JSON.stringify(err) + 'data: ' + JSON.stringify(data)); }); ``` @@ -384,7 +384,7 @@ getDisplayOrientation(): Promise\; import featureAbility from '@ohos.ability.featureAbility'; let context = featureAbility.getContext(); context.getDisplayOrientation().then((data) => { - console.info("getDisplayOrientation data: " + JSON.stringify(data)); + console.info('getDisplayOrientation data: ' + JSON.stringify(data)); }); ``` @@ -408,7 +408,7 @@ getExternalCacheDir(callback: AsyncCallback\): void import featureAbility from '@ohos.ability.featureAbility'; let context = featureAbility.getContext(); context.getExternalCacheDir((err, data) => { - console.info("getExternalCacheDir err: " + JSON.stringify(err) + "data: " + JSON.stringify(data)); + console.info('getExternalCacheDir err: ' + JSON.stringify(err) + 'data: ' + JSON.stringify(data)); }); ``` @@ -432,7 +432,7 @@ getExternalCacheDir(): Promise\; import featureAbility from '@ohos.ability.featureAbility'; let context = featureAbility.getContext(); context.getExternalCacheDir().then((data) => { - console.info("getExternalCacheDir data: " + JSON.stringify(data)); + console.info('getExternalCacheDir data: ' + JSON.stringify(data)); }); ``` @@ -459,7 +459,7 @@ import bundle from '@ohos.bundle'; let context = featureAbility.getContext(); let orientation=bundle.DisplayOrientation.UNSPECIFIED context.setDisplayOrientation(orientation, (err) => { - console.info("setDisplayOrientation err: " + JSON.stringify(err)); + console.info('setDisplayOrientation err: ' + JSON.stringify(err)); }); ``` @@ -486,7 +486,7 @@ import bundle from '@ohos.bundle'; let context = featureAbility.getContext(); let orientation=bundle.DisplayOrientation.UNSPECIFIED context.setDisplayOrientation(orientation).then((data) => { - console.info("setDisplayOrientation data: " + JSON.stringify(data)); + console.info('setDisplayOrientation data: ' + JSON.stringify(data)); }); ``` @@ -512,7 +512,7 @@ import featureAbility from '@ohos.ability.featureAbility'; let context = featureAbility.getContext(); let show=true context.setShowOnLockScreen(show, (err) => { - console.info("setShowOnLockScreen err: " + JSON.stringify(err)); + console.info('setShowOnLockScreen err: ' + JSON.stringify(err)); }); ``` @@ -543,7 +543,7 @@ import featureAbility from '@ohos.ability.featureAbility'; let context = featureAbility.getContext(); let show=true context.setShowOnLockScreen(show).then((data) => { - console.info("setShowOnLockScreen data: " + JSON.stringify(data)); + console.info('setShowOnLockScreen data: ' + JSON.stringify(data)); }); ``` @@ -569,7 +569,7 @@ import featureAbility from '@ohos.ability.featureAbility'; let context = featureAbility.getContext(); let wakeUp=true context.setWakeUpScreen(wakeUp, (err) => { - console.info("setWakeUpScreen err: " + JSON.stringify(err)); + console.info('setWakeUpScreen err: ' + JSON.stringify(err)); }); ``` @@ -600,7 +600,7 @@ import featureAbility from '@ohos.ability.featureAbility'; let context = featureAbility.getContext(); let wakeUp=true context.setWakeUpScreen(wakeUp).then((data) => { - console.info("setWakeUpScreen data: " + JSON.stringify(data)); + console.info('setWakeUpScreen data: ' + JSON.stringify(data)); }); ``` @@ -627,7 +627,7 @@ getProcessInfo(callback: AsyncCallback\): void import featureAbility from '@ohos.ability.featureAbility'; let context = featureAbility.getContext(); context.getProcessInfo((err, data) => { - console.info("getProcessInfo err: " + JSON.stringify(err) + "data: " + JSON.stringify(data)); + console.info('getProcessInfo err: ' + JSON.stringify(err) + 'data: ' + JSON.stringify(data)); }); ``` @@ -653,7 +653,7 @@ getProcessInfo(): Promise\ import featureAbility from '@ohos.ability.featureAbility'; let context = featureAbility.getContext(); context.getProcessInfo().then((data) => { - console.info("getProcessInfo data: " + JSON.stringify(data)); + console.info('getProcessInfo data: ' + JSON.stringify(data)); }); ``` @@ -681,7 +681,7 @@ getElementName(callback: AsyncCallback\): void import featureAbility from '@ohos.ability.featureAbility'; let context = featureAbility.getContext(); context.getElementName((err, data) => { - console.info("getElementName err: " + JSON.stringify(err) + "data: " + JSON.stringify(data)); + console.info('getElementName err: ' + JSON.stringify(err) + 'data: ' + JSON.stringify(data)); }); ``` @@ -709,7 +709,7 @@ getElementName(): Promise\ import featureAbility from '@ohos.ability.featureAbility'; let context = featureAbility.getContext(); context.getElementName().then((data) => { - console.info("getElementName data: " + JSON.stringify(data)); + console.info('getElementName data: ' + JSON.stringify(data)); }); ``` @@ -733,7 +733,7 @@ getProcessName(callback: AsyncCallback\): void import featureAbility from '@ohos.ability.featureAbility'; let context = featureAbility.getContext(); context.getProcessName((err, data) => { - console.info("getProcessName err: " + JSON.stringify(err) + "data: " + JSON.stringify(data)); + console.info('getProcessName err: ' + JSON.stringify(err) + 'data: ' + JSON.stringify(data)); }); ``` @@ -759,7 +759,7 @@ getProcessName(): Promise\ import featureAbility from '@ohos.ability.featureAbility'; let context = featureAbility.getContext(); context.getProcessName().then((data) => { - console.info("getProcessName data: " + JSON.stringify(data)); + console.info('getProcessName data: ' + JSON.stringify(data)); }); ``` @@ -785,7 +785,7 @@ getCallingBundle(callback: AsyncCallback\): void import featureAbility from '@ohos.ability.featureAbility'; let context = featureAbility.getContext(); context.getCallingBundle((err, data) => { - console.info("getCallingBundle err: " + JSON.stringify(err) + "data: " + JSON.stringify(data)); + console.info('getCallingBundle err: ' + JSON.stringify(err) + 'data: ' + JSON.stringify(data)); }); ``` @@ -811,7 +811,7 @@ getCallingBundle(): Promise\ import featureAbility from '@ohos.ability.featureAbility'; let context = featureAbility.getContext(); context.getCallingBundle().then((data) => { - console.info("getCallingBundle data: " + JSON.stringify(data)); + console.info('getCallingBundle data: ' + JSON.stringify(data)); }); ``` @@ -835,7 +835,7 @@ getCacheDir(callback: AsyncCallback\): void import featureAbility from '@ohos.ability.featureAbility'; let context = featureAbility.getContext(); context.getCacheDir((err, data) => { - console.info("getCacheDir err: " + JSON.stringify(err) + "data: " + JSON.stringify(data)); + console.info('getCacheDir err: ' + JSON.stringify(err) + 'data: ' + JSON.stringify(data)); }); ``` @@ -859,7 +859,7 @@ getCacheDir(): Promise\ import featureAbility from '@ohos.ability.featureAbility'; let context = featureAbility.getContext(); context.getCacheDir().then((data) => { - console.info("getCacheDir data: " + JSON.stringify(data)); + console.info('getCacheDir data: ' + JSON.stringify(data)); }); ``` @@ -883,7 +883,7 @@ getFilesDir(callback: AsyncCallback\): void import featureAbility from '@ohos.ability.featureAbility'; let context = featureAbility.getContext(); context.getFilesDir((err, data) => { - console.info("getFilesDir err: " + JSON.stringify(err) + "data: " + JSON.stringify(data)); + console.info('getFilesDir err: ' + JSON.stringify(err) + 'data: ' + JSON.stringify(data)); }); ``` @@ -907,7 +907,7 @@ getFilesDir(): Promise\ import featureAbility from '@ohos.ability.featureAbility'; let context = featureAbility.getContext(); context.getFilesDir().then((data) => { - console.info("getFilesDir data: " + JSON.stringify(data)); + console.info('getFilesDir data: ' + JSON.stringify(data)); }); ``` @@ -933,7 +933,7 @@ getOrCreateDistributedDir(callback: AsyncCallback\): void import featureAbility from '@ohos.ability.featureAbility'; let context = featureAbility.getContext(); context.getOrCreateDistributedDir((err, data) => { - console.info("getOrCreateDistributedDir err: " + JSON.stringify(err) + "data: " + JSON.stringify(data)); + console.info('getOrCreateDistributedDir err: ' + JSON.stringify(err) + 'data: ' + JSON.stringify(data)); }); ``` @@ -959,7 +959,7 @@ getOrCreateDistributedDir(): Promise\ import featureAbility from '@ohos.ability.featureAbility'; let context = featureAbility.getContext(); context.getOrCreateDistributedDir().then((data) => { - console.info("getOrCreateDistributedDir data: " + JSON.stringify(data)); + console.info('getOrCreateDistributedDir data: ' + JSON.stringify(data)); }); ``` @@ -983,7 +983,7 @@ getAppType(callback: AsyncCallback\): void import featureAbility from '@ohos.ability.featureAbility'; let context = featureAbility.getContext(); context.getAppType((err, data) => { - console.info("getAppType err: " + JSON.stringify(err) + "data: " + JSON.stringify(data)); + console.info('getAppType err: ' + JSON.stringify(err) + 'data: ' + JSON.stringify(data)); }); ``` @@ -1007,7 +1007,7 @@ getAppType(): Promise\ import featureAbility from '@ohos.ability.featureAbility'; let context = featureAbility.getContext(); context.getAppType().then((data) => { - console.info("getAppType data: " + JSON.stringify(data)); + console.info('getAppType data: ' + JSON.stringify(data)); }); ``` @@ -1031,7 +1031,7 @@ getHapModuleInfo(callback: AsyncCallback\): void import featureAbility from '@ohos.ability.featureAbility'; let context = featureAbility.getContext(); context.getHapModuleInfo((err, data) => { - console.info("getHapModuleInfo err: " + JSON.stringify(err) + "data: " + JSON.stringify(data)); + console.info('getHapModuleInfo err: ' + JSON.stringify(err) + 'data: ' + JSON.stringify(data)); }); ``` @@ -1055,7 +1055,7 @@ getHapModuleInfo(): Promise\ import featureAbility from '@ohos.ability.featureAbility'; let context = featureAbility.getContext(); context.getHapModuleInfo().then((data) => { - console.info("getHapModuleInfo data: " + JSON.stringify(data)); + console.info('getHapModuleInfo data: ' + JSON.stringify(data)); }); ``` @@ -1079,7 +1079,7 @@ getAppVersionInfo(callback: AsyncCallback\): void import featureAbility from '@ohos.ability.featureAbility'; let context = featureAbility.getContext(); context.getAppVersionInfo((err, data) => { - console.info("getAppVersionInfo err: " + JSON.stringify(err) + "data: " + JSON.stringify(data)); + console.info('getAppVersionInfo err: ' + JSON.stringify(err) + 'data: ' + JSON.stringify(data)); }); ``` @@ -1103,7 +1103,7 @@ getAppVersionInfo(): Promise\ import featureAbility from '@ohos.ability.featureAbility'; let context = featureAbility.getContext(); context.getAppVersionInfo().then((data) => { - console.info("getAppVersionInfo data: " + JSON.stringify(data)); + console.info('getAppVersionInfo data: ' + JSON.stringify(data)); }); ``` @@ -1127,7 +1127,7 @@ getAbilityInfo(callback: AsyncCallback\): void import featureAbility from '@ohos.ability.featureAbility'; let context = featureAbility.getContext(); context.getAbilityInfo((err, data) => { - console.info("getAbilityInfo err: " + JSON.stringify(err) + "data: " + JSON.stringify(data)); + console.info('getAbilityInfo err: ' + JSON.stringify(err) + 'data: ' + JSON.stringify(data)); }); ``` @@ -1151,7 +1151,7 @@ getAbilityInfo(): Promise\ import featureAbility from '@ohos.ability.featureAbility'; let context = featureAbility.getContext(); context.getAbilityInfo().then((data) => { - console.info("getAbilityInfo data: " + JSON.stringify(data)); + console.info('getAbilityInfo data: ' + JSON.stringify(data)); }); ``` @@ -1196,7 +1196,7 @@ isUpdatingConfigurations(callback: AsyncCallback\): void; import featureAbility from '@ohos.ability.featureAbility'; let context = featureAbility.getContext(); context.isUpdatingConfigurations((err, data) => { - console.info("isUpdatingConfigurations err: " + JSON.stringify(err) + "data: " + JSON.stringify(data)); + console.info('isUpdatingConfigurations err: ' + JSON.stringify(err) + 'data: ' + JSON.stringify(data)); }); ``` @@ -1220,7 +1220,7 @@ isUpdatingConfigurations(): Promise\; import featureAbility from '@ohos.ability.featureAbility'; let context = featureAbility.getContext(); context.isUpdatingConfigurations().then((data) => { - console.info("isUpdatingConfigurations data: " + JSON.stringify(data)); + console.info('isUpdatingConfigurations data: ' + JSON.stringify(data)); }); ``` @@ -1268,7 +1268,7 @@ printDrawnCompleted(): Promise\; import featureAbility from '@ohos.ability.featureAbility'; let context = featureAbility.getContext(); context.printDrawnCompleted().then((data) => { - console.info("printDrawnCompleted data: " + JSON.stringify(data)); + console.info('printDrawnCompleted data: ' + JSON.stringify(data)); }); ``` diff --git a/zh-cn/application-dev/reference/apis/js-apis-inner-app-processInfo.md b/zh-cn/application-dev/reference/apis/js-apis-inner-app-processInfo.md index bcb283693fd299d935a7afa82ca181b9a08c91bf..25311ca75c7cf4a302918a7168d07ed41a1b6b15 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-inner-app-processInfo.md +++ b/zh-cn/application-dev/reference/apis/js-apis-inner-app-processInfo.md @@ -19,8 +19,8 @@ import featureAbility from '@ohos.ability.featureAbility'; let context = featureAbility.getContext(); context.getProcessInfo((err, data) => { - if (err.code != 0) { - console.info("getProcessInfo err: " + JSON.stringify(err) + "data: " + JSON.stringify(data)); + if (err.code !== 0) { + console.info('getProcessInfo err: ' + JSON.stringify(err) + 'data: ' + JSON.stringify(data)); let pid = data.pid; let processName = data.processName; } diff --git a/zh-cn/application-dev/reference/apis/js-apis-inner-application-abilityDelegator.md b/zh-cn/application-dev/reference/apis/js-apis-inner-application-abilityDelegator.md index fe66bf067e46dbd9dc5e7e720517f4686999c5ac..a67ca15d48554775698d7a7fc98c4caf622cc985 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-inner-application-abilityDelegator.md +++ b/zh-cn/application-dev/reference/apis/js-apis-inner-application-abilityDelegator.md @@ -38,17 +38,17 @@ addAbilityMonitor(monitor: AbilityMonitor, callback: AsyncCallback\): void var abilityDelegator; function onAbilityCreateCallback(data) { - console.info("onAbilityCreateCallback"); + console.info('onAbilityCreateCallback'); } var monitor = { - abilityName: "abilityname", + abilityName: 'abilityname', onAbilityCreate: onAbilityCreateCallback -} +}; abilityDelegator = AbilityDelegatorRegistry.getAbilityDelegator(); abilityDelegator.addAbilityMonitor(monitor, (err : any) => { - console.info("addAbilityMonitor callback"); + console.info('addAbilityMonitor callback'); }); ``` @@ -78,17 +78,17 @@ addAbilityMonitor(monitor: AbilityMonitor): Promise\; var abilityDelegator; function onAbilityCreateCallback(data) { - console.info("onAbilityCreateCallback"); + console.info('onAbilityCreateCallback'); } var monitor = { - abilityName: "abilityname", + abilityName: 'abilityname', onAbilityCreate: onAbilityCreateCallback -} +}; abilityDelegator = AbilityDelegatorRegistry.getAbilityDelegator(); abilityDelegator.addAbilityMonitor(monitor).then(() => { - console.info("addAbilityMonitor promise"); + console.info('addAbilityMonitor promise'); }); ``` @@ -115,17 +115,17 @@ removeAbilityMonitor(monitor: AbilityMonitor, callback: AsyncCallback\): v var abilityDelegator; function onAbilityCreateCallback(data) { - console.info("onAbilityCreateCallback"); + console.info('onAbilityCreateCallback'); } var monitor = { - abilityName: "abilityname", + abilityName: 'abilityname', onAbilityCreate: onAbilityCreateCallback -} +}; abilityDelegator = AbilityDelegatorRegistry.getAbilityDelegator(); abilityDelegator.removeAbilityMonitor(monitor, (err : any) => { - console.info("removeAbilityMonitor callback"); + console.info('removeAbilityMonitor callback'); }); ``` @@ -157,17 +157,17 @@ removeAbilityMonitor(monitor: AbilityMonitor): Promise\; var abilityDelegator; function onAbilityCreateCallback(data) { - console.info("onAbilityCreateCallback"); + console.info('onAbilityCreateCallback'); } var monitor = { - abilityName: "abilityname", + abilityName: 'abilityname', onAbilityCreate: onAbilityCreateCallback -} +}; abilityDelegator = AbilityDelegatorRegistry.getAbilityDelegator(); abilityDelegator.removeAbilityMonitor(monitor).then(() => { - console.info("removeAbilityMonitor promise"); + console.info('removeAbilityMonitor promise'); }); ``` @@ -194,17 +194,17 @@ waitAbilityMonitor(monitor: AbilityMonitor, callback: AsyncCallback\) var abilityDelegator; function onAbilityCreateCallback(data) { - console.info("onAbilityCreateCallback"); + console.info('onAbilityCreateCallback'); } var monitor = { - abilityName: "abilityname", + abilityName: 'abilityname', onAbilityCreate: onAbilityCreateCallback -} +}; abilityDelegator = AbilityDelegatorRegistry.getAbilityDelegator(); abilityDelegator.waitAbilityMonitor(monitor, (err : any, data : any) => { - console.info("waitAbilityMonitor callback"); + console.info('waitAbilityMonitor callback'); }); ``` @@ -231,17 +231,17 @@ var abilityDelegator; var timeout = 100; function onAbilityCreateCallback(data) { - console.info("onAbilityCreateCallback"); + console.info('onAbilityCreateCallback'); } var monitor = { - abilityName: "abilityname", + abilityName: 'abilityname', onAbilityCreate: onAbilityCreateCallback -} +}; abilityDelegator = AbilityDelegatorRegistry.getAbilityDelegator(); abilityDelegator.waitAbilityMonitor(monitor, timeout, (err : any, data : any) => { - console.info("waitAbilityMonitor callback"); + console.info('waitAbilityMonitor callback'); }); ``` @@ -274,17 +274,17 @@ waitAbilityMonitor(monitor: AbilityMonitor, timeout?: number): Promise\ { - console.info("waitAbilityMonitor promise"); + console.info('waitAbilityMonitor promise'); }); ``` @@ -343,10 +343,10 @@ var ability; abilityDelegator = AbilityDelegatorRegistry.getAbilityDelegator(); abilityDelegator.getCurrentTopAbility((err : any, data : any) => { - console.info("getCurrentTopAbility callback"); + console.info('getCurrentTopAbility callback'); ability = data; var state = abilityDelegator.getAbilityState(ability); - console.info("getAbilityState" + state); + console.info('getAbilityState' + state); }); ``` @@ -374,7 +374,7 @@ var ability; abilityDelegator = AbilityDelegatorRegistry.getAbilityDelegator(); abilityDelegator.getCurrentTopAbility((err : any, data : any) => { - console.info("getCurrentTopAbility callback"); + console.info('getCurrentTopAbility callback'); ability = data; }); ``` @@ -403,7 +403,7 @@ var ability; abilityDelegator = AbilityDelegatorRegistry.getAbilityDelegator(); abilityDelegator.getCurrentTopAbility().then((data : any) => { - console.info("getCurrentTopAbility promise"); + console.info('getCurrentTopAbility promise'); ability = data; }); ``` @@ -430,13 +430,13 @@ startAbility(want: Want, callback: AsyncCallback\): void; ```ts var abilityDelegator; var want = { - bundleName: "bundleName", - abilityName: "abilityName" + bundleName: 'bundleName', + abilityName: 'abilityName' }; abilityDelegator = AbilityDelegatorRegistry.getAbilityDelegator(); abilityDelegator.startAbility(want, (err : any, data : any) => { - console.info("startAbility callback"); + console.info('startAbility callback'); }); ``` @@ -467,13 +467,13 @@ startAbility(want: Want): Promise\; ```ts var abilityDelegator; var want = { - bundleName: "bundleName", - abilityName: "abilityName" + bundleName: 'bundleName', + abilityName: 'abilityName' }; abilityDelegator = AbilityDelegatorRegistry.getAbilityDelegator(); abilityDelegator.startAbility(want).then((data: any) => { - console.info("startAbility promise"); + console.info('startAbility promise'); }); ``` @@ -502,10 +502,10 @@ var ability; abilityDelegator = AbilityDelegatorRegistry.getAbilityDelegator(); abilityDelegator.getCurrentTopAbility((err : any, data : any) => { - console.info("getCurrentTopAbility callback"); + console.info('getCurrentTopAbility callback'); ability = data; abilityDelegator.doAbilityForeground(ability, (err : any, data : any) => { - console.info("doAbilityForeground callback"); + console.info('doAbilityForeground callback'); }); }); ``` @@ -540,10 +540,10 @@ var ability; abilityDelegator = AbilityDelegatorRegistry.getAbilityDelegator(); abilityDelegator.getCurrentTopAbility((err : any, data : any) => { - console.info("getCurrentTopAbility callback"); + console.info('getCurrentTopAbility callback'); ability = data; abilityDelegator.doAbilityForeground(ability).then((data : any) => { - console.info("doAbilityForeground promise"); + console.info('doAbilityForeground promise'); }); }); ``` @@ -573,10 +573,10 @@ var ability; abilityDelegator = AbilityDelegatorRegistry.getAbilityDelegator(); abilityDelegator.getCurrentTopAbility((err : any, data : any) => { - console.info("getCurrentTopAbility callback"); + console.info('getCurrentTopAbility callback'); ability = data; abilityDelegator.doAbilityBackground(ability, (err : any, data : any) => { - console.info("doAbilityBackground callback"); + console.info('doAbilityBackground callback'); }); }); ``` @@ -611,10 +611,10 @@ var ability; abilityDelegator = AbilityDelegatorRegistry.getAbilityDelegator(); abilityDelegator.getCurrentTopAbility((err : any, data : any) => { - console.info("getCurrentTopAbility callback"); + console.info('getCurrentTopAbility callback'); ability = data; abilityDelegator.doAbilityBackground(ability).then((data : any) => { - console.info("doAbilityBackground promise"); + console.info('doAbilityBackground promise'); }); }); ``` @@ -639,7 +639,7 @@ printSync(msg: string): void; ```ts var abilityDelegator; -var msg = "msg"; +var msg = 'msg'; abilityDelegator = AbilityDelegatorRegistry.getAbilityDelegator(); abilityDelegator.printSync(msg); @@ -666,11 +666,11 @@ print(msg: string, callback: AsyncCallback\): void; ```ts var abilityDelegator; -var msg = "msg"; +var msg = 'msg'; abilityDelegator = AbilityDelegatorRegistry.getAbilityDelegator(); abilityDelegator.print(msg, (err : any) => { - console.info("print callback"); + console.info('print callback'); }); ``` @@ -700,11 +700,11 @@ print(msg: string): Promise\; ```ts var abilityDelegator; -var msg = "msg"; +var msg = 'msg'; abilityDelegator = AbilityDelegatorRegistry.getAbilityDelegator(); abilityDelegator.print(msg).then(() => { - console.info("print promise"); + console.info('print promise'); }); ``` @@ -729,11 +729,11 @@ executeShellCommand(cmd: string, callback: AsyncCallback\): void ```ts var abilityDelegator; -var cmd = "cmd"; +var cmd = 'cmd'; abilityDelegator = AbilityDelegatorRegistry.getAbilityDelegator(); abilityDelegator.executeShellCommand(cmd, (err : any, data : any) => { - console.info("executeShellCommand callback"); + console.info('executeShellCommand callback'); }); ``` @@ -759,12 +759,12 @@ executeShellCommand(cmd: string, timeoutSecs: number, callback: AsyncCallback\ { - console.info("executeShellCommand callback"); + console.info('executeShellCommand callback'); }); ``` @@ -795,12 +795,12 @@ executeShellCommand(cmd: string, timeoutSecs?: number): Promise\ ```ts var abilityDelegator; -var cmd = "cmd"; +var cmd = 'cmd'; var timeout = 100; abilityDelegator = AbilityDelegatorRegistry.getAbilityDelegator(); abilityDelegator.executeShellCommand(cmd, timeout).then((data : any) => { - console.info("executeShellCommand promise"); + console.info('executeShellCommand promise'); }); ``` @@ -826,11 +826,11 @@ finishTest(msg: string, code: number, callback: AsyncCallback\): void; ```ts var abilityDelegator; -var msg = "msg"; +var msg = 'msg'; abilityDelegator = AbilityDelegatorRegistry.getAbilityDelegator(); abilityDelegator.finishTest(msg, 0, (err : any) => { - console.info("finishTest callback"); + console.info('finishTest callback'); }); ``` @@ -861,11 +861,11 @@ finishTest(msg: string, code: number): Promise\; ```ts var abilityDelegator; -var msg = "msg"; +var msg = 'msg'; abilityDelegator = AbilityDelegatorRegistry.getAbilityDelegator(); abilityDelegator.finishTest(msg, 0).then(() => { - console.info("finishTest promise"); + console.info('finishTest promise'); }); ``` @@ -890,13 +890,13 @@ addAbilityStageMonitor(monitor: AbilityStageMonitor, callback: AsyncCallback\ { - console.info("addAbilityStageMonitor callback"); + console.info('addAbilityStageMonitor callback'); }); ``` @@ -928,13 +928,13 @@ addAbilityStageMonitor(monitor: AbilityStageMonitor): Promise\; var abilityDelegator; var monitor = { - moduleName: "moduleName", - srcEntrance: "srcEntrance", -} + moduleName: 'moduleName', + srcEntrance: 'srcEntrance', +}; abilityDelegator = AbilityDelegatorRegistry.getAbilityDelegator(); abilityDelegator.addAbilityStageMonitor(monitor).then(() => { - console.info("addAbilityStageMonitor promise"); + console.info('addAbilityStageMonitor promise'); }); ``` @@ -959,13 +959,13 @@ removeAbilityStageMonitor(monitor: AbilityStageMonitor, callback: AsyncCallback\ var abilityDelegator; var monitor = { - moduleName: "moduleName", - srcEntrance: "srcEntrance", -} + moduleName: 'moduleName', + srcEntrance: 'srcEntrance', +}; abilityDelegator = AbilityDelegatorRegistry.getAbilityDelegator(); abilityDelegator.removeAbilityStageMonitor(monitor, (err : any) => { - console.info("removeAbilityStageMonitor callback"); + console.info('removeAbilityStageMonitor callback'); }); ``` @@ -997,13 +997,13 @@ removeAbilityStageMonitor(monitor: AbilityStageMonitor): Promise\; var abilityDelegator; var monitor = { - moduleName: "moduleName", - srcEntrance: "srcEntrance", -} + moduleName: 'moduleName', + srcEntrance: 'srcEntrance', +}; abilityDelegator = AbilityDelegatorRegistry.getAbilityDelegator(); abilityDelegator.removeAbilityStageMonitor(monitor).then(() => { - console.info("removeAbilityStageMonitor promise"); + console.info('removeAbilityStageMonitor promise'); }); ``` @@ -1028,17 +1028,17 @@ waitAbilityStageMonitor(monitor: AbilityStageMonitor, callback: AsyncCallback\ { - console.info("waitAbilityStageMonitor callback"); + console.info('waitAbilityStageMonitor callback'); }); ``` @@ -1069,17 +1069,17 @@ waitAbilityStageMonitor(monitor: AbilityStageMonitor, timeout?: number): Promise var abilityDelegator; function onAbilityCreateCallback(data) { - console.info("onAbilityCreateCallback"); + console.info('onAbilityCreateCallback'); } var monitor = { - moduleName: "moduleName", - srcEntrance: "srcEntrance", -} + moduleName: 'moduleName', + srcEntrance: 'srcEntrance', +}; abilityDelegator = AbilityDelegatorRegistry.getAbilityDelegator(); abilityDelegator.waitAbilityStageMonitor(monitor).then((data : any) => { - console.info("waitAbilityStageMonitor promise"); + console.info('waitAbilityStageMonitor promise'); }); ``` @@ -1106,16 +1106,16 @@ var abilityDelegator; var timeout = 100; function onAbilityCreateCallback(data) { - console.info("onAbilityCreateCallback"); + console.info('onAbilityCreateCallback'); } var monitor = { - moduleName: "moduleName", - srcEntrance: "srcEntrance", -} + moduleName: 'moduleName', + srcEntrance: 'srcEntrance', +}; abilityDelegator = AbilityDelegatorRegistry.getAbilityDelegator(); abilityDelegator.waitAbilityStageMonitor(monitor, timeout, (err : any, data : any) => { - console.info("waitAbilityStageMonitor callback"); + console.info('waitAbilityStageMonitor callback'); }); ``` \ No newline at end of file diff --git a/zh-cn/application-dev/reference/apis/js-apis-inner-application-abilityMonitor.md b/zh-cn/application-dev/reference/apis/js-apis-inner-application-abilityMonitor.md index 6026ff334b32e0892c8e6061073eed11efc2841d..64de807614db6017592851defba085fea411d366 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-inner-application-abilityMonitor.md +++ b/zh-cn/application-dev/reference/apis/js-apis-inner-application-abilityMonitor.md @@ -30,20 +30,20 @@ Ability监听器 **示例:** ```ts -import AbilityDelegatorRegistry from '@ohos.application.abilityDelegatorRegistry' +import AbilityDelegatorRegistry from '@ohos.application.abilityDelegatorRegistry'; function onAbilityCreateCallback(data) { - console.info("onAbilityCreateCallback"); + console.info('onAbilityCreateCallback'); } let monitor = { - abilityName: "abilityname", + abilityName: 'abilityname', onAbilityCreate: onAbilityCreateCallback -} +}; let abilityDelegator = AbilityDelegatorRegistry.getAbilityDelegator(); abilityDelegator.addAbilityMonitor(monitor, (err : any) => { - console.info("addAbilityMonitor callback"); + console.info('addAbilityMonitor callback'); }); ``` diff --git a/zh-cn/application-dev/reference/apis/js-apis-inner-application-abilityRunningInfo.md b/zh-cn/application-dev/reference/apis/js-apis-inner-application-abilityRunningInfo.md index 79dd323daeeef52717d3d571181603ed51affe57..20d0ea03a7e0c6e94b7dc2967815ed5c4ca0e234 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-inner-application-abilityRunningInfo.md +++ b/zh-cn/application-dev/reference/apis/js-apis-inner-application-abilityRunningInfo.md @@ -30,15 +30,15 @@ AbilityRunningInfo模块提供对Ability运行的相关信息和状态的定义 ```ts import abilitymanager from '@ohos.application.abilityManager'; abilitymanager.getAbilityRunningInfos((err,data) => { - console.log("getAbilityRunningInfos err: " + err + " data: " + JSON.stringify(data)); + console.log('getAbilityRunningInfos err: ' + err + ' data: ' + JSON.stringify(data)); for (let i = 0; i < data.length; i++) { let abilityinfo = data[i]; - console.log("abilityinfo.ability: " + JSON.stringify(abilityinfo.ability)); - console.log("abilityinfo.pid: " + JSON.stringify(abilityinfo.pid)); - console.log("abilityinfo.uid: " + JSON.stringify(abilityinfo.uid)); - console.log("abilityinfo.processName: " + JSON.stringify(abilityinfo.processName)); - console.log("abilityinfo.startTime: " + JSON.stringify(abilityinfo.startTime)); - console.log("abilityinfo.abilityState: " + JSON.stringify(abilityinfo.abilityState)); + console.log('abilityinfo.ability: ' + JSON.stringify(abilityinfo.ability)); + console.log('abilityinfo.pid: ' + JSON.stringify(abilityinfo.pid)); + console.log('abilityinfo.uid: ' + JSON.stringify(abilityinfo.uid)); + console.log('abilityinfo.processName: ' + JSON.stringify(abilityinfo.processName)); + console.log('abilityinfo.startTime: ' + JSON.stringify(abilityinfo.startTime)); + console.log('abilityinfo.abilityState: ' + JSON.stringify(abilityinfo.abilityState)); } }); ``` \ No newline at end of file diff --git a/zh-cn/application-dev/reference/apis/js-apis-inner-application-abilityStageMonitor.md b/zh-cn/application-dev/reference/apis/js-apis-inner-application-abilityStageMonitor.md index 840cc6da4dab10dd9bb3898dbdb2a4ce59422b74..e26bce07a1139d9dd606960bcd8d6b7eeb1b5929 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-inner-application-abilityStageMonitor.md +++ b/zh-cn/application-dev/reference/apis/js-apis-inner-application-abilityStageMonitor.md @@ -11,15 +11,15 @@ **示例:** ```ts -import AbilityDelegatorRegistry from '@ohos.application.abilityDelegatorRegistry' +import AbilityDelegatorRegistry from '@ohos.application.abilityDelegatorRegistry'; let monitor = { - moduleName: "feature_as1", - srcEntrance: "./ets/Application/MyAbilityStage.ts", + moduleName: 'feature_as1', + srcEntrance: './ets/Application/MyAbilityStage.ts', }; let abilityDelegator = AbilityDelegatorRegistry.getAbilityDelegator(); abilityDelegator.waitAbilityStageMonitor(monitor, (error, data) => { - console.info("stageMonitor waitAbilityStageMonitor, abilityStage = " + JSON.stringify(data)); + console.info('stageMonitor waitAbilityStageMonitor, abilityStage = ' + JSON.stringify(data)); }); ``` \ No newline at end of file diff --git a/zh-cn/application-dev/reference/apis/js-apis-inner-application-accessibilityExtensionContext.md b/zh-cn/application-dev/reference/apis/js-apis-inner-application-accessibilityExtensionContext.md index c8f5e4da876638902846162cf47b1ae70547abf5..27320dfe20f24b683e2f9b383d7d209a9a7f2964 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-inner-application-accessibilityExtensionContext.md +++ b/zh-cn/application-dev/reference/apis/js-apis-inner-application-accessibilityExtensionContext.md @@ -14,7 +14,7 @@ AccessibilityExtensionContext是AccessibilityExtensionAbility上下文环境, 在使用AccessibilityExtensionContext的功能前,需要通过AccessibilityExtensionAbility子类实例获取AccessibilityExtensionContex的实例。 ```ts -import AccessibilityExtensionAbility from '@ohos.application.AccessibilityExtensionAbility' +import AccessibilityExtensionAbility from '@ohos.application.AccessibilityExtensionAbility'; let axContext; class MainAbility extends AccessibilityExtensionAbility { onConnect(): void { @@ -541,7 +541,7 @@ injectGesture(gesturePath: GesturePath): Promise\; **示例:** ```ts -import GesturePath from "@ohos.accessibility.GesturePath"; +import GesturePath from '@ohos.accessibility.GesturePath'; import GesturePoint from '@ohos.accessibility.GesturePoint'; let gesturePath = new GesturePath.GesturePath(100); try { @@ -584,7 +584,7 @@ injectGesture(gesturePath: GesturePath, callback: AsyncCallback\): void **示例:** ```ts -import GesturePath from "@ohos.accessibility.GesturePath"; +import GesturePath from '@ohos.accessibility.GesturePath'; import GesturePoint from '@ohos.accessibility.GesturePoint'; let gesturePath = new GesturePath.GesturePath(100); try { diff --git a/zh-cn/application-dev/reference/apis/js-apis-inner-application-appStateData.md b/zh-cn/application-dev/reference/apis/js-apis-inner-application-appStateData.md index 2dce76952c4df946a96f2545b4708c1334c5a317..5cc5df0eaa1f7a97de9f4057db4f8fda32b9550a 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-inner-application-appStateData.md +++ b/zh-cn/application-dev/reference/apis/js-apis-inner-application-appStateData.md @@ -14,7 +14,7 @@ **示例:** ```ts -import appManager from "@ohos.application.appManager" +import appManager from "@ohos.application.appManager"; appManager.getForegroundApplications((error, data) => { for (let i = 0; i < data.length; i++) { diff --git a/zh-cn/application-dev/reference/apis/js-apis-inner-application-applicationContext.md b/zh-cn/application-dev/reference/apis/js-apis-inner-application-applicationContext.md index 89accd1caa760ef3f756d56caaf0e8f77415fee5..8aa9decb03d6ff26d7ccfaf3ae46b4947ed4323d 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-inner-application-applicationContext.md +++ b/zh-cn/application-dev/reference/apis/js-apis-inner-application-applicationContext.md @@ -15,9 +15,9 @@ ApplicationContext模块提供开发者应用级别的的上下文的能力, let applicationContext = this.context.getApplicationContext(); ``` -## ApplicationContext.on(type: "abilityLifecycle", callback: AbilityLifecycleCallback) +## ApplicationContext.on(type: 'abilityLifecycle', callback: AbilityLifecycleCallback) -on(type: "abilityLifecycle", callback: AbilityLifecycleCallback): **number**; +on(type: 'abilityLifecycle', callback: AbilityLifecycleCallback): **number**; 注册监听应用内生命周期 @@ -27,7 +27,7 @@ on(type: "abilityLifecycle", callback: AbilityLifecycleCallback): **number**; | 参数名 | 类型 | 必填 | 说明 | | ------------------------ | -------- | ---- | ------------------------------ | -| type | "abilityLifecycle" | 是 | 监听事件的类型。 | +| type | 'abilityLifecycle' | 是 | 监听事件的类型。 | | callback | [AbilityLifecycleCallback](js-apis-app-ability-abilityLifecycleCallback.md) | 是 | 回调方法,返回注册监听事件的ID。 | **返回值:** @@ -45,52 +45,52 @@ let lifecycleId; export default class EntryAbility extends UIAbility { onCreate() { - console.log("MyAbility onCreate") + console.log('MyAbility onCreate'); let AbilityLifecycleCallback = { onAbilityCreate(ability) { - console.log("AbilityLifecycleCallback onAbilityCreate ability:" + ability); + console.log('AbilityLifecycleCallback onAbilityCreate ability:' + ability); }, onWindowStageCreate(ability, windowStage) { - console.log("AbilityLifecycleCallback onWindowStageCreate ability:" + ability); - console.log("AbilityLifecycleCallback onWindowStageCreate windowStage:" + windowStage); + console.log('AbilityLifecycleCallback onWindowStageCreate ability:' + ability); + console.log('AbilityLifecycleCallback onWindowStageCreate windowStage:' + windowStage); }, onWindowStageActive(ability, windowStage) { - console.log("AbilityLifecycleCallback onWindowStageActive ability:" + ability); - console.log("AbilityLifecycleCallback onWindowStageActive windowStage:" + windowStage); + console.log('AbilityLifecycleCallback onWindowStageActive ability:' + ability); + console.log('AbilityLifecycleCallback onWindowStageActive windowStage:' + windowStage); }, onWindowStageInactive(ability, windowStage) { - console.log("AbilityLifecycleCallback onWindowStageInactive ability:" + ability); - console.log("AbilityLifecycleCallback onWindowStageInactive windowStage:" + windowStage); + console.log('AbilityLifecycleCallback onWindowStageInactive ability:' + ability); + console.log('AbilityLifecycleCallback onWindowStageInactive windowStage:' + windowStage); }, onWindowStageDestroy(ability, windowStage) { - console.log("AbilityLifecycleCallback onWindowStageDestroy ability:" + ability); - console.log("AbilityLifecycleCallback onWindowStageDestroy windowStage:" + windowStage); + console.log('AbilityLifecycleCallback onWindowStageDestroy ability:' + ability); + console.log('AbilityLifecycleCallback onWindowStageDestroy windowStage:' + windowStage); }, onAbilityDestroy(ability) { - console.log("AbilityLifecycleCallback onAbilityDestroy ability:" + ability); + console.log('AbilityLifecycleCallback onAbilityDestroy ability:' + ability); }, onAbilityForeground(ability) { - console.log("AbilityLifecycleCallback onAbilityForeground ability:" + ability); + console.log('AbilityLifecycleCallback onAbilityForeground ability:' + ability); }, onAbilityBackground(ability) { - console.log("AbilityLifecycleCallback onAbilityBackground ability:" + ability); + console.log('AbilityLifecycleCallback onAbilityBackground ability:' + ability); }, onAbilityContinue(ability) { - console.log("AbilityLifecycleCallback onAbilityContinue ability:" + ability); + console.log('AbilityLifecycleCallback onAbilityContinue ability:' + ability); } } // 1.通过context属性获取applicationContext let applicationContext = this.context.getApplicationContext(); // 2.通过applicationContext注册监听应用内生命周期 - lifecycleId = applicationContext.on("abilityLifecycle", AbilityLifecycleCallback); - console.log("registerAbilityLifecycleCallback number: " + JSON.stringify(lifecycleId)); + lifecycleId = applicationContext.on('abilityLifecycle', AbilityLifecycleCallback); + console.log('registerAbilityLifecycleCallback number: ' + JSON.stringify(lifecycleId)); } } ``` -## ApplicationContext.off(type: "abilityLifecycle", callbackId: number, callback: AsyncCallback) +## ApplicationContext.off(type: 'abilityLifecycle', callbackId: number, callback: AsyncCallback) -off(type: "abilityLifecycle", callbackId: **number**, callback: AsyncCallback<**void**>): **void**; +off(type: 'abilityLifecycle', callbackId: **number**, callback: AsyncCallback<**void**>): **void**; 取消监听应用内生命周期 @@ -100,7 +100,7 @@ off(type: "abilityLifecycle", callbackId: **number**, callback: AsyncCallback<* | 参数名 | 类型 | 必填 | 说明 | | ------------- | -------- | ---- | -------------------------- | -| type | "abilityLifecycle" | 是 | 取消监听事件的类型。 | +| type | 'abilityLifecycle' | 是 | 取消监听事件的类型。 | | callbackId | number | 是 | 注册监听应用内生命周期的ID。 | | callback | AsyncCallback\ | 是 | 回调方法。 | @@ -114,17 +114,17 @@ let lifecycleId; export default class EntryAbility extends UIAbility { onDestroy() { let applicationContext = this.context.getApplicationContext(); - console.log("stage applicationContext: " + applicationContext); - applicationContext.off(type: "abilityLifecycle", lifecycleId, (error, data) => { - console.log("unregisterAbilityLifecycleCallback success, err: " + JSON.stringify(error)); + console.log('stage applicationContext: ' + applicationContext); + applicationContext.off(type: 'abilityLifecycle', lifecycleId, (error, data) => { + console.log('unregisterAbilityLifecycleCallback success, err: ' + JSON.stringify(error)); }); } } ``` -## ApplicationContext.off(type: "abilityLifecycle", callbackId: number) +## ApplicationContext.off(type: 'abilityLifecycle', callbackId: number) -off(type: "abilityLifecycle", callbackId: **number**): **void**; +off(type: 'abilityLifecycle', callbackId: **number**): **void**; 取消监听应用内生命周期 @@ -134,28 +134,28 @@ off(type: "abilityLifecycle", callbackId: **number**): **void**; | 参数名 | 类型 | 必填 | 说明 | | ------------- | -------- | ---- | -------------------------- | -| type | "abilityLifecycle" | 是 | 取消监听事件的类型。 | +| type | 'abilityLifecycle' | 是 | 取消监听事件的类型。 | | callbackId | number | 是 | 注册监听应用内生命周期的ID。 | **示例:** ```ts -import Ability from "@ohos.app.ability.UIAbility"; +import Ability from '@ohos.app.ability.UIAbility'; let lifecycleId; export default class MyAbility extends Ability { onDestroy() { let applicationContext = this.context.getApplicationContext(); - console.log("stage applicationContext: " + applicationContext); - applicationContext.off(type: "abilityLifecycle", lifecycleId); + console.log('stage applicationContext: ' + applicationContext); + applicationContext.off(type: 'abilityLifecycle', lifecycleId); } } ``` -## ApplicationContext.on(type: "environment", callback: EnvironmentCallback) +## ApplicationContext.on(type: 'environment', callback: EnvironmentCallback) -on(type: "environment", callback: EnvironmentCallback): **number**; +on(type: 'environment', callback: EnvironmentCallback): **number**; 注册对系统环境变化的监听。使用callback异步回调。 @@ -165,7 +165,7 @@ on(type: "environment", callback: EnvironmentCallback): **number**; | 参数名 | 类型 | 必填 | 说明 | | ------------------------ | -------- | ---- | ------------------------------ | -| type | "environment" | 是 | 监听事件的类型。 | +| type | 'environment' | 是 | 监听事件的类型。 | | callback | [EnvironmentCallback](js-apis-app-ability-environmentCallback.md) | 是 | 回调方法,返回注册监听事件的ID。 | **返回值:** @@ -183,28 +183,28 @@ let callbackId; export default class EntryAbility extends UIAbility { onCreate() { - console.log("MyAbility onCreate") + console.log('MyAbility onCreate') globalThis.applicationContext = this.context.getApplicationContext(); let EnvironmentCallback = { onConfigurationUpdated(config){ - console.log("onConfigurationUpdated config:" + JSON.stringify(config)); + console.log('onConfigurationUpdated config:' + JSON.stringify(config)); }, onMemoryLevel(level){ - console.log("onMemoryLevel level:" + level); + console.log('onMemoryLevel level:' + level); } } // 1.获取applicationContext let applicationContext = globalThis.applicationContext; // 2.通过applicationContext注册监听应用内生命周期 - callbackId = applicationContext.on("environment", EnvironmentCallback); - console.log("registerEnvironmentCallback number: " + JSON.stringify(callbackId)); + callbackId = applicationContext.on('environment', EnvironmentCallback); + console.log('registerEnvironmentCallback number: ' + JSON.stringify(callbackId)); } } ``` -## ApplicationContext.off(type: "environment", callbackId: number, callback: AsyncCallback) +## ApplicationContext.off(type: 'environment', callbackId: number, callback: AsyncCallback) -off(type: "environment", callbackId: **number**, callback: AsyncCallback<**void**>): **void**; +off(type: 'environment', callbackId: **number**, callback: AsyncCallback<**void**>): **void**; 取消对系统环境变化的监听。使用callback异步回调。 @@ -214,7 +214,7 @@ off(type: "environment", callbackId: **number**, callback: AsyncCallback<**void | 参数名 | 类型 | 必填 | 说明 | | ------------- | -------- | ---- | -------------------------- | -| type | "environment" | 是 | 取消监听事件的类型。 | +| type | 'environment' | 是 | 取消监听事件的类型。 | | callbackId | number | 是 | 注册监听系统环境变化的ID。 | | callback | AsyncCallback\ | 是 | 回调方法。 | @@ -228,16 +228,16 @@ let callbackId; export default class EntryAbility extends UIAbility { onDestroy() { let applicationContext = this.context.getApplicationContext(); - applicationContext.off("environment", callbackId, (error, data) => { - console.log("unregisterEnvironmentCallback success, err: " + JSON.stringify(error)); + applicationContext.off('environment', callbackId, (error, data) => { + console.log('unregisterEnvironmentCallback success, err: ' + JSON.stringify(error)); }); } } ``` -## ApplicationContext.off(type: "environment", callbackId: number) +## ApplicationContext.off(type: 'environment', callbackId: number) -off(type: "environment", callbackId: **number**, callback: AsyncCallback<**void**>): **void**; +off(type: 'environment', callbackId: **number**, callback: AsyncCallback<**void**>): **void**; 取消对系统环境变化的监听。使用callback异步回调。 @@ -247,20 +247,20 @@ off(type: "environment", callbackId: **number**, callback: AsyncCallback<**void | 参数名 | 类型 | 必填 | 说明 | | ------------- | -------- | ---- | -------------------------- | -| type | "environment" | 是 | 取消监听事件的类型。 | +| type | 'environment' | 是 | 取消监听事件的类型。 | | callbackId | number | 是 | 注册监听系统环境变化的ID。 | **示例:** ```ts -import Ability from "@ohos.app.ability.UIAbility"; +import Ability from '@ohos.app.ability.UIAbility'; let callbackId; export default class MyAbility extends Ability { onDestroy() { let applicationContext = this.context.getApplicationContext(); - applicationContext.off("environment", callbackId); + applicationContext.off('environment', callbackId); } } ``` @@ -281,16 +281,16 @@ getProcessRunningInformation(): Promise\>; | 类型 | 说明 | | -------- | -------- | -| Promise\> | 以Promise方式返回接口运行结果及有关运行进程的信息,可进行错误处理或其他自定义处理。 | +| Promise\> | 以Promise方式返回接口运行结果及有关运行进程的信息,可进行错误处理或其他自定义处理。 | **示例:** ```ts let applicationContext = this.context.getApplicationContext(); applicationContext.getProcessRunningInformation().then((data) => { - console.log("The process running information is:" + JSON.stringify(data)); + console.log('The process running information is:' + JSON.stringify(data)); }).catch((error) => { - console.log("error:" + JSON.stringify(error)); + console.log('error:' + JSON.stringify(error)); }); ``` @@ -310,7 +310,7 @@ getProcessRunningInformation(callback: AsyncCallback\> | 以回调方式返回接口运行结果及有关运行进程的信息,可进行错误处理或其他自定义处理。 | +|AsyncCallback\> | 以回调方式返回接口运行结果及有关运行进程的信息,可进行错误处理或其他自定义处理。 | **示例:** @@ -318,9 +318,9 @@ getProcessRunningInformation(callback: AsyncCallback\ { if (err.code !== 0) { - console.error("getProcessRunningInformation faile, err: " + JSON.stringify(err)); + console.error('getProcessRunningInformation faile, err: ' + JSON.stringify(err)); } else { - console.log("The process running information is:" + JSON.stringify(data)); + console.log('The process running information is:' + JSON.stringify(data)); } }) ``` @@ -344,9 +344,9 @@ killProcessesBySelf(): Promise; ```ts let applicationContext = this.context.getApplicationContext(); applicationContext.killProcessesBySelf().then((data) => { - console.log("The process running information is:" + JSON.stringify(data)); + console.log('The process running information is:' + JSON.stringify(data)); }).catch((error) => { - console.error("error:" + JSON.stringify(error)); + console.error('error:' + JSON.stringify(error)); }); ``` @@ -370,7 +370,7 @@ killProcessesBySelf(callback: AsyncCallback); let applicationContext = this.context.getApplicationContext(); applicationContext.killProcessesBySelf(err => { if (err.code !== 0) { - console.error("killProcessesBySelf faile, err: " + JSON.stringify(err)); + console.error('killProcessesBySelf faile, err: ' + JSON.stringify(err)); } }) ``` \ No newline at end of file diff --git a/zh-cn/application-dev/reference/apis/js-apis-inner-application-applicationStateObserver.md b/zh-cn/application-dev/reference/apis/js-apis-inner-application-applicationStateObserver.md index 32084be192c100c27333aa0522958e1dd6eefd61..1f4cc1e36ba979396dc7247840dd630ce22fe450 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-inner-application-applicationStateObserver.md +++ b/zh-cn/application-dev/reference/apis/js-apis-inner-application-applicationStateObserver.md @@ -16,7 +16,7 @@ **示例:** ```ts -import appManager from "@ohos.application.appManager" +import appManager from "@ohos.application.appManager"; let applicationStateObserver = { onForegroundApplicationChanged(appStateData) { @@ -34,6 +34,6 @@ let applicationStateObserver = { onProcessStateChanged(processData) { console.log('onProcessStateChanged onProcessStateChanged: ' + JSON.stringify(processData)); } -} +}; let observerCode = appManager.registerApplicationStateObserver(applicationStateObserver); ``` \ No newline at end of file diff --git a/zh-cn/application-dev/reference/apis/js-apis-inner-application-baseContext.md b/zh-cn/application-dev/reference/apis/js-apis-inner-application-baseContext.md index b88ae3fe2dfa6f6f3946a361f7c95c12d03200b1..d4d3f14f605ca14ff07ba0246394a05ad53505b4 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-inner-application-baseContext.md +++ b/zh-cn/application-dev/reference/apis/js-apis-inner-application-baseContext.md @@ -22,7 +22,7 @@ import UIAbility from '@ohos.app.ability.UIAbility'; class MainAbility extends UIAbility { onCreate(want, launchParam) { // MainAbility onCreate, isStageMode: true - console.log("MainAbility onCreate, isStageMode: " + this.context.stageMode); + console.log('MainAbility onCreate, isStageMode: ' + this.context.stageMode); } } ``` diff --git a/zh-cn/application-dev/reference/apis/js-apis-inner-application-context.md b/zh-cn/application-dev/reference/apis/js-apis-inner-application-context.md index 1ce2e21fe7a6ca232f350bac28c52e0b7f87f048..d54bec3196fd309d2a5829f8a51dc8f1e0a5d107 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-inner-application-context.md +++ b/zh-cn/application-dev/reference/apis/js-apis-inner-application-context.md @@ -49,7 +49,7 @@ createBundleContext(bundleName: string): Context; **示例:** ```ts -let bundleContext = this.context.createBundleContext("com.example.test"); +let bundleContext = this.context.createBundleContext('com.example.test'); ``` ## Context.createModuleContext @@ -75,7 +75,7 @@ createModuleContext(moduleName: string): Context; **示例:** ```ts -let moduleContext = this.context.createModuleContext("entry"); +let moduleContext = this.context.createModuleContext('entry'); ``` createModuleContext(bundleName: string, moduleName: string): Context; @@ -100,7 +100,7 @@ createModuleContext(bundleName: string, moduleName: string): Context; **示例:** ```ts -let moduleContext = this.context.createModuleContext("com.example.test", "entry"); +let moduleContext = this.context.createModuleContext('com.example.test', 'entry'); ``` ## Context.getApplicationContext diff --git a/zh-cn/application-dev/reference/apis/js-apis-inner-application-continueCallback.md b/zh-cn/application-dev/reference/apis/js-apis-inner-application-continueCallback.md index 9367f66a9e24cf3956b06602501e2200b0957cc6..7e12ce10bfa691c8b269e27c228ad15c6d666ff4 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-inner-application-continueCallback.md +++ b/zh-cn/application-dev/reference/apis/js-apis-inner-application-continueCallback.md @@ -14,11 +14,11 @@ import distributedMissionManager from '@ohos.distributedMissionManager'; let continueDeviceInfo = { - srcDeviceId: "123", - dstDeviceId: "456", + srcDeviceId: '123', + dstDeviceId: '456', missionId: 123, wantParam: { - "key":"value" + 'key':'value' } }; @@ -26,7 +26,7 @@ onContinueDone(result) { console.log('onContinueDone, result: ' + JSON.stringify(result)); } - } + }; distributedMissionManager.continueMission(continueDeviceInfo, continueCallback, (error) => { if (error.code != 0) { diff --git a/zh-cn/application-dev/reference/apis/js-apis-inner-application-continueDeviceInfo.md b/zh-cn/application-dev/reference/apis/js-apis-inner-application-continueDeviceInfo.md index 0d4cdaae13b0f4d9af3b992a9408a846e434d36f..39761db2a1a146612252ed60368d266b2f3392e2 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-inner-application-continueDeviceInfo.md +++ b/zh-cn/application-dev/reference/apis/js-apis-inner-application-continueDeviceInfo.md @@ -17,11 +17,11 @@ import distributedMissionManager from '@ohos.distributedMissionManager'; let continueDeviceInfo = { - srcDeviceId: "123", - dstDeviceId: "456", + srcDeviceId: '123', + dstDeviceId: '456', missionId: 123, wantParam: { - "key":"value" + 'key':'value' } }; @@ -29,7 +29,7 @@ onContinueDone(result) { console.log('onContinueDone, result: ' + JSON.stringify(result)); } - } + }; distributedMissionManager.continueMission(continueDeviceInfo, continueCallback, (error) => { if (error.code != 0) { diff --git a/zh-cn/application-dev/reference/apis/js-apis-inner-application-errorObserver.md b/zh-cn/application-dev/reference/apis/js-apis-inner-application-errorObserver.md index af5ef4b750eccba37e7f4912c2e0ce1987fe1a27..3ad3e560941ab59809bad02749972339b211b533 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-inner-application-errorObserver.md +++ b/zh-cn/application-dev/reference/apis/js-apis-inner-application-errorObserver.md @@ -25,6 +25,6 @@ let observer = { onUnhandledException(errorMsg) { console.log('onUnhandledException, errorMsg: ' + JSON.stringify(errorMsg)); } -} -errorManager.registerErrorObserver(observer) +}; +errorManager.registerErrorObserver(observer); ``` \ No newline at end of file diff --git a/zh-cn/application-dev/reference/apis/js-apis-inner-application-eventHub.md b/zh-cn/application-dev/reference/apis/js-apis-inner-application-eventHub.md index e5c0502fed2c7e5271ebb4239ab14e383f533d98..e219e1ef3ef15076314cb7892fddc77bd38078c4 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-inner-application-eventHub.md +++ b/zh-cn/application-dev/reference/apis/js-apis-inner-application-eventHub.md @@ -15,10 +15,10 @@ EventHub模块提供了事件中心,提供订阅、取消订阅、触发事件 import Ability from '@ohos.application.Ability'; export default class MainAbility extends Ability { func1(){ - console.log("func1 is called"); + console.log('func1 is called'); } onForeground() { - this.context.eventHub.on("123", this.func1); + this.context.eventHub.on('123', this.func1); } } ``` @@ -45,17 +45,17 @@ on(event: string, callback: Function): void; export default class MainAbility extends Ability { onForeground() { - this.context.eventHub.on("123", this.func1); - this.context.eventHub.on("123", () => { - console.log("call anonymous func 1"); + this.context.eventHub.on('123', this.func1); + this.context.eventHub.on('123', () => { + console.log('call anonymous func 1'); }); // 结果: // func1 is called // call anonymous func 1 - this.context.eventHub.emit("123"); + this.context.eventHub.emit('123'); } func1() { - console.log("func1 is called"); + console.log('func1 is called'); } } ``` @@ -83,17 +83,17 @@ off(event: string, callback?: Function): void; export default class MainAbility extends Ability { onForeground() { - this.context.eventHub.on("123", this.func1); - this.context.eventHub.off("123", this.func1); //取消订阅func1 - this.context.eventHub.on("123", this.func1); - this.context.eventHub.on("123", this.func2); - this.context.eventHub.off("123"); //取消订阅func1和func2 + this.context.eventHub.on('123', this.func1); + this.context.eventHub.off('123', this.func1); //取消订阅func1 + this.context.eventHub.on('123', this.func1); + this.context.eventHub.on('123', this.func2); + this.context.eventHub.off('123'); //取消订阅func1和func2 } func1() { - console.log("func1 is called"); + console.log('func1 is called'); } func2() { - console.log("func2 is called"); + console.log('func2 is called'); } } ``` @@ -121,19 +121,19 @@ emit(event: string, ...args: Object[]): void; export default class MainAbility extends Ability { onForeground() { - this.context.eventHub.on("123", this.func1); + this.context.eventHub.on('123', this.func1); // 结果: // func1 is called,undefined,undefined - this.context.eventHub.emit("123"); + this.context.eventHub.emit('123'); // 结果: // func1 is called,1,undefined - this.context.eventHub.emit("123", 1); + this.context.eventHub.emit('123', 1); // 结果: // func1 is called,1,2 - this.context.eventHub.emit("123", 1, 2); + this.context.eventHub.emit('123', 1, 2); } func1(a, b) { - console.log("func1 is called," + a + "," + b); + console.log('func1 is called,' + a + ',' + b); } } ``` diff --git a/zh-cn/application-dev/reference/apis/js-apis-inner-application-extensionContext.md b/zh-cn/application-dev/reference/apis/js-apis-inner-application-extensionContext.md index 9e9154fb65b1f60190e2ba0943bfd02cbad91f7e..250a9c67a2afe0f382d3fc01ca4092c6cbaa3d1a 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-inner-application-extensionContext.md +++ b/zh-cn/application-dev/reference/apis/js-apis-inner-application-extensionContext.md @@ -31,8 +31,8 @@ ExtensionContext主要用于查询所属Extension的信息、Module的配置信 三个Module内都定义一个相同名称的ServiceExtension: ```ts -import ServiceExtension from '@ohos.app.ability.ServiceExtensionAbility' -import Want from '@ohos.application.Want' +import ServiceExtension from '@ohos.app.ability.ServiceExtensionAbility'; +import Want from '@ohos.application.Want'; export default class TheServiceExtension extends ServiceExtension { onCreate(want:Want) { console.log('ServiceAbility onCreate, want: ' + want.abilityName); @@ -61,14 +61,14 @@ export default class TheServiceExtension extends ServiceExtension { 在entry的MainAbility的onCreate回调内启动ServiceExtension ```ts -import Ability from '@ohos.app.ability.Ability' +import Ability from '@ohos.app.ability.Ability'; export default class MainAbility extends Ability { onCreate(want, launchParam) { - console.log("[Demo] MainAbility onCreate"); + console.log('[Demo] MainAbility onCreate'); let wantExt = { - deviceId: "", - bundleName: "com.example.TheServiceExtension", - abilityName: "TheServiceExtension", + deviceId: '', + bundleName: 'com.example.TheServiceExtension', + abilityName: 'TheServiceExtension', }; this.context.startServiceExtensionAbility(wantExt); } @@ -83,8 +83,8 @@ export default class ServiceModel { constructor() {} executeTask() { - if (globalThis.ExtensionContext == undefined) { - console.log("ERROR, ServiceExtension does not exist"); + if (globalThis.ExtensionContext === undefined) { + console.log('ERROR, ServiceExtension does not exist'); return; } @@ -92,20 +92,20 @@ export default class ServiceModel { this.moduleName = moduleInfo.name; // 根据moduleName执行不同的业务逻辑,实现对不同性能设备的区分 switch (this.moduleName) { - case "highPerformance": - console.log("This is high performance device."); + case 'highPerformance': + console.log('This is high performance device.'); // 执行对应业务逻辑 break; - case "midPerformance": - console.log("This is mid performance device."); + case 'midPerformance': + console.log('This is mid performance device.'); // 执行对应业务逻辑 break; - case "lowPerformance": - console.log("This is low performance device."); + case 'lowPerformance': + console.log('This is low performance device.'); // 执行对应业务逻辑 break; default: - console.log("ERROR, invalid moduleName."); + console.log('ERROR, invalid moduleName.'); break; } } diff --git a/zh-cn/application-dev/reference/apis/js-apis-inner-application-extensionRunningInfo.md b/zh-cn/application-dev/reference/apis/js-apis-inner-application-extensionRunningInfo.md index a5834f33491284810adbbc6457e50d5d59243ded..6e978ef3e713c430ec74b9e459e0d8415ba66306 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-inner-application-extensionRunningInfo.md +++ b/zh-cn/application-dev/reference/apis/js-apis-inner-application-extensionRunningInfo.md @@ -30,16 +30,16 @@ ExtensionRunningInfo模块提供对Extension运行的相关信息和类型进行 import abilityManager from '@ohos.application.abilityManager'; let upperLimit = 1; abilityManager.getExtensionRunningInfos(upperLimit, (err,data) => { - console.log("getExtensionRunningInfos err: " + err + " data: " + JSON.stringify(data)); + console.log('getExtensionRunningInfos err: ' + err + ' data: ' + JSON.stringify(data)); for (let i = 0; i < data.length; i++) { let extensionRunningInfo = data[i]; - console.log("extensionRunningInfo.extension: " + JSON.stringify(extensionRunningInfo.extension)); - console.log("extensionRunningInfo.pid: " + JSON.stringify(extensionRunningInfo.pid)); - console.log("extensionRunningInfo.uid: " + JSON.stringify(extensionRunningInfo.uid)); - console.log("extensionRunningInfo.processName: " + JSON.stringify(extensionRunningInfo.processName)); - console.log("extensionRunningInfo.startTime: " + JSON.stringify(extensionRunningInfo.startTime)); - console.log("extensionRunningInfo.clientPackage: " + JSON.stringify(extensionRunningInfo.clientPackage)); - console.log("extensionRunningInfo.type: " + JSON.stringify(extensionRunningInfo.type)); + console.log('extensionRunningInfo.extension: ' + JSON.stringify(extensionRunningInfo.extension)); + console.log('extensionRunningInfo.pid: ' + JSON.stringify(extensionRunningInfo.pid)); + console.log('extensionRunningInfo.uid: ' + JSON.stringify(extensionRunningInfo.uid)); + console.log('extensionRunningInfo.processName: ' + JSON.stringify(extensionRunningInfo.processName)); + console.log('extensionRunningInfo.startTime: ' + JSON.stringify(extensionRunningInfo.startTime)); + console.log('extensionRunningInfo.clientPackage: ' + JSON.stringify(extensionRunningInfo.clientPackage)); + console.log('extensionRunningInfo.type: ' + JSON.stringify(extensionRunningInfo.type)); } }); ``` \ No newline at end of file diff --git a/zh-cn/application-dev/reference/apis/js-apis-inner-application-formExtensionContext.md b/zh-cn/application-dev/reference/apis/js-apis-inner-application-formExtensionContext.md index 5e0784c672fede2fc0e66d665176a12e02fd157f..01b493932c9722be3c696a4be40325a0f06fba4e 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-inner-application-formExtensionContext.md +++ b/zh-cn/application-dev/reference/apis/js-apis-inner-application-formExtensionContext.md @@ -21,8 +21,8 @@ export default class MyFormExtensionAbility extends FormExtensionAbility { let formContext = this.context; // 获取FormExtensionContext // ... let dataObj1 = { - temperature:"11c", - "time":"11:00" + temperature:'11c', + 'time':'11:00' }; let obj1 = formBindingData.createFormBindingData(dataObj1); return obj1; @@ -51,22 +51,22 @@ startAbility(want: Want, callback: AsyncCallback<void>): void ```ts var want = { - deviceId: "", - bundleName: "com.example.formstartability", - abilityName: "MainAbility", - action: "action1", - entities: ["entity1"], - type: "MIMETYPE", - uri: "key={true,true,false}", + deviceId: '', + bundleName: 'com.example.formstartability', + abilityName: 'MainAbility', + action: 'action1', + entities: ['entity1'], + type: 'MIMETYPE', + uri: 'key={true,true,false}', parameters: {} -} +}; this.context.startAbility(want, (error, data) => { if (error) { console.log('FormExtensionContext startAbility, error:' + JSON.stringify(error)); } else { console.log(`FormExtensionContext startAbility success`); } -}) +}); ``` ## startAbility @@ -95,18 +95,18 @@ startAbility(want: Want): Promise<void> ```ts var want = { - deviceId: "", - bundleName: "com.example.formstartability", - abilityName: "MainAbility", - action: "action1", - entities: ["entity1"], - type: "MIMETYPE", - uri: "key={true,true,false}", + deviceId: '', + bundleName: 'com.example.formstartability', + abilityName: 'MainAbility', + action: 'action1', + entities: ['entity1'], + type: 'MIMETYPE', + uri: 'key={true,true,false}', parameters: {} -} +}; this.context.startAbility(want).then(() => { - console.info("StartAbility Success"); + console.info('StartAbility Success'); }).catch((error) => { - console.info("StartAbility failed"); + console.info('StartAbility failed'); }); ``` \ No newline at end of file diff --git a/zh-cn/application-dev/reference/apis/js-apis-inner-application-missionCallbacks.md b/zh-cn/application-dev/reference/apis/js-apis-inner-application-missionCallbacks.md index 76672e326f8a0bcb9563ad48584c801a6ec47fbf..a4885d4fdd916d0355ca438c63961d7afd1e91e4 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-inner-application-missionCallbacks.md +++ b/zh-cn/application-dev/reference/apis/js-apis-inner-application-missionCallbacks.md @@ -15,19 +15,19 @@ import distributedMissionManager from '@ohos.distributedMissionManager'; let missionDeviceInfo = { - deviceId: "123456" + deviceId: '123456' }; let missionCallback = { notifyMissionsChanged: function (deviceId) { - console.log("notifyMissionsChanged deviceId: " + JSON.stringify(deviceId)); + console.log('notifyMissionsChanged deviceId: ' + JSON.stringify(deviceId)); }, notifySnapshot: function (deviceId, mission) { - console.log("notifySnapshot deviceId: " + JSON.stringify(deviceId)); - console.log("notifySnapshot mission: " + JSON.stringify(mission)); + console.log('notifySnapshot deviceId: ' + JSON.stringify(deviceId)); + console.log('notifySnapshot mission: ' + JSON.stringify(mission)); }, notifyNetDisconnect: function (deviceId, state) { - console.log("notifyNetDisconnect deviceId: " + JSON.stringify(deviceId)); - console.log("notifyNetDisconnect state: " + JSON.stringify(state)); + console.log('notifyNetDisconnect deviceId: ' + JSON.stringify(deviceId)); + console.log('notifyNetDisconnect state: ' + JSON.stringify(state)); } }; distributedMissionManager.registerMissionListener(missionDeviceInfo, missionCallback); diff --git a/zh-cn/application-dev/reference/apis/js-apis-inner-application-missionDeviceInfo.md b/zh-cn/application-dev/reference/apis/js-apis-inner-application-missionDeviceInfo.md index 6c314132d14ea310b7c9fe971fd68d00d8548ccc..d937db73e439b915e157370ff571edc65c7df625 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-inner-application-missionDeviceInfo.md +++ b/zh-cn/application-dev/reference/apis/js-apis-inner-application-missionDeviceInfo.md @@ -13,19 +13,19 @@ import distributedMissionManager from '@ohos.distributedMissionManager'; let missionDeviceInfo = { - deviceId: "123456" + deviceId: '123456' }; let missionCallback = { notifyMissionsChanged: function (deviceId) { - console.log("notifyMissionsChanged deviceId: " + JSON.stringify(deviceId)); + console.log('notifyMissionsChanged deviceId: ' + JSON.stringify(deviceId)); }, notifySnapshot: function (mission, deviceId) { - console.log("notifySnapshot mission: " + JSON.stringify(mission)); - console.log("notifySnapshot deviceId: " + JSON.stringify(deviceId)); + console.log('notifySnapshot mission: ' + JSON.stringify(mission)); + console.log('notifySnapshot deviceId: ' + JSON.stringify(deviceId)); }, notifyNetDisconnect: function (mission, state) { - console.log("notifyNetDisconnect mission: " + JSON.stringify(mission)); - console.log("notifyNetDisconnect state: " + JSON.stringify(state)); + console.log('notifyNetDisconnect mission: ' + JSON.stringify(mission)); + console.log('notifyNetDisconnect state: ' + JSON.stringify(state)); } }; distributedMissionManager.registerMissionListener(missionDeviceInfo, missionCallback); diff --git a/zh-cn/application-dev/reference/apis/js-apis-inner-application-missionInfo.md b/zh-cn/application-dev/reference/apis/js-apis-inner-application-missionInfo.md index 3f3fd0c235df03dd07fc5ccb5705675f8e1056e7..a35b76370327b8309a488d881ad146adf5db3729 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-inner-application-missionInfo.md +++ b/zh-cn/application-dev/reference/apis/js-apis-inner-application-missionInfo.md @@ -19,9 +19,9 @@ **示例:** ```ts -import missionManager from '@ohos.application.missionManager' +import missionManager from '@ohos.application.missionManager'; -missionManager.getMissionInfo("12345", 1, (error, data) => { +missionManager.getMissionInfo('12345', 1, (error, data) => { console.info('getMissionInfo missionId is:' + JSON.stringify(data.missionId)); console.info('getMissionInfo runningState is:' + JSON.stringify(data.runningState)); console.info('getMissionInfo lockedState is:' + JSON.stringify(data.lockedState)); diff --git a/zh-cn/application-dev/reference/apis/js-apis-inner-application-missionListener.md b/zh-cn/application-dev/reference/apis/js-apis-inner-application-missionListener.md index 6dbc6f9e7adf7335f834a3c75637869a9733ab0d..bbc99e90938f01686646d12b62a240d7ee2b87d3 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-inner-application-missionListener.md +++ b/zh-cn/application-dev/reference/apis/js-apis-inner-application-missionListener.md @@ -16,26 +16,26 @@ **示例:** ```ts -import missionManager from '@ohos.application.missionManager' +import missionManager from '@ohos.application.missionManager'; let listener = { onMissionCreated: function (mission) { - console.log("onMissionCreated mission: " + JSON.stringify(mission)); + console.log('onMissionCreated mission: ' + JSON.stringify(mission)); }, onMissionDestroyed: function (mission) { - console.log("onMissionDestroyed mission: " + JSON.stringify(mission)); + console.log('onMissionDestroyed mission: ' + JSON.stringify(mission)); }, onMissionSnapshotChanged: function (mission) { - console.log("onMissionSnapshotChanged mission: " + JSON.stringify(mission)); + console.log('onMissionSnapshotChanged mission: ' + JSON.stringify(mission)); }, onMissionMovedToFront: function (mission) { - console.log("onMissionMovedToFront mission: " + JSON.stringify(mission)); + console.log('onMissionMovedToFront mission: ' + JSON.stringify(mission)); }, onMissionIconUpdated: function (mission, icon) { - console.log("onMissionIconUpdated mission: " + JSON.stringify(mission)); + console.log('onMissionIconUpdated mission: ' + JSON.stringify(mission)); }, onMissionClosed: function (mission) { - console.log("onMissionClosed mission: " + JSON.stringify(mission)); + console.log('onMissionClosed mission: ' + JSON.stringify(mission)); } }; let listenerid = missionManager.registerMissionListener(listener); diff --git a/zh-cn/application-dev/reference/apis/js-apis-inner-application-missionParameter.md b/zh-cn/application-dev/reference/apis/js-apis-inner-application-missionParameter.md index b6320f9b62824b9ef42b8b52c967a466813655d6..e96ca676a567a6cc8302d565959fb7a155aff663 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-inner-application-missionParameter.md +++ b/zh-cn/application-dev/reference/apis/js-apis-inner-application-missionParameter.md @@ -15,14 +15,14 @@ import distributedMissionManager from '@ohos.distributedMissionManager'; let missionParameter = { - deviceId: "123456", + deviceId: '123456', fixConflict: true, tag: 123 }; try { distributedMissionManager.startSyncRemoteMissions(missionParameter, (err, data) => { - console.log("startSyncRemoteMissions, data: " + JSON.stringify(data)); + console.log('startSyncRemoteMissions, data: ' + JSON.stringify(data)); } ); } catch (err) { diff --git a/zh-cn/application-dev/reference/apis/js-apis-inner-application-missionSnapshot.md b/zh-cn/application-dev/reference/apis/js-apis-inner-application-missionSnapshot.md index 2dba37ff19cd3f8eac0567d2661a42d0ba396243..f8fc4f2d467a82a8ea4e8dd1f591da913a47a03e 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-inner-application-missionSnapshot.md +++ b/zh-cn/application-dev/reference/apis/js-apis-inner-application-missionSnapshot.md @@ -24,15 +24,15 @@ import ElementName from '@ohos.bundle'; import image from '@ohos.multimedia.image'; import missionManager from '@ohos.application.missionManager'; -missionManager.getMissionInfos("", 10, (error, missions) => { - console.log("getMissionInfos is called, error.code = " + error.code); - console.log("size = " + missions.length); - console.log("missions = " + JSON.stringify(missions)); +missionManager.getMissionInfos('', 10, (error, missions) => { + console.log('getMissionInfos is called, error.code = ' + error.code); + console.log('size = ' + missions.length); + console.log('missions = ' + JSON.stringify(missions)); let id = missions[0].missionId; - missionManager.getMissionSnapShot("", id, (error, snapshot) => { - console.log("getMissionSnapShot is called, error.code = " + error.code); - console.log("bundleName = " + snapshot.ability.bundleName); - }) -}) + missionManager.getMissionSnapShot('', id, (error, snapshot) => { + console.log('getMissionSnapShot is called, error.code = ' + error.code); + console.log('bundleName = ' + snapshot.ability.bundleName); + }); +}); ``` \ No newline at end of file diff --git a/zh-cn/application-dev/reference/apis/js-apis-inner-application-serviceExtensionContext.md b/zh-cn/application-dev/reference/apis/js-apis-inner-application-serviceExtensionContext.md index 8ef06b823ea366009d3fb520e0c779671ebefa38..4f9580d7b0791455b2efcb55d263e2389a7a2e04 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-inner-application-serviceExtensionContext.md +++ b/zh-cn/application-dev/reference/apis/js-apis-inner-application-serviceExtensionContext.md @@ -69,8 +69,8 @@ startAbility(want: Want, callback: AsyncCallback<void>): void; ```ts let want = { - bundleName: "com.example.myapp", - abilityName: "MyAbility" + bundleName: 'com.example.myapp', + abilityName: 'MyAbility' }; try { @@ -142,8 +142,8 @@ startAbility(want: Want, options?: StartOptions): Promise\; ```ts let want = { - bundleName: "com.example.myapp", - abilityName: "MyAbility" + bundleName: 'com.example.myapp', + abilityName: 'MyAbility' }; let options = { windowMode: 0, @@ -213,9 +213,9 @@ startAbility(want: Want, options: StartOptions, callback: AsyncCallback<void& ```ts let want = { - deviceId: "", - bundleName: "com.extreme.test", - abilityName: "MainAbility" + deviceId: '', + bundleName: 'com.extreme.test', + abilityName: 'MainAbility' }; let options = { windowMode: 0 @@ -291,9 +291,9 @@ startAbilityWithAccount(want: Want, accountId: number, callback: AsyncCallback\< ```ts let want = { - deviceId: "", - bundleName: "com.extreme.test", - abilityName: "MainAbility" + deviceId: '', + bundleName: 'com.extreme.test', + abilityName: 'MainAbility' }; let accountId = 100; @@ -368,9 +368,9 @@ startAbilityWithAccount(want: Want, accountId: number, options: StartOptions, ca ```ts let want = { - deviceId: "", - bundleName: "com.extreme.test", - abilityName: "MainAbility" + deviceId: '', + bundleName: 'com.extreme.test', + abilityName: 'MainAbility' }; let accountId = 100; let options = { @@ -454,9 +454,9 @@ startAbilityWithAccount(want: Want, accountId: number, options?: StartOptions): ```ts let want = { - deviceId: "", - bundleName: "com.extreme.test", - abilityName: "MainAbility" + deviceId: '', + bundleName: 'com.extreme.test', + abilityName: 'MainAbility' }; let accountId = 100; let options = { @@ -519,9 +519,9 @@ startServiceExtensionAbility(want: Want, callback: AsyncCallback\): void; ```ts let want = { - deviceId: "", - bundleName: "com.extreme.test", - abilityName: "MainAbility" + deviceId: '', + bundleName: 'com.extreme.test', + abilityName: 'MainAbility' }; try { @@ -585,9 +585,9 @@ startServiceExtensionAbility(want: Want): Promise\; ```ts let want = { - deviceId: "", - bundleName: "com.extreme.test", - abilityName: "MainAbility" + deviceId: '', + bundleName: 'com.extreme.test', + abilityName: 'MainAbility' }; try { @@ -651,9 +651,9 @@ startServiceExtensionAbilityWithAccount(want: Want, accountId: number, callback: ```ts let want = { - deviceId: "", - bundleName: "com.extreme.test", - abilityName: "MainAbility" + deviceId: '', + bundleName: 'com.extreme.test', + abilityName: 'MainAbility' }; let accountId = 100; @@ -722,9 +722,9 @@ startServiceExtensionAbilityWithAccount(want: Want, accountId: number): Promise\ ```ts let want = { - deviceId: "", - bundleName: "com.extreme.test", - abilityName: "MainAbility" + deviceId: '', + bundleName: 'com.extreme.test', + abilityName: 'MainAbility' }; let accountId = 100; @@ -781,9 +781,9 @@ stopServiceExtensionAbility(want: Want, callback: AsyncCallback\): void; ```ts let want = { - deviceId: "", - bundleName: "com.extreme.test", - abilityName: "MainAbility" + deviceId: '', + bundleName: 'com.extreme.test', + abilityName: 'MainAbility' }; try { @@ -844,9 +844,9 @@ stopServiceExtensionAbility(want: Want): Promise\; ```ts let want = { - deviceId: "", - bundleName: "com.extreme.test", - abilityName: "MainAbility" + deviceId: '', + bundleName: 'com.extreme.test', + abilityName: 'MainAbility' }; try { @@ -906,9 +906,9 @@ stopServiceExtensionAbilityWithAccount(want: Want, accountId: number, callback: ```ts let want = { - deviceId: "", - bundleName: "com.extreme.test", - abilityName: "MainAbility" + deviceId: '', + bundleName: 'com.extreme.test', + abilityName: 'MainAbility' }; let accountId = 100; @@ -974,9 +974,9 @@ stopServiceExtensionAbilityWithAccount(want: Want, accountId: number): Promise\< ```ts let want = { - deviceId: "", - bundleName: "com.extreme.test", - abilityName: "MainAbility" + deviceId: '', + bundleName: 'com.extreme.test', + abilityName: 'MainAbility' }; let accountId = 100; @@ -1119,14 +1119,14 @@ connectServiceExtensionAbility(want: Want, options: ConnectOptions): number; ```ts let want = { - bundleName: "com.example.myapp", - abilityName: "MyAbility" + bundleName: 'com.example.myapp', + abilityName: 'MyAbility' }; let options = { onConnect(elementName, remote) { console.log('----------- onConnect -----------') }, onDisconnect(elementName) { console.log('----------- onDisconnect -----------') }, onFailed(code) { console.log('----------- onFailed -----------') } - } + }; let connection = null; try { @@ -1179,9 +1179,9 @@ connectServiceExtensionAbilityWithAccount(want: Want, accountId: number, options ```ts let want = { - deviceId: "", - bundleName: "com.extreme.test", - abilityName: "MainAbility" + deviceId: '', + bundleName: 'com.extreme.test', + abilityName: 'MainAbility' }; let accountId = 100; let options = { @@ -1359,10 +1359,10 @@ startAbilityByCall(want: Want): Promise<Caller>; // 后台启动Ability,不配置parameters let wantBackground = { - bundleName: "com.example.myservice", - moduleName: "entry", - abilityName: "MainAbility", - deviceId: "" + bundleName: 'com.example.myservice', + moduleName: 'entry', + abilityName: 'MainAbility', + deviceId: '' }; try { @@ -1388,14 +1388,14 @@ startAbilityByCall(want: Want): Promise<Caller>; ```ts let caller = undefined; - // 前台启动Ability,将parameters中的"ohos.aafwk.param.callAbilityToForeground"配置为true + // 前台启动Ability,将parameters中的'ohos.aafwk.param.callAbilityToForeground'配置为true let wantForeground = { - bundleName: "com.example.myservice", - moduleName: "entry", - abilityName: "MainAbility", - deviceId: "", + bundleName: 'com.example.myservice', + moduleName: 'entry', + abilityName: 'MainAbility', + deviceId: '', parameters: { - "ohos.aafwk.param.callAbilityToForeground": true + 'ohos.aafwk.param.callAbilityToForeground': true } }; diff --git a/zh-cn/application-dev/reference/apis/js-apis-inner-application-shellCmdResult.md b/zh-cn/application-dev/reference/apis/js-apis-inner-application-shellCmdResult.md index 986aaca7944a212ac2e57e9460e9e50a1157ed9e..bd438eae69aaaa4fb2a1c718ce27aab5870f1eba 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-inner-application-shellCmdResult.md +++ b/zh-cn/application-dev/reference/apis/js-apis-inner-application-shellCmdResult.md @@ -19,13 +19,13 @@ **示例:** ```ts -import AbilityDelegatorRegistry from "@ohos.application.abilityDelegatorRegistry"; +import AbilityDelegatorRegistry from '@ohos.application.abilityDelegatorRegistry'; let abilityDelegator; -let cmd = "cmd"; +let cmd = 'cmd'; abilityDelegator = AbilityDelegatorRegistry.getAbilityDelegator(); abilityDelegator.executeShellCommand(cmd, (err: any, data: any) => { - console.info("executeShellCommand callback, failed: ", err); - console.info("executeShellCommand callback, success: ", data); + console.info('executeShellCommand callback, failed: ', err); + console.info('executeShellCommand callback, success: ', data); }); ``` \ No newline at end of file diff --git a/zh-cn/application-dev/reference/apis/js-apis-inner-application-uiAbilityContext.md b/zh-cn/application-dev/reference/apis/js-apis-inner-application-uiAbilityContext.md index 1f56e2f24ed5c7503a002797395dbb095082b0cc..c37cbb66ec4c8c2c06ec13b741547960f7b60683 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-inner-application-uiAbilityContext.md +++ b/zh-cn/application-dev/reference/apis/js-apis-inner-application-uiAbilityContext.md @@ -67,8 +67,8 @@ startAbility(want: Want, callback: AsyncCallback<void>): void; ```ts var want = { - bundleName: "com.example.myapp", - abilityName: "MyAbility" + bundleName: 'com.example.myapp', + abilityName: 'MyAbility' }; try { @@ -139,9 +139,9 @@ startAbility(want: Want, options: StartOptions, callback: AsyncCallback<void& ```ts var want = { - deviceId: "", - bundleName: "com.extreme.test", - abilityName: "MainAbility" + deviceId: '', + bundleName: 'com.extreme.test', + abilityName: 'MainAbility' }; var options = { windowMode: 0 @@ -219,8 +219,8 @@ startAbility(want: Want, options?: StartOptions): Promise<void>; ```ts var want = { - bundleName: "com.example.myapp", - abilityName: "MyAbility" + bundleName: 'com.example.myapp', + abilityName: 'MyAbility' }; var options = { windowMode: 0, @@ -296,9 +296,9 @@ startAbilityForResult(want: Want, callback: AsyncCallback<AbilityResult>): ```ts var want = { - deviceId: "", - bundleName: "com.extreme.test", - abilityName: "MainAbility" + deviceId: '', + bundleName: 'com.extreme.test', + abilityName: 'MainAbility' }; try { @@ -310,7 +310,7 @@ startAbilityForResult(want: Want, callback: AsyncCallback<AbilityResult>): return; } // 执行正常业务 - console.log("startAbilityForResult succeed, result.resultCode = " + + console.log('startAbilityForResult succeed, result.resultCode = ' + result.resultCode) }); } catch (paramError) { @@ -372,9 +372,9 @@ startAbilityForResult(want: Want, options: StartOptions, callback: AsyncCallback ```ts var want = { - deviceId: "", - bundleName: "com.extreme.test", - abilityName: "MainAbility" + deviceId: '', + bundleName: 'com.extreme.test', + abilityName: 'MainAbility' }; var options = { windowMode: 0, @@ -389,7 +389,7 @@ startAbilityForResult(want: Want, options: StartOptions, callback: AsyncCallback return; } // 执行正常业务 - console.log("startAbilityForResult succeed, result.resultCode = " + + console.log('startAbilityForResult succeed, result.resultCode = ' + result.resultCode) }); } catch (paramError) { @@ -458,8 +458,8 @@ startAbilityForResult(want: Want, options?: StartOptions): Promise<AbilityRes ```ts var want = { - bundleName: "com.example.myapp", - abilityName: "MyAbility" + bundleName: 'com.example.myapp', + abilityName: 'MyAbility' }; var options = { windowMode: 0, @@ -469,7 +469,7 @@ startAbilityForResult(want: Want, options?: StartOptions): Promise<AbilityRes this.context.startAbilityForResult(want, options) .then((result) => { // 执行正常业务 - console.log("startAbilityForResult succeed, result.resultCode = " + result.resultCode); + console.log('startAbilityForResult succeed, result.resultCode = ' + result.resultCode); }) .catch((error) => { // 处理业务逻辑错误 @@ -532,9 +532,9 @@ startAbilityForResultWithAccount(want: Want, accountId: number, callback: AsyncC ```ts var want = { - deviceId: "", - bundleName: "com.extreme.test", - abilityName: "MainAbility" + deviceId: '', + bundleName: 'com.extreme.test', + abilityName: 'MainAbility' }; var accountId = 100; @@ -547,7 +547,7 @@ startAbilityForResultWithAccount(want: Want, accountId: number, callback: AsyncC return; } // 执行正常业务 - console.log("startAbilityForResultWithAccount succeed, result.resultCode = " + + console.log('startAbilityForResultWithAccount succeed, result.resultCode = ' + result.resultCode) }); } catch (paramError) { @@ -608,9 +608,9 @@ startAbilityForResultWithAccount(want: Want, accountId: number, options: StartOp ```ts var want = { - deviceId: "", - bundleName: "com.extreme.test", - abilityName: "MainAbility" + deviceId: '', + bundleName: 'com.extreme.test', + abilityName: 'MainAbility' }; var accountId = 100; var options = { @@ -626,7 +626,7 @@ startAbilityForResultWithAccount(want: Want, accountId: number, options: StartOp return; } // 执行正常业务 - console.log("startAbilityForResultWithAccount succeed, result.resultCode = " + + console.log('startAbilityForResultWithAccount succeed, result.resultCode = ' + result.resultCode) }); } catch (paramError) { @@ -692,9 +692,9 @@ startAbilityForResultWithAccount(want: Want, accountId: number, options?: StartO ```ts var want = { - deviceId: "", - bundleName: "com.extreme.test", - abilityName: "MainAbility" + deviceId: '', + bundleName: 'com.extreme.test', + abilityName: 'MainAbility' }; var accountId = 100; var options = { @@ -705,7 +705,7 @@ startAbilityForResultWithAccount(want: Want, accountId: number, options?: StartO this.context.startAbilityForResultWithAccount(want, accountId, options) .then((result) => { // 执行正常业务 - console.log("startAbilityForResultWithAccount succeed, result.resultCode = " + + console.log('startAbilityForResultWithAccount succeed, result.resultCode = ' + result.resultCode) }) .catch((error) => { @@ -757,9 +757,9 @@ startServiceExtensionAbility(want: Want, callback: AsyncCallback\): void; ```ts var want = { - deviceId: "", - bundleName: "com.extreme.test", - abilityName: "MainAbility" + deviceId: '', + bundleName: 'com.extreme.test', + abilityName: 'MainAbility' }; try { @@ -817,9 +817,9 @@ startServiceExtensionAbility(want: Want): Promise\; ```ts var want = { - deviceId: "", - bundleName: "com.extreme.test", - abilityName: "MainAbility" + deviceId: '', + bundleName: 'com.extreme.test', + abilityName: 'MainAbility' }; try { @@ -878,9 +878,9 @@ startServiceExtensionAbilityWithAccount(want: Want, accountId: number, callback: ```ts var want = { - deviceId: "", - bundleName: "com.extreme.test", - abilityName: "MainAbility" + deviceId: '', + bundleName: 'com.extreme.test', + abilityName: 'MainAbility' }; var accountId = 100; @@ -943,9 +943,9 @@ startServiceExtensionAbilityWithAccount(want: Want, accountId: number): Promise\ ```ts var want = { - deviceId: "", - bundleName: "com.extreme.test", - abilityName: "MainAbility" + deviceId: '', + bundleName: 'com.extreme.test', + abilityName: 'MainAbility' }; var accountId = 100; @@ -1001,9 +1001,9 @@ stopServiceExtensionAbility(want: Want, callback: AsyncCallback\): void; ```ts var want = { - deviceId: "", - bundleName: "com.extreme.test", - abilityName: "MainAbility" + deviceId: '', + bundleName: 'com.extreme.test', + abilityName: 'MainAbility' }; try { @@ -1058,9 +1058,9 @@ stopServiceExtensionAbility(want: Want): Promise\; ```ts var want = { - deviceId: "", - bundleName: "com.extreme.test", - abilityName: "MainAbility" + deviceId: '', + bundleName: 'com.extreme.test', + abilityName: 'MainAbility' }; try { @@ -1120,9 +1120,9 @@ stopServiceExtensionAbilityWithAccount(want: Want, accountId: number, callback: ```ts var want = { - deviceId: "", - bundleName: "com.extreme.test", - abilityName: "MainAbility" + deviceId: '', + bundleName: 'com.extreme.test', + abilityName: 'MainAbility' }; var accountId = 100; @@ -1182,9 +1182,9 @@ stopServiceExtensionAbilityWithAccount(want: Want, accountId: number): Promise\< ```ts var want = { - deviceId: "", - bundleName: "com.extreme.test", - abilityName: "MainAbility" + deviceId: '', + bundleName: 'com.extreme.test', + abilityName: 'MainAbility' }; var accountId = 100; @@ -1316,8 +1316,8 @@ terminateSelfWithResult(parameter: AbilityResult, callback: AsyncCallback<voi ```ts var want = { - bundleName: "com.extreme.myapplication", - abilityName: "SecondAbility" + bundleName: 'com.extreme.myapplication', + abilityName: 'SecondAbility' } var resultCode = 100; // 返回给接口调用方AbilityResult信息 @@ -1381,8 +1381,8 @@ terminateSelfWithResult(parameter: AbilityResult): Promise<void>; ```ts var want = { - bundleName: "com.extreme.myapplication", - abilityName: "SecondAbility" + bundleName: 'com.extreme.myapplication', + abilityName: 'SecondAbility' } var resultCode = 100; // 返回给接口调用方AbilityResult信息 @@ -1446,9 +1446,9 @@ connectServiceExtensionAbility(want: Want, options: ConnectOptions): number; ```ts var want = { - deviceId: "", - bundleName: "com.extreme.test", - abilityName: "MainAbility" + deviceId: '', + bundleName: 'com.extreme.test', + abilityName: 'MainAbility' }; var options = { onConnect(elementName, remote) { console.log('----------- onConnect -----------') }, @@ -1510,9 +1510,9 @@ connectServiceExtensionAbilityWithAccount(want: Want, accountId: number, options ```ts var want = { - deviceId: "", - bundleName: "com.extreme.test", - abilityName: "MainAbility" + deviceId: '', + bundleName: 'com.extreme.test', + abilityName: 'MainAbility' }; var accountId = 100; var options = { @@ -1674,10 +1674,10 @@ startAbilityByCall(want: Want): Promise<Caller>; // 后台启动Ability,不配置parameters var wantBackground = { - bundleName: "com.example.myservice", - moduleName: "entry", - abilityName: "MainAbility", - deviceId: "" + bundleName: 'com.example.myservice', + moduleName: 'entry', + abilityName: 'MainAbility', + deviceId: '' }; try { @@ -1703,14 +1703,14 @@ startAbilityByCall(want: Want): Promise<Caller>; ```ts var caller = undefined; - // 前台启动Ability,将parameters中的"ohos.aafwk.param.callAbilityToForeground"配置为true + // 前台启动Ability,将parameters中的'ohos.aafwk.param.callAbilityToForeground'配置为true var wantForeground = { - bundleName: "com.example.myservice", - moduleName: "entry", - abilityName: "MainAbility", - deviceId: "", + bundleName: 'com.example.myservice', + moduleName: 'entry', + abilityName: 'MainAbility', + deviceId: '', parameters: { - "ohos.aafwk.param.callAbilityToForeground": true + 'ohos.aafwk.param.callAbilityToForeground': true } }; @@ -1781,9 +1781,9 @@ startAbilityWithAccount(want: Want, accountId: number, callback: AsyncCallback\< ```ts var want = { - deviceId: "", - bundleName: "com.extreme.test", - abilityName: "MainAbility" + deviceId: '', + bundleName: 'com.extreme.test', + abilityName: 'MainAbility' }; var accountId = 100; @@ -1856,9 +1856,9 @@ startAbilityWithAccount(want: Want, accountId: number, options: StartOptions, ca ```ts var want = { - deviceId: "", - bundleName: "com.extreme.test", - abilityName: "MainAbility" + deviceId: '', + bundleName: 'com.extreme.test', + abilityName: 'MainAbility' }; var accountId = 100; var options = { @@ -1933,9 +1933,9 @@ startAbilityWithAccount(want: Want, accountId: number, options?: StartOptions): ```ts var want = { - deviceId: "", - bundleName: "com.extreme.test", - abilityName: "MainAbility" + deviceId: '', + bundleName: 'com.extreme.test', + abilityName: 'MainAbility' }; var accountId = 100; var options = { @@ -2037,7 +2037,7 @@ setMissionLabel(label: string, callback:AsyncCallback<void>): void; **示例:** ```ts - this.context.setMissionLabel("test",(result) => { + this.context.setMissionLabel('test',(result) => { console.log('requestPermissionsFromUserresult:' + JSON.stringify(result)); }); ``` @@ -2066,7 +2066,7 @@ setMissionLabel(label: string): Promise<void>; **示例:** ```ts - this.context.setMissionLabel("test").then(() => { + this.context.setMissionLabel('test').then(() => { console.log('success'); }).catch((error) => { console.log('failed:' + JSON.stringify(error));