From c5acb171ecd6fd1e0f87f8105cdd69e6a080ae8f Mon Sep 17 00:00:00 2001 From: z00524957 Date: Fri, 21 Apr 2023 21:45:25 +0800 Subject: [PATCH] update docs Signed-off-by: z00524957 --- en/application-dev/faqs/faqs-ability.md | 2 - en/application-dev/faqs/faqs-bundle.md | 2 +- .../faqs/faqs-development-board.md | 6 +- .../faqs/faqs-event-notification.md | 2 +- en/application-dev/faqs/faqs-graphics.md | 10 ++-- en/application-dev/faqs/faqs-language.md | 3 +- en/application-dev/faqs/faqs-media.md | 14 +++-- en/application-dev/faqs/faqs-web-arkts.md | 2 +- en/application-dev/media/avrecorder.md | 12 ++-- zh-cn/application-dev/faqs/faqs-ability.md | 24 ++------ zh-cn/application-dev/faqs/faqs-bundle.md | 4 +- .../application-dev/faqs/faqs-connectivity.md | 6 +- .../faqs/faqs-data-management.md | 7 +-- .../faqs/faqs-development-board.md | 1 - .../faqs/faqs-device-management.md | 4 +- zh-cn/application-dev/faqs/faqs-dfx.md | 4 +- .../faqs/faqs-event-notification.md | 10 ++-- .../faqs/faqs-file-management.md | 1 - zh-cn/application-dev/faqs/faqs-graphics.md | 18 +++--- zh-cn/application-dev/faqs/faqs-language.md | 9 +-- zh-cn/application-dev/faqs/faqs-media.md | 10 ++-- zh-cn/application-dev/faqs/faqs-native.md | 4 +- zh-cn/application-dev/faqs/faqs-ui-ets.md | 56 +++++++------------ zh-cn/application-dev/faqs/faqs-ui-js.md | 3 +- zh-cn/application-dev/faqs/faqs-web-arkts.md | 3 +- .../media/avplayer-avrecorder-overview.md | 2 +- .../media/avsession-overview.md | 2 + zh-cn/application-dev/media/video-playback.md | 4 +- .../reference/apis/development-intro.md | 2 +- 29 files changed, 91 insertions(+), 136 deletions(-) diff --git a/en/application-dev/faqs/faqs-ability.md b/en/application-dev/faqs/faqs-ability.md index 7b3136f70a..aab3ecc19a 100644 --- a/en/application-dev/faqs/faqs-ability.md +++ b/en/application-dev/faqs/faqs-ability.md @@ -212,5 +212,3 @@ The following conditions must be met: 1. Before the redirection to the previous page, a confirm dialog box will be displayed. Note that **router.disableAlertBeforeBackPage** is used to disable the display of a confirm dialog box before returning to the previous page (default), and **router.enableAlertBeforeBackPage** is used to enable the display. 2. The system return key is used. - - \ No newline at end of file diff --git a/en/application-dev/faqs/faqs-bundle.md b/en/application-dev/faqs/faqs-bundle.md index 61a5277c6d..fda41c42bc 100644 --- a/en/application-dev/faqs/faqs-bundle.md +++ b/en/application-dev/faqs/faqs-bundle.md @@ -14,7 +14,7 @@ Applicable to: OpenHarmony SDK 3.2.3.5, stage model of API version 9 Obtain the bundle name through **context.abilityInfo.bundleName**. -Reference: [AbilityContext](../reference/apis/js-apis-ability-context.md) and [AbilityInfo](../reference/apis/js-apis-bundle-AbilityInfo.md) +Reference: [AbilityInfo](../reference/apis/js-apis-bundle-AbilityInfo.md) ## How do I obtain an application icon? diff --git a/en/application-dev/faqs/faqs-development-board.md b/en/application-dev/faqs/faqs-development-board.md index 79e5fc390f..0a2a29db5b 100644 --- a/en/application-dev/faqs/faqs-development-board.md +++ b/en/application-dev/faqs/faqs-development-board.md @@ -9,7 +9,6 @@ Applicable to: OpenHarmony SDK 3.2.2.5, stage model of API version 9 - Method 2: Run the screenshot script. Connect to the development board to a computer running Windows. Create a text file on the computer, copy the following script content to the file, change the file name extension to **.bat** (the HDC environment variables must be configured in advance), and click **Run**. The screenshot is saved to the same directory as the **.bat** script file. Example: - ``` set filepath=/data/%date:~0,4%%date:~5,2%%date:~8,2%%time:~1,1%%time:~3,2%%time:~6,2%.png echo %filepath% @@ -29,10 +28,11 @@ Applicable to: DevEco Studio 3.0.0.991 ![en-us_image_0000001361254285](figures/en-us_image_0000001361254285.png) 2. Set the profile parameters as follows: + Device type : default - + Resolution: 720\*1280 - + DPI: 240 ## What should I do if Device Manager incorrectly identifies a development board as FT232R USB UART even when the development board already has a driver installed? diff --git a/en/application-dev/faqs/faqs-event-notification.md b/en/application-dev/faqs/faqs-event-notification.md index 496abb0692..1197745d90 100644 --- a/en/application-dev/faqs/faqs-event-notification.md +++ b/en/application-dev/faqs/faqs-event-notification.md @@ -17,7 +17,7 @@ Reference: [Notification](../reference/apis/js-apis-notification.md#notification Example: ```ts -import WantAgent from '@ohos.wantAgent'; +import WantAgent from '@ohos.app.ability.wantAgent'; async function publishNotification() { let wantAgentInfo = { diff --git a/en/application-dev/faqs/faqs-graphics.md b/en/application-dev/faqs/faqs-graphics.md index 7752d9d746..7eeba06447 100644 --- a/en/application-dev/faqs/faqs-graphics.md +++ b/en/application-dev/faqs/faqs-graphics.md @@ -18,10 +18,10 @@ Applicable to: OpenHarmony SDK 3.2.6.3, stage model of API version 9 1. Use the **onWindowStageCreate** to obtain a **windowClass** object. - ``` + ```ts onWindowStageCreate(windowStage) { // When the main window is created, set the main page for this ability. - console.log("[Demo] MainAbility onWindowStageCreate") + console.log("[Demo] EntryAbility onWindowStageCreate") windowStage.getMainWindow((err, data) => { if (err.code) { console.error('Failed to obtain the main window.') @@ -35,7 +35,7 @@ Applicable to: OpenHarmony SDK 3.2.6.3, stage model of API version 9 2. Enable the full-screen mode for the window and hide the status bar. - ``` + ```ts globalThis.windowClass.setFullScreen(isFullScreen, (err, data) => { if (err.code) { console.error('Failed to enable the full-screen mode. Cause:' + JSON.stringify(err)); @@ -54,7 +54,7 @@ Use **window.getProperties()** to obtain the window properties. The **windowRect Example: -``` +```ts let promise = windowClass.getProperties(); promise.then((data)=> { console.info('Succeeded in obtaining the window properties. Data: ' + JSON.stringify(data.windowRect)); @@ -70,7 +70,7 @@ Applicable to: OpenHarmony SDK 3.2.5.5, stage model of API version 9 Refer to the following code: -``` +```ts window.getTopWindow(globalThis.mainContext).then(win => { var systemBarProperties = { statusBarColor: '#19B6FF', // Set the background color of the status bar. diff --git a/en/application-dev/faqs/faqs-language.md b/en/application-dev/faqs/faqs-language.md index 34404f5197..6d3ded94a7 100644 --- a/en/application-dev/faqs/faqs-language.md +++ b/en/application-dev/faqs/faqs-language.md @@ -251,7 +251,6 @@ Applicable to: OpenHarmony SDK 3.2.5.5, stage model of API version 9 To listen for in-depth changes of **@State** decorated variables, you can use **@Observed** and **@ObjectLink** decorators. -Reference: [@Observed and @ObjectLink](../quick-start/arkts-state-mgmt-page-level.md#observed-and-objectlink) ## How do I implement character string encoding and decoding? @@ -289,4 +288,4 @@ Applicable to: OpenHarmony SDK 3.2.5.5, stage model of API version 9 No. Relational database operations cannot be performed in the worker thread. - \ No newline at end of file + \ No newline at end of file diff --git a/en/application-dev/faqs/faqs-media.md b/en/application-dev/faqs/faqs-media.md index 9f465834a0..0e88cf4e94 100644 --- a/en/application-dev/faqs/faqs-media.md +++ b/en/application-dev/faqs/faqs-media.md @@ -42,7 +42,7 @@ cameraInput = await this.cameraManager.createCameraInput(cameraId) Applicable to: OpenHarmony SDK 3.2.5.6, stage model of API version 9 1. Create an **ImageSource** instance based on the input URI. - + ``` let path = this.context.getApplicationContext().fileDirs + "test.jpg"; const imageSourceApi = image.createImageSource(path); @@ -52,7 +52,7 @@ Applicable to: OpenHarmony SDK 3.2.5.6, stage model of API version 9 - Set **desiredSize** to specify the target size after scaling. If the values are all set to **0**, scaling will not be performed. - Set **desiredRegion** to specify the target rectangular area after cropping. If the values are all set to **0**, cropping will not be performed. - Set **rotateDegrees** to specify the rotation angle. The image will be rotated clockwise at the center. - + ``` const decodingOptions = { desiredSize: { @@ -85,7 +85,7 @@ Applicable to: OpenHarmony SDK 3.2.5.5, stage model of API version 9 1. Configure the permissions **ohos.permission.READ_MEDIA** and **ohos.permission.WRITE_MEDIA** in the **module.json5** file. Example: - + ``` { "module" : { @@ -104,10 +104,14 @@ Applicable to: OpenHarmony SDK 3.2.5.5, stage model of API version 9 ``` 2. Call **requestPermissionsFromUser** to request the permissions from end users in the form of a dialog box. This operation is required because the grant mode of both permissions is **user_grant**. - + ``` + import abilityAccessCtrl from '@ohos.abilityAccessCtrl.d.ts'; + let permissions: Array = ['ohos.permission.READ_MEDIA','ohos.permission.WRITE_MEDIA'] - context.requestPermissionsFromUser(permissions).then((data) => { + let atManager = abilityAccessCtrl.createAtManager(); + // context is the ability-level context of the initiator UIAbility. + atManager.requestPermissionsFromUser(context, permissions).then((data) => { console.log("Succeed to request permission from user with data: " + JSON.stringify(data)) }).catch((error) => { console.log("Failed to request permission from user with error: " + JSON.stringify(error)) diff --git a/en/application-dev/faqs/faqs-web-arkts.md b/en/application-dev/faqs/faqs-web-arkts.md index be2d58f82d..6fe2c75a4b 100644 --- a/en/application-dev/faqs/faqs-web-arkts.md +++ b/en/application-dev/faqs/faqs-web-arkts.md @@ -76,4 +76,4 @@ Applicable to: OpenHarmony SDK 3.2.7.5, stage model of API version 9 4. Use message port 0 on the application side to send messages to message port 1 on the HTML side. -Reference: [Web](../reference/arkui-ts/ts-basic-components-web.md#postmessage9) +Reference: [Web](../reference/arkui-ts/ts-basic-components-web.md) diff --git a/en/application-dev/media/avrecorder.md b/en/application-dev/media/avrecorder.md index fdc7d7c35c..fa8238bc81 100644 --- a/en/application-dev/media/avrecorder.md +++ b/en/application-dev/media/avrecorder.md @@ -20,9 +20,9 @@ The following figures show the AVRecorder state transition and the interaction w ## Constraints -Before developing audio recording, configure the permission **ohos.permission.MICROPHONE** for your application. For details about the configuration, see [Permission Application Guide](../security/accesstoken-guidelines.md). +Before developing the recording feature, configure permissions for your application. If audio recording is involved, obtain the permission **ohos.permission.MICROPHONE** by following the instructions provided in [Permission Application Guide](../security/accesstoken-guidelines.md). -To use the camera to record videos, the camera module is required. For details about how to use the camera APIs, see [Camera Management](../reference/apis/js-apis-camera.md). +To use the camera to record videos, the camera module is required. For details about how to use the APIs and obtain permissions, see [Camera Management](../reference/apis/js-apis-camera.md). ## How to Develop @@ -30,6 +30,8 @@ For details about the AVRecorder APIs, see the [AVRecorder APIs in the Media Cla For details about the processes related to the media library, see [Media Library Management](../reference/apis/js-apis-medialibrary.md). +For details about the camera-related process, see [Camera Management](../reference/apis/js-apis-camera.md). + ### Full-Process Scenario of Audio and Video Recording The full audio and video recording process includes creating an instance, setting recording parameters, obtaining the input surface, starting, pausing, resuming, and stopping recording, and releasing resources. @@ -478,9 +480,3 @@ export class VideoRecorderDemo { } } ``` - -### AVRecorder App - -The AVRecorder app provides a complete audio and video recording process, which includes creating an instance, setting recording parameters, obtaining the input surface, starting, pausing, resuming, and stopping recording, and releasing resources. - -For details about the code, see [AVRecorderDemo]([multimedia_player_framework: Implementation of media playback and recording](https://gitee.com/openharmony/multimedia_player_framework/tree/master/test/appdemo/AVRecorderDemo)). diff --git a/zh-cn/application-dev/faqs/faqs-ability.md b/zh-cn/application-dev/faqs/faqs-ability.md index 1a41bf3371..98d55b7f79 100644 --- a/zh-cn/application-dev/faqs/faqs-ability.md +++ b/zh-cn/application-dev/faqs/faqs-ability.md @@ -1,13 +1,5 @@ # Ability框架开发常见问题 -## Stage模型中是否有类似FA模型的DataAbility的开发指导文档 - -适用于:OpenHarmony SDK 3.2.3.5版本, API9 Stage模型 - -Stage模型中DataShareExtensionAbility提供了向其他应用共享以及管理其数据的方法。 - -参考文档:[数据共享开发指导](../database/database-datashare-guidelines.md) - ## 拉起Ability在界面上没反应 适用于:OpenHarmony SDK 3.2.5.3版本,API9 Stage模型 @@ -54,7 +46,7 @@ build() { 方式二:使用箭头函数。 -## 如何解决must have required property 'startWindowIcon'报错 +## 如何解决must have required property 'startWindowIcon'报错 适用于:OpenHarmony SDK 3.2.3.5版本,API9 Stage模型 @@ -83,27 +75,19 @@ Ability配置中缺少startWindowIcon属性配置,需要在module.json5中abil 使用Ability的onConfigurationUpdated回调实现,系统语言、颜色模式以及Display相关的参数,比如方向、Density,发生变化时触发该回调。 -参考文档:[Ability开发指导](../ability/stage-ability.md) - ## Stage模型是否推荐用globalThis去获取Context 适用于:OpenHarmony SDK 3.2.5.5版本,API9 Stage模型 不推荐,Stage模型使用globalThis去获取Context是错误的使用方式。在Stage模型中,整个应用进程共用一个js虚拟机实例,其中可以运行多个Ability实例,共用一个global对象。在同一个js虚拟机内的不同的Ability中使用globalThis获取Context,存在被覆盖从而发生错误的风险。 -推荐使用方式参考:[Stage模型的Context详细介绍](../ability/context-userguide.md#stage模型的context详细介绍)。 +推荐使用方式参考:[Stage模型的Context详细介绍](../application-models/application-context-stage.md)。 -## 如何在应用A中去获取应用B的Hap包的安装路径 +## 如何在应用A中去获取应用B的HAP的安装路径 适用于:OpenHarmony SDK 3.0以上版本, API9 Stage模型 -首先需要申请系统权限,具体参看文档:[自动化签名](https://developer.harmonyos.com/cn/docs/documentation/doc-guides/ohos-auto-configuring-signature-information-0000001271659465)。导入bundle模块,通过调用bundle.getApplicationInfo()接口,通过包名获取应用信息。然后通过application.moduleSourceDirs获取应用存储路径。 - -## 调用方使用startAbilityForResult,被调用方如何返回数据 - -适用于:OpenHarmony SDK3.0, API9 Stage模型 - -被调用方使用AbilityContext.terminateSelfWithResult方法,销毁被调用方ability,传递参数给startAbilityForResult回调函数,具体用法请参考[AbilityContext](../reference/apis/js-apis-ability-context.md#abilitycontextterminateselfwithresult) +首先需要申请系统权限,具体参看文档:[自动化签名](https://developer.harmonyos.com/cn/docs/documentation/doc-guides/ohos-auto-configuring-signature-information-0000001271659465)。导入bundle模块,通过调用bundle.getApplicationInfo()接口,通过Bundle名称获取应用信息。然后通过application.moduleSourceDirs获取应用存储路径。 ## FA卡片上架后在用户的服务中心展示时可否触发生命周期,从而实现用户没有打开过FA应用的情况下获取到用户的登录信息? diff --git a/zh-cn/application-dev/faqs/faqs-bundle.md b/zh-cn/application-dev/faqs/faqs-bundle.md index eb8cc6aef7..cf5f642e29 100644 --- a/zh-cn/application-dev/faqs/faqs-bundle.md +++ b/zh-cn/application-dev/faqs/faqs-bundle.md @@ -4,7 +4,7 @@ 适用于:OpenHarmony SDK 3.2.3.5版本,API9 Stage模型 -通过\@ohos.bundle模块bundle.getBundleInfo()接口获取包信息bundleInfo,然后分别通过bundleInfo.versionCode、bundleInfo.versionName +通过@ohos.bundle模块bundle.getBundleInfo()接口获取包信息bundleInfo,然后分别通过bundleInfo.versionCode、bundleInfo.versionName 参考文档:[Bundle模块](../reference/apis/js-apis-Bundle.md#bundlegetbundleinfo) @@ -14,7 +14,7 @@ 通过可以context.abilityInfo.bundleName获取。 -参考文档:[AbilityContext](../reference/apis/js-apis-ability-context.md)、[AbilityInfo](../reference/apis/js-apis-bundle-AbilityInfo.md) +参考文档:[AbilityInfo](../reference/apis/js-apis-bundle-AbilityInfo.md) ## 如何获取应用图标 diff --git a/zh-cn/application-dev/faqs/faqs-connectivity.md b/zh-cn/application-dev/faqs/faqs-connectivity.md index c50e44cc0f..8855b30f1b 100644 --- a/zh-cn/application-dev/faqs/faqs-connectivity.md +++ b/zh-cn/application-dev/faqs/faqs-connectivity.md @@ -18,7 +18,7 @@ extraData代表发送请求的额外数据,支持如下数据: 错误码28代表CURLE_OPERATION_TIMEDOUT,操作超时。网络请求底层使用libcurl库,更多错误码可以查看相应文档。 -参考文档:[Response常用错误码](../reference/apis/js-apis-http.md#response常用错误码)和[Curl错误码](https://curl.se/libcurl/c/libcurl-errors.html) +参考文档:[Curl错误码](https://curl.se/libcurl/c/libcurl-errors.html) ## \@ohos.net.http.d.ts的response错误码返回6是什么意思? @@ -26,7 +26,7 @@ extraData代表发送请求的额外数据,支持如下数据: 6表示地址无法解析主机,可以尝试ping一下request中的url,确认是否可以ping通。 -更多错误码参考[Response常用错误码](../reference/apis/js-apis-http.md#response常用错误码)或者[Curl错误码](https://curl.se/libcurl/c/libcurl-errors.html) +更多错误码参考[Curl错误码](https://curl.se/libcurl/c/libcurl-errors.html) ## 调用camera拍摄的照片怎么上传到服务器 @@ -44,7 +44,7 @@ HttpRequestOptions中的header是一个Object类型,可以直接在header里 适用于:OpenHarmony SDK 3.2.6.5版本,API9 Stage模型 -1. 鼠标移到extraData, ctrl+鼠标左键,跳转到sdk中,里面有关于extraData的传参说明。可以发现文档中对extraData的定义是这样的 extraData?: string | Object,也就是extraData支持string 和 Object两种类型。 +1. 鼠标移到extraData, ctrl+鼠标左键,跳转到sdk中,里面有关于extraData的传参说明。可以发现文档中对extraData的定义为 extraData?: string | Object,也就是extraData支持string 和 Object两种类型。 2. 这两种写法都可以实现: a.extraData:"data to send"; diff --git a/zh-cn/application-dev/faqs/faqs-data-management.md b/zh-cn/application-dev/faqs/faqs-data-management.md index fe93fd317d..e736292e07 100644 --- a/zh-cn/application-dev/faqs/faqs-data-management.md +++ b/zh-cn/application-dev/faqs/faqs-data-management.md @@ -1,6 +1,6 @@ # 数据管理开发常见问题 -## 如何将PixelMap的数据存储到数据库中。 +## 如何将PixelMap的数据存储到数据库中 适用于:OpenHarmony SDK 3.2.3.5版本 @@ -16,7 +16,6 @@ PixelMap应该被转换成相应的ArrayBuffer再放进数据库。 示例: - ``` hdc_std file recv /data/app/el2/100/database/com.xxxx.xxxx/entry/db/test.db ./test.db ``` @@ -62,12 +61,8 @@ PixelMap应该被转换成相应的ArrayBuffer再放进数据库。 - 分布式数据管理KV数据模型Value最大支持4M。 -参考文档:[首选项概述](../database/database-preference-overview.md)、[分布式数据服务概述](../database/database-mdds-overview.md) - ## Stage模型数据共享DataShare开发 适用于:OpenHarmony SDK 3.2.5.5版本,API 9 Stage模型DataShare不可与FA模型DataAbility混用,连接的服务端应用需使用DataShareExtensionAbility实现。 - -参考文档:[数据共享开发指导](../database/database-datashare-guidelines.md) diff --git a/zh-cn/application-dev/faqs/faqs-development-board.md b/zh-cn/application-dev/faqs/faqs-development-board.md index d6965edfbc..900ba10a82 100644 --- a/zh-cn/application-dev/faqs/faqs-development-board.md +++ b/zh-cn/application-dev/faqs/faqs-development-board.md @@ -9,7 +9,6 @@ - 方法二:通过截屏脚本一键截屏,可以在电脑上查看。操作方法:Windows上连接开发板,然后电脑上新建文本文件,拷贝如下脚本内容,文件名后缀改为.bat文件(需要提前配置好hdc的环境变量),点击运行后,截屏图片与脚本在同一目录。 示例: - ``` set filepath=/data/%date:~0,4%%date:~5,2%%date:~8,2%%time:~1,1%%time:~3,2%%time:~6,2%.png echo %filepath% diff --git a/zh-cn/application-dev/faqs/faqs-device-management.md b/zh-cn/application-dev/faqs/faqs-device-management.md index 3ff19c2308..47a73b6ff7 100644 --- a/zh-cn/application-dev/faqs/faqs-device-management.md +++ b/zh-cn/application-dev/faqs/faqs-device-management.md @@ -43,9 +43,9 @@ try { 适用于:OpenHarmony SDK3.0, API9 Stage模型 -1、如果想获取连接设备的udid,可使用 hdc shell bm get --udid命令; +1. 如果想获取连接设备的udid,可使用 hdc shell bm get --udid命令; -2、如果想在代码中获得,参考文档 [udid](../reference/apis/js-apis-device-info.md) 。 +2. 如果想在代码中获得,参考文档 [udid](../reference/apis/js-apis-device-info.md) 。 ## 开发快捷键功能 diff --git a/zh-cn/application-dev/faqs/faqs-dfx.md b/zh-cn/application-dev/faqs/faqs-dfx.md index a3554754af..25b326f678 100644 --- a/zh-cn/application-dev/faqs/faqs-dfx.md +++ b/zh-cn/application-dev/faqs/faqs-dfx.md @@ -4,9 +4,9 @@ 使用于:OpenHarmony SDK 3.2.5.5版本 -1.通过业务日志打印,定位崩溃的代码位置。 +1. 通过业务日志打印,定位崩溃的代码位置。 -2.通过Crash文件查看报错信息,Crash文件路径是:/data/log/faultlog/faultlogger/。 +2. 通过Crash文件查看报错信息,Crash文件路径是:/data/log/faultlog/faultlogger/。 ## UiTest测试框架无法获取控件问题 diff --git a/zh-cn/application-dev/faqs/faqs-event-notification.md b/zh-cn/application-dev/faqs/faqs-event-notification.md index a035a58908..b507f8f85c 100644 --- a/zh-cn/application-dev/faqs/faqs-event-notification.md +++ b/zh-cn/application-dev/faqs/faqs-event-notification.md @@ -12,19 +12,19 @@ emitter数据大小限制不超过10240。 通过配置Notification.publish发布通知接口的参数NotificationRequest中wantAgent属性实现 -参考文档:[Notification](../reference/apis/js-apis-notification.md#notificationpublish)、[WantAgent](../reference/apis/js-apis-wantAgent.md) +参考文档:[Notification](../reference/apis/js-apis-notification.md#notificationpublish)、[WantAgent](../reference/apis/js-apis-app-ability-wantAgent.md) 示例: -``` -import WantAgent from '@ohos.wantAgent'; +```ts +import WantAgent from '@ohos.app.ability.wantAgent'; async function publishNotification() { let wantAgentInfo = { wants: [ { - bundleName: "com.example.notification", - abilityName: "MainAbility", + bundleName: "com.example.myapplication", + abilityName: "EntryAbility", } ], operationType: WantAgent.OperationType.START_ABILITIES, diff --git a/zh-cn/application-dev/faqs/faqs-file-management.md b/zh-cn/application-dev/faqs/faqs-file-management.md index ace4ddad85..25c84da0e2 100644 --- a/zh-cn/application-dev/faqs/faqs-file-management.md +++ b/zh-cn/application-dev/faqs/faqs-file-management.md @@ -6,7 +6,6 @@ 是递归删除。 - ## 如何实现如果文件不存在则创建文件 适用于:OpenHarmony SDK 3.2.6.3版本,API9 Stage模型 diff --git a/zh-cn/application-dev/faqs/faqs-graphics.md b/zh-cn/application-dev/faqs/faqs-graphics.md index 61d9981d2b..229d88e8ea 100644 --- a/zh-cn/application-dev/faqs/faqs-graphics.md +++ b/zh-cn/application-dev/faqs/faqs-graphics.md @@ -17,11 +17,11 @@ 适用于:OpenHarmony SDK 3.2.6.3版本,API9 Stage模型 1. 可以在onWindowStageCreate方法获取windowClass对象。 - - ``` + + ```ts onWindowStageCreate(windowStage) { // Main window is created, set main page for this ability - console.log("[Demo] MainAbility onWindowStageCreate") + console.log("[Demo] EntryAbility onWindowStageCreate") windowStage.getMainWindow((err, data) => { if (err.code) { console.error('Failed to obtain the main window.') @@ -34,8 +34,8 @@ ``` 2. 设置窗口全屏,隐藏状态栏。 - - ``` + + ```ts globalThis.windowClass.setFullScreen(isFullScreen, (err, data) => { if (err.code) { console.error('Failed to enable the full-screen mode. Cause:' + JSON.stringify(err)); @@ -53,8 +53,8 @@ 示例: - -``` + +```ts let promise = windowClass.getProperties(); promise.then((data)=> { console.info('Succeeded in obtaining the window properties. Data: ' + JSON.stringify(data.windowRect)); @@ -69,8 +69,8 @@ promise.then((data)=> { 参考如下方式实现,示例: - -``` + +```ts window.getTopWindow(globalThis.mainContext).then(win => { var systemBarProperties = { statusBarColor: '#19B6FF', // 状态栏背景颜色 diff --git a/zh-cn/application-dev/faqs/faqs-language.md b/zh-cn/application-dev/faqs/faqs-language.md index d92efc1985..72ba273698 100644 --- a/zh-cn/application-dev/faqs/faqs-language.md +++ b/zh-cn/application-dev/faqs/faqs-language.md @@ -16,7 +16,6 @@ TS语言的使用在生成器函数中存在以下限制: 错误示例: - ``` build() { let a: number = 1 // invalid: variable declaration not allowed @@ -54,7 +53,7 @@ build() { 1. 通过resourceManager的RawFile接口获取Uint8Array格式数据。 -2. 通过String.fromCharCode将Uint8Array格式数据转化为String类型。快快快 +2. 通过String.fromCharCode将Uint8Array格式数据转化为String类型。 参考文档:[资源管理](../reference/apis/js-apis-resource-manager.md) @@ -86,8 +85,6 @@ resourceManager.getRawFile(path, (error, value) => { Page和Ability打包后会对import的对象分别形成两个不同的闭包,即打包出两个Global对象。因此,所引用的静态变量并不是同一对象,所以无法通过class静态变量方式定义全局变量。建议使用AppStorage进行全局变量管理。 -参考文档:[应用程序的数据存储](../quick-start/arkts-state-mgmt-application-level.md) - ## Stage模型下如何获取资源 适用于:OpenHarmony SDK 3.2.3.5版本,API9 Stage模型 @@ -180,7 +177,7 @@ systemTime.getCurrentTime(false)和new Date().getTime()一样,都是返回1970 适用于:OpenHarmony SDK3.2.6.5, API9 Stage模型 -对\@BuilderParam修饰的属性进行赋值时不带参数(如:content: this.specificParam),则此属性的类型需定义成无返回值的函数(如:\@BuilderParam content: () => void);若带参数(如:callContent: this.specificParam1("111")),则此属性的类型需定义成any(如:\@BuilderParam callContent: any;),具体用法请参考[BuilderParam](../quick-start/arkts-dynamic-ui-elememt-building.md#builderparam8)。 +对\@BuilderParam修饰的属性进行赋值时不带参数(如:content: this.specificParam),则此属性的类型需定义成无返回值的函数(如:\@BuilderParam content: () => void);若带参数(如:callContent: this.specificParam1("111")),则此属性的类型需定义成any(如:\@BuilderParam callContent: any;)。 ## ArkTS如何把string转成byte数组 @@ -248,8 +245,6 @@ OpenHarmony推荐使用worker来处理多线程场景。 通过\@Observed配合\@ObjectLink装饰符实现。 -参考文档:[Observed和ObjectLink数据管理](../quick-start/arkts-state-mgmt-page-level.md#observed和objectlink数据管理) - ## 如何实现字符串编解码 适用于:OpenHarmony SDK 3.2.5.5版本,API9 Stage模型 diff --git a/zh-cn/application-dev/faqs/faqs-media.md b/zh-cn/application-dev/faqs/faqs-media.md index 353120e6c8..5233b35f5a 100644 --- a/zh-cn/application-dev/faqs/faqs-media.md +++ b/zh-cn/application-dev/faqs/faqs-media.md @@ -42,7 +42,7 @@ cameraInput = await this.cameraManager.createCameraInput(cameraId) 适用于:OpenHarmony 3.2.5.6版本,API9 Stage模型 1. **通过传入的uri创建图片源实例ImageSource对象。** - + ``` let path = this.context.getApplicationContext().fileDirs + "test.jpg"; const imageSourceApi = image.createImageSource(path); @@ -52,7 +52,7 @@ cameraInput = await this.cameraManager.createCameraInput(cameraId) - 设置desiredSize支持按尺寸缩放,如果设置为全0,则不进行缩放。 - 设置desiredRegion支持按矩形区域裁剪,如果设置为全0,则不进行裁剪。 - 设置rotateDegrees支持旋转角度,以图像中心点顺时针旋转。 - + ``` const decodingOptions = { desiredSize: { @@ -85,7 +85,7 @@ cameraInput = await this.cameraManager.createCameraInput(cameraId) 1. 在module.json5配置文件中配置媒体读写权限ohos.permission.READ_MEDIA和ohos.permission.WRITE_MEDIA。 示例: - + ``` { "module" : { @@ -104,13 +104,13 @@ cameraInput = await this.cameraManager.createCameraInput(cameraId) ``` 2. 这两个权限的授权方式均为user_grant,因此需要调用requestPermissionsFromUser接口,以动态弹窗的方式向用户申请授权。 - + ``` import abilityAccessCtrl from '@ohos.abilityAccessCtrl.d.ts'; let permissions: Array = ['ohos.permission.READ_MEDIA','ohos.permission.WRITE_MEDIA'] let atManager = abilityAccessCtrl.createAtManager(); - // context为调用方UIAbility的AbilityContext + // context为调用方UIAbility的UIAbilityContext atManager.requestPermissionsFromUser(context, permissions).then((data) => { console.log("Succeed to request permission from user with data: " + JSON.stringify(data)) }).catch((error) => { diff --git a/zh-cn/application-dev/faqs/faqs-native.md b/zh-cn/application-dev/faqs/faqs-native.md index c0a05db2c3..b67bb4162d 100644 --- a/zh-cn/application-dev/faqs/faqs-native.md +++ b/zh-cn/application-dev/faqs/faqs-native.md @@ -28,9 +28,9 @@ Native API中的[Drawing](../reference/native-apis/_drawing.md)接口可以提 适用于:OpenHarmony SDK 3.2.5.3版本,API9 Stage模型 -1. 在编译工具Hvigor脚本文件hvigorfile.js中,通过subModule.getPackageJsonPath方法获取module中package.json文件位置; +1. 在编译工具Hvigor脚本文件hvigorfile.js中,通过subModule.getPackageJsonPath方法获取module中package.json文件位置。 -2. 使用nodejs能力读取package.json文件中version字段,写入build-profile.json5文件buildOption.cppFlags字段; +2. 使用nodejs能力读取package.json文件中version字段,写入build-profile.json5文件buildOption.cppFlags字段。 示例: diff --git a/zh-cn/application-dev/faqs/faqs-ui-ets.md b/zh-cn/application-dev/faqs/faqs-ui-ets.md index 9afce454ad..13e60de3c7 100644 --- a/zh-cn/application-dev/faqs/faqs-ui-ets.md +++ b/zh-cn/application-dev/faqs/faqs-ui-ets.md @@ -23,7 +23,7 @@ 可以使用Stack堆叠容器,设置子组件在容器内的最底部。 示例: - + ``` build() { Stack({alignContent : Alignment.Bottom}) { @@ -59,7 +59,7 @@ build() { 示例: - + ``` // 弹窗组件 @CustomDialog @@ -144,7 +144,7 @@ GridContainer内子组件默认水平左对齐,居中显示可以参考以下 内部嵌套布局组件Row,设置Row属性justifyContent(FlexAlign.Center),内部嵌套子组件可保持居中显示,参考[栅格布局](../reference/arkui-ts/ts-container-gridcontainer.md)文档。 示例: - + ``` GridContainer({ sizeType: SizeType.SM, columns: 12 }) { Row() { @@ -164,10 +164,10 @@ GridContainer({ sizeType: SizeType.SM, columns: 12 }) { 在加载窗口内容之前,采用systemAvoidAreaChange事件监听。 示例: - -``` -// MainAbility.ts -import window from '@ohos.window'; + +```ts +import Window from '@ohos.window'; +import UIAbility from '@ohos.app.ability.UIAbility'; /** * 设置沉浸式窗口,并获取状态栏和导航栏高度 @@ -187,7 +187,7 @@ async function enterImmersion(mainWindow: window.Window) { statusBarContentColor: "#FF0000" }) } -export default class MainAbility extends Ability { +export default class EntryAbility extends UIAbility { // do something async onWindowStageCreate(windowStage: window.WindowStage) { let mainWindow = await windowStage.getMainWindow() @@ -212,8 +212,8 @@ gesture的属性distance默认值是5,把gesture的属性distance设成1就可 示例: - -``` + +```ts Column() { Text(this.value) .backgroundColor(Color.Green).margin(30).fontSize(20) @@ -234,8 +234,8 @@ List组件绑定Scoller控制器,通过currentOffset方式获取当前的滚 示例: - -``` + +```ts Column() { List({ space: 20, initialIndex: 0,scroller: this.scroller}) { ForEach(this.arr, (item) => { @@ -258,8 +258,8 @@ Column() { 适用于:OpenHarmony SDK 3.2.5.5版本,API9 Stage模型 - -``` + +```ts // 3.1.5.5版本之前,取值方式为:router.getParams().key private value: string = router.getParams().value; // 从3.1.6.5版本起,取值方式为:router.getParams()['key'] @@ -296,8 +296,8 @@ lpx相当于百分比视图,按比例扩大或者缩小。 颜色可以使用两种格式,例如 0x7F000000 或者 '\#7F000000' ,其中前两位是透明度,后六位是RGB。 - -``` + +```ts fontColor(0x7F000000) fontColor( '#7F000000' ) ``` @@ -306,7 +306,7 @@ fontColor( '#7F000000' ) 适用于:OpenHarmony SDK 3.2.5.5版本,API9 Stage模型 -在Page页面返回时,系统会调用\@Entry修饰的自定义组件的onBackPress()回调,可以在回调函数中实现相关业务诉求。参考[自定义组件生命周期回调函数](../ui/ui-ts-custom-component-lifecycle-callbacks.md) +在Page页面返回时,系统会调用\@Entry修饰的自定义组件的onBackPress()回调,可以在回调函数中实现相关业务诉求。参考[自定义组件生命周期回调函数](../reference/arkui-ts/ts-custom-component-lifecycle.md) ## TextInput组件密码模式下,右边的眼睛图标是否支持自定义? @@ -356,12 +356,6 @@ onSubmit事件在回车键或软键盘回车触发该回调,参数为当前软 页面路由栈支持的最大页面数量是32,当超出此限制时,使用router.push接口页面无法完成跳转 。 -## ArkUI是否支持通过代码动态创建组件 - -适用于:OpenHarmony SDK 3.2.6.5版本,API9 Stage模型 - -支持使用[条件渲染](../quick-start/arkts-rendering-control.md#条件渲染)和[循环渲染](../quick-start/arkts-rendering-control.md#循环渲染)等方式进行动态创建组件。 - ## 页面路由携带PixelMap对象参数,跳转页面无法获取 适用于:OpenHarmony SDK 3.2.6.5版本,API9 Stage模型 @@ -400,7 +394,7 @@ input 组件的 type 设置为 date,只是会有相关格式提示,本质上 示例: - + ``` @Component struct FoodImageDisplay { @@ -504,7 +498,7 @@ Scroll支持单个子组件,子组件高度应由内容高度决定,当内 可以参考如下实现: - + ``` struct Index { @State text: string = 'Hello World' @@ -545,12 +539,6 @@ id添加为唯一值,成为关键字。 基于OpenHarmony开发的应用,默认字体'HarmonyOS Sans',且当前只支持这种字体。 -## Ability与UI页面推荐的数据交互方式是什么 - -适用于:OpenHarmony SDK 3.2.7.5版本,API9 Stage模型 - -推荐使用[LocalStorage](../quick-start/arkts-state-mgmt-application-level.md#localstorage)。 - ## 父组件如何与其孙子组件进行状态同步 适用于:OpenHarmony SDK 3.2.6.5版本,API9 Stage模型 @@ -565,7 +553,7 @@ id添加为唯一值,成为关键字。 代码示例 - + ``` beautySub(str,len) { var reg = /[\u4e00-\u9fa5]/g; @@ -623,11 +611,9 @@ RichText底层是web,可以参考html的语法,在div上加上的overflow: 通过PersistentStorage类实现管理应用持久化数据,可以将特定标记的持久化数据链接到AppStorage中,并由AppStorage接口访问对应持久化数据。 -参考文档:[持久化数据管理](../quick-start/arkts-state-mgmt-application-level.md#persistentstorage) - 示例: - + ``` AppStorage.Link('varA') PersistentStorage.PersistProp("varA", "111"); diff --git a/zh-cn/application-dev/faqs/faqs-ui-js.md b/zh-cn/application-dev/faqs/faqs-ui-js.md index f2e540c747..39e7c8ac2a 100644 --- a/zh-cn/application-dev/faqs/faqs-ui-js.md +++ b/zh-cn/application-dev/faqs/faqs-ui-js.md @@ -91,5 +91,4 @@ export default class DateTimeUtil{ } } -``` - +``` \ No newline at end of file diff --git a/zh-cn/application-dev/faqs/faqs-web-arkts.md b/zh-cn/application-dev/faqs/faqs-web-arkts.md index c423c07b5e..03fd079d72 100644 --- a/zh-cn/application-dev/faqs/faqs-web-arkts.md +++ b/zh-cn/application-dev/faqs/faqs-web-arkts.md @@ -6,7 +6,6 @@ 设置是否开启文档对象模型存储接口(DOM Storage API)权限,默认未开启,控制web网页中localStorage的使用,对sessionStorage未做控制 - ## Web组件加载的html页面内如何检测网络状态 适用于:OpenHarmony SDK 3.2.7.5版本,API9 Stage模型 @@ -77,4 +76,4 @@ onAppear方法只是定位完Canvas的位置,onReady方法才是测量完成 4. 使用应用侧的端口0给HTML侧消息端口1发送消息。 -使用参考:[Web组件](../reference/arkui-ts/ts-basic-components-web.md#postmessage9) +使用参考:[Web组件](../reference/arkui-ts/ts-basic-components-web.md) diff --git a/zh-cn/application-dev/media/avplayer-avrecorder-overview.md b/zh-cn/application-dev/media/avplayer-avrecorder-overview.md index 0e62bb3abb..9bad52367c 100644 --- a/zh-cn/application-dev/media/avplayer-avrecorder-overview.md +++ b/zh-cn/application-dev/media/avplayer-avrecorder-overview.md @@ -35,7 +35,7 @@ AVPlayer提供功能完善一体化播放能力,应用只需要提供流媒体 应用通过调用JS接口层提供的AVPlayer接口实现相应功能时,框架层会通过播放服务(Player Framework)解析成单独的音频数据流和视频数据流,音频数据流经过软件解码后输出至音频服务(Audio Framework),再至硬件接口层的音频HDI,实现音频播放功能。视频数据流经过硬件(推荐)/软件解码后输出至图形渲染服务(Graphic Framework),再输出至硬件接口层的显示HDI,完成图形渲染。 -完整的视频播放需要:应用、XComponemt、Player Framework、Graphic Framework、Audio Framework、显示HDI和音频HDI共同实现。 +完整的视频播放需要:应用、XComponent、Player Framework、Graphic Framework、Audio Framework、显示HDI和音频HDI共同实现。 图2中,数字标注表示需要数据与外部模块的传递。 diff --git a/zh-cn/application-dev/media/avsession-overview.md b/zh-cn/application-dev/media/avsession-overview.md index d48476f864..446e027ad0 100644 --- a/zh-cn/application-dev/media/avsession-overview.md +++ b/zh-cn/application-dev/media/avsession-overview.md @@ -4,6 +4,8 @@ 音视频类应用接入媒体会话后,可以发送应用的数据(比如正在播放的歌曲、歌曲的播放状态等),用户可以通过系统播控中心、语音助手等应用切换多个应用、多个设备播放。音视频类应用如果不接入媒体会话,将无法在后台播放,在应用进入后台时,会被强制停止播放。 +实现后台播放,还需申请长时任务避免进入挂起(Suspend)状态。具体参考[长时任务开发指导](../task-management/continuous-task-dev-guide.md)。 + ## 基础概念 在开发前,需要先了解以下基础概念: diff --git a/zh-cn/application-dev/media/video-playback.md b/zh-cn/application-dev/media/video-playback.md index 127ae791d0..1cced19ac0 100644 --- a/zh-cn/application-dev/media/video-playback.md +++ b/zh-cn/application-dev/media/video-playback.md @@ -46,7 +46,7 @@ > > 下面代码示例中的url仅作示意使用,开发者需根据实际情况,确认资源有效性并设置: > - > - 如果使用本地资源播放,必须确认相应的资源文件可用,并使用应用沙箱路径访问对应资源,参考[获取应用文件路径](../application-models/application-context-stage.md#获取应用开发路径)。应用沙箱的介绍及如何向应用沙箱推送文件,请参考[文件管理](../file-management/app-sandbox-directory.md)。 + > - 如果使用本地资源播放,必须确认资源文件可用,并使用应用沙箱路径访问对应资源,参考[获取应用文件路径](../application-models/application-context-stage.md#获取应用开发路径)。应用沙箱的介绍及如何向应用沙箱推送文件,请参考[文件管理](../file-management/app-sandbox-directory.md)。 > > - 如果使用网络播放路径,需[申请相关权限](../security/accesstoken-guidelines.md):ohos.permission.INTERNET。 > @@ -61,7 +61,7 @@ 6. 视频播控:播放play(),暂停pause(),跳转seek(),停止stop() 等操作。 -7. (可选)更换资源:调用reset()重置资源,AVPlayer重新进入idle状态,允许更换资源url。 +7. (可选)更换资源:调用reset()重置资源,AVPlayer重新进入idle状态,允许更换资源url。 8. 退出播放:调用release()销毁实例,AVPlayer进入released状态,退出播放。 diff --git a/zh-cn/application-dev/reference/apis/development-intro.md b/zh-cn/application-dev/reference/apis/development-intro.md index d609303628..3ae0b33f7b 100644 --- a/zh-cn/application-dev/reference/apis/development-intro.md +++ b/zh-cn/application-dev/reference/apis/development-intro.md @@ -30,7 +30,7 @@ OpenHarmony中提供的接口,部分是仅供OEM厂商使用的system api, 随DevEco下载的SDK为public-SDK,不包括系统接口。如需使用系统接口,需要: - 参考[full-SDK替换指南](../../quick-start/full-sdk-switch-guide.md)将SDK替换为full-SDK。 -- 参考[HarmonyAppProvision配置文件的说明](../../security/app-provision-structure.md#harmonyappprovision配置文件的说明)修改HarmonyAppProvision配置文件中的app-feature字段为hos_system_app(系统应用)。 +- 参考[HarmonyAppProvision配置文件的说明](../../security/app-provision-structure.md)修改HarmonyAppProvision配置文件中的app-feature字段为hos_system_app(系统应用)。 ## 权限说明 -- GitLab