提交 69639820 编写于 作者: Y yyuanche

Merge branch 'master' into Dimension

...@@ -135,7 +135,7 @@ zh-cn/application-dev/IDL/ @RayShih @littlejerry1 @gwang2008 @ccllee @chengxingz ...@@ -135,7 +135,7 @@ zh-cn/application-dev/IDL/ @RayShih @littlejerry1 @gwang2008 @ccllee @chengxingz
zh-cn/application-dev/device-usage-statistics/ @chenmingJay @ningningW @tangtiantian2021 @nan-xiansen @iceice1001 zh-cn/application-dev/device-usage-statistics/ @chenmingJay @ningningW @tangtiantian2021 @nan-xiansen @iceice1001
zh-cn/application-dev/ui/ @HelloCrease @huaweimaxuchu @tomatodevboy @niulihua zh-cn/application-dev/ui/ @HelloCrease @huaweimaxuchu @tomatodevboy @niulihua
zh-cn/application-dev/notification/ @RayShih @jayleehw @li-weifeng2 @currydavids zh-cn/application-dev/notification/ @RayShih @jayleehw @li-weifeng2 @currydavids
zh-cn/application-dev/windowmanager/ @ge-yafang @zhangqiang183 @zhouyaoying @zxg-gitee zh-cn/application-dev/windowmanager/ @ge-yafang @zhangqiang183 @zhouyaoying @zxg-gitee @nobuggers
zh-cn/application-dev/webgl/ @zengyawen @zhangqiang183 @wind_zj @zxg-gitee zh-cn/application-dev/webgl/ @zengyawen @zhangqiang183 @wind_zj @zxg-gitee
zh-cn/application-dev/media/audio-overview.md @zengyawen @liuyuehua1 @saga2020 @currydavids zh-cn/application-dev/media/audio-overview.md @zengyawen @liuyuehua1 @saga2020 @currydavids
zh-cn/application-dev/media/audio-playback.md @zengyawen @liuyuehua1 @saga2020 @currydavids zh-cn/application-dev/media/audio-playback.md @zengyawen @liuyuehua1 @saga2020 @currydavids
...@@ -186,7 +186,7 @@ zh-cn/application-dev/dfx/errormanager-guidelines.md @littlejerry1 @ccllee @chen ...@@ -186,7 +186,7 @@ zh-cn/application-dev/dfx/errormanager-guidelines.md @littlejerry1 @ccllee @chen
zh-cn/application-dev/dfx/errormanager-guidelines.md @littlejerry1 @ccllee @chengxingzhen @RayShih zh-cn/application-dev/dfx/errormanager-guidelines.md @littlejerry1 @ccllee @chengxingzhen @RayShih
zh-cn/application-dev/key-features/multi-device-app-dev/ @lingminghw @crazyracing0726 zh-cn/application-dev/key-features/multi-device-app-dev/ @lingminghw @crazyracing0726
zh-cn/application-dev/database/ @ge-yafang @feng-aiwen @gong-a-shi @logic42 zh-cn/application-dev/database/ @ge-yafang @feng-aiwen @gong-a-shi @logic42
zh-cn/application-dev/napi/native-window-guidelines.md @ge-yafang @zhangqiang183 @zhouyaoying @zxg-gitee zh-cn/application-dev/napi/native-window-guidelines.md @ge-yafang @zhangqiang183 @zhouyaoying @zxg-gitee @nobuggers
zh-cn/application-dev/napi/mindspore-lite-guidelines.md @ge-yafang @grbuzhidao @jianghui58 @auraxu zh-cn/application-dev/napi/mindspore-lite-guidelines.md @ge-yafang @grbuzhidao @jianghui58 @auraxu
zh-cn/application-dev/napi/mindspore-lite-offline-model-guidelines.md @ge-yafang @grbuzhidao @jianghui58 @auraxu zh-cn/application-dev/napi/mindspore-lite-offline-model-guidelines.md @ge-yafang @grbuzhidao @jianghui58 @auraxu
zh-cn/application-dev/napi/rawfile_guidelines.md @ningningW zh-cn/application-dev/napi/rawfile_guidelines.md @ningningW
...@@ -275,9 +275,9 @@ zh-cn/application-dev/reference/apis/js-apis-application-shellCmdResult.md @litt ...@@ -275,9 +275,9 @@ zh-cn/application-dev/reference/apis/js-apis-application-shellCmdResult.md @litt
zh-cn/application-dev/reference/apis/js-apis-application-StartOptions.md @littlejerry1 @RayShih @gwang2008 @chengxingzhen zh-cn/application-dev/reference/apis/js-apis-application-StartOptions.md @littlejerry1 @RayShih @gwang2008 @chengxingzhen
zh-cn/application-dev/reference/apis/js-apis-application-staticSubscriberExtensionAbility.md @littlejerry1 @RayShih @gwang2008 @chengxingzhen zh-cn/application-dev/reference/apis/js-apis-application-staticSubscriberExtensionAbility.md @littlejerry1 @RayShih @gwang2008 @chengxingzhen
zh-cn/application-dev/reference/apis/js-apis-application-Want.md @littlejerry1 @RayShih @gwang2008 @chengxingzhen zh-cn/application-dev/reference/apis/js-apis-application-Want.md @littlejerry1 @RayShih @gwang2008 @chengxingzhen
zh-cn/application-dev/reference/apis/js-apis-application-WindowExtensionAbility.md @zhangqiang183 @ge-yafang @zhouyaoying @zxg-gitee zh-cn/application-dev/reference/apis/js-apis-application-WindowExtensionAbility.md @zhangqiang183 @ge-yafang @zhouyaoying @zxg-gitee @nobuggers
zh-cn/application-dev/application-models/windowextensionability.md @zhangqiang183 @ge-yafang @zhouyaoying @zxg-gitee zh-cn/application-dev/application-models/windowextensionability.md @zhangqiang183 @ge-yafang @zhouyaoying @zxg-gitee @nobuggers
zh-cn/application-dev/reference/apis/js-apis-inner-application-windowExtensionContext.md @ge-yafang @zhouyaoying @zxg-gitee zh-cn/application-dev/reference/apis/js-apis-inner-application-windowExtensionContext.md @ge-yafang @zhouyaoying @zxg-gitee @nobuggers
zh-cn/application-dev/reference/apis/js-apis-appmanager.md @littlejerry1 @RayShih @gwang2008 @chengxingzhen zh-cn/application-dev/reference/apis/js-apis-appmanager.md @littlejerry1 @RayShih @gwang2008 @chengxingzhen
zh-cn/application-dev/reference/apis/js-apis-arraylist.md @gongjunsong @ge-yafang @flyingwolf @BlackStone zh-cn/application-dev/reference/apis/js-apis-arraylist.md @gongjunsong @ge-yafang @flyingwolf @BlackStone
zh-cn/application-dev/reference/apis/js-apis-audio.md @liuyuehua1 @zengyawen @magekkkk @currydavids zh-cn/application-dev/reference/apis/js-apis-audio.md @liuyuehua1 @zengyawen @magekkkk @currydavids
...@@ -334,7 +334,7 @@ zh-cn/application-dev/reference/apis/js-apis-deque.md @gongjunsong @ge-yafang @f ...@@ -334,7 +334,7 @@ zh-cn/application-dev/reference/apis/js-apis-deque.md @gongjunsong @ge-yafang @f
zh-cn/application-dev/reference/apis/js-apis-device-info.md @mupceet @zengyawen @handyohos @nan-xiansen zh-cn/application-dev/reference/apis/js-apis-device-info.md @mupceet @zengyawen @handyohos @nan-xiansen
zh-cn/application-dev/reference/apis/js-apis-device-manager.md @intermilano @RayShih @william-ligang @liuhonggang123 zh-cn/application-dev/reference/apis/js-apis-device-manager.md @intermilano @RayShih @william-ligang @liuhonggang123
zh-cn/application-dev/reference/apis/js-apis-deviceUsageStatistics.md @shuaytao @RayShih @wangzhen107 @inter515 zh-cn/application-dev/reference/apis/js-apis-deviceUsageStatistics.md @shuaytao @RayShih @wangzhen107 @inter515
zh-cn/application-dev/reference/apis/js-apis-display.md @zhangqiang183 @ge-yafang @zhouyaoying @zxg-gitee zh-cn/application-dev/reference/apis/js-apis-display.md @zhangqiang183 @ge-yafang @zhouyaoying @zxg-gitee @nobuggers
zh-cn/application-dev/reference/apis/js-apis-distributed-account.md @nianCode @zengyawen @JiDong-CS @murphy1984 zh-cn/application-dev/reference/apis/js-apis-distributed-account.md @nianCode @zengyawen @JiDong-CS @murphy1984
zh-cn/application-dev/reference/apis/js-apis-distributed-data.md @feng-aiwen @ge-yafang @gong-a-shi @logic42 zh-cn/application-dev/reference/apis/js-apis-distributed-data.md @feng-aiwen @ge-yafang @gong-a-shi @logic42
zh-cn/application-dev/reference/apis/js-apis-distributedMissionManager.md @chenmingJay @ningningW @nan-xiansen @iceice1001 zh-cn/application-dev/reference/apis/js-apis-distributedMissionManager.md @chenmingJay @ningningW @nan-xiansen @iceice1001
...@@ -419,8 +419,8 @@ zh-cn/application-dev/reference/apis/js-apis-router.md @huaweimaxuchu @HelloCrea ...@@ -419,8 +419,8 @@ zh-cn/application-dev/reference/apis/js-apis-router.md @huaweimaxuchu @HelloCrea
zh-cn/application-dev/reference/apis/js-apis-rpc.md @xuepianpian @RayShih @zhaopeng_gitee @vagrant_world zh-cn/application-dev/reference/apis/js-apis-rpc.md @xuepianpian @RayShih @zhaopeng_gitee @vagrant_world
zh-cn/application-dev/reference/apis/js-apis-runninglock.md @aqxyjay @zengyawen @aqxyjay @alien0208 zh-cn/application-dev/reference/apis/js-apis-runninglock.md @aqxyjay @zengyawen @aqxyjay @alien0208
zh-cn/application-dev/reference/apis/js-apis-screen.md @zhangqiang183 @ge-yafang @zhouyaoying @zxg-gitee zh-cn/application-dev/reference/apis/js-apis-screen.md @zhangqiang183 @ge-yafang @zhouyaoying @zxg-gitee @nobuggers
zh-cn/application-dev/reference/apis/js-apis-screenshot.md @zhangqiang183 @ge-yafang @zhouyaoying @zxg-gitee zh-cn/application-dev/reference/apis/js-apis-screenshot.md @zhangqiang183 @ge-yafang @zhouyaoying @zxg-gitee @nobuggers
zh-cn/application-dev/reference/apis/js-apis-securityLabel.md @panqinxu @zengyawen @bubble_mao @jinhaihw zh-cn/application-dev/reference/apis/js-apis-securityLabel.md @panqinxu @zengyawen @bubble_mao @jinhaihw
zh-cn/application-dev/reference/apis/js-apis-sensor.md @hellohyh001 @ningningW @butterls @star-wind-snow-and-rain zh-cn/application-dev/reference/apis/js-apis-sensor.md @hellohyh001 @ningningW @butterls @star-wind-snow-and-rain
zh-cn/application-dev/reference/apis/js-apis-service-extension-ability.md @littlejerry1 @RayShih @gwang2008 @chengxingzhen zh-cn/application-dev/reference/apis/js-apis-service-extension-ability.md @littlejerry1 @RayShih @gwang2008 @chengxingzhen
...@@ -482,7 +482,7 @@ zh-cn/application-dev/reference/apis/js-apis-webgl2.md @zhangqiang183 @ge-yafan ...@@ -482,7 +482,7 @@ zh-cn/application-dev/reference/apis/js-apis-webgl2.md @zhangqiang183 @ge-yafan
zh-cn/application-dev/reference/apis/js-apis-webSocket.md @zhang-hai-feng @zengyawen @jyh926 @gaoxi785 zh-cn/application-dev/reference/apis/js-apis-webSocket.md @zhang-hai-feng @zengyawen @jyh926 @gaoxi785
zh-cn/application-dev/reference/apis/js-apis-wifi.md @cheng_guohong @RayShih @cheng_guohong @quanli125 zh-cn/application-dev/reference/apis/js-apis-wifi.md @cheng_guohong @RayShih @cheng_guohong @quanli125
zh-cn/application-dev/reference/apis/js-apis-wifiext.md @cheng_guohong @RayShih @cheng_guohong @quanli125 zh-cn/application-dev/reference/apis/js-apis-wifiext.md @cheng_guohong @RayShih @cheng_guohong @quanli125
zh-cn/application-dev/reference/apis/js-apis-window.md @zhangqiang183 @ge-yafang @zhouyaoying @zxg-gitee zh-cn/application-dev/reference/apis/js-apis-window.md @zhangqiang183 @ge-yafang @zhouyaoying @zxg-gitee @nobuggers
zh-cn/application-dev/reference/apis/js-apis-windowAnimationManager.md @zhangqiang183 @ge-yafang @wind_zj @zxg-gitee zh-cn/application-dev/reference/apis/js-apis-windowAnimationManager.md @zhangqiang183 @ge-yafang @wind_zj @zxg-gitee
zh-cn/application-dev/reference/apis/js-apis-worker.md @gongjunsong @ge-yafang @flyingwolf @BlackStone zh-cn/application-dev/reference/apis/js-apis-worker.md @gongjunsong @ge-yafang @flyingwolf @BlackStone
zh-cn/application-dev/reference/apis/js-apis-taskpool.md @gongjunsong @ge-yafang @flyingwolf @BlackStone zh-cn/application-dev/reference/apis/js-apis-taskpool.md @gongjunsong @ge-yafang @flyingwolf @BlackStone
......
# Device Usage Statistics Development (API Version 9) # Device Usage Statistics Development
## When to Use ## When to Use
...@@ -38,7 +38,7 @@ import usageStatistics from '@ohos.resourceschedule.usageStatistics'; ...@@ -38,7 +38,7 @@ import usageStatistics from '@ohos.resourceschedule.usageStatistics';
## How to Develop ## How to Develop
1. Before obtaining the device usage statistics, check whether the **ohos.permission.BUNDLE_ACTIVE_INFO** permission is configured. For details about how to configure a permission, see [Declaring Permissions](../security/accesstoken-guidelines.md). 1. Before obtaining the device usage statistics, check whether the **ohos.permission.BUNDLE_ACTIVE_INFO** permission is configured. For details about how to configure a permission, see [Declaring Permissions](../security/accesstoken-guidelines.md).
2. Query events of all applications based on the specified start time and end time. This requires the **ohos.permission.BUNDLE_ACTIVE_INFO** permission to be configured. 2. Query events of all applications based on the specified start time and end time. This requires the **ohos.permission.BUNDLE_ACTIVE_INFO** permission to be configured.
```js ```js
......
# Native APIs # Native APIs
- [Introduction to Native APIs](introduction.md) - [Introduction to Native APIs](introduction.md)
- [Using N-APIs in Application Projects](napi-guidelines.md) - [Using Native APIs in Application Projects](napi-guidelines.md)
- [Drawing Development](drawing-guidelines.md) - [Drawing Development](drawing-guidelines.md)
- [Raw File Development](rawfile-guidelines.md) - [Raw File Development](rawfile-guidelines.md)
- [Native Window Development](native-window-guidelines.md) - [Native Window Development](native-window-guidelines.md)
......
# Using N-APIs in Application Projects # Using Native APIs in Application Projects
In OpenHarmony, you can use the N-APIs in C APIs to implement interaction between ArkTS/TS/JS and C/C++. The N-API names are the same as those in the third-party **Node.js**. Currently, OpenHarmony supports some N-APIs. For details about the APIs supported, see [arkui_napi](https://gitee.com/openharmony/arkui_napi/blob/master/libnapi.ndk.json). In OpenHarmony, you can use the N-APIs in C APIs to implement interaction between ArkTS/TS/JS and C/C++. The N-API names are the same as those in the third-party **Node.js**. Currently, OpenHarmony supports some N-APIs. For details about the APIs supported, see [arkui_napi](https://gitee.com/openharmony/arkui_napi/blob/master/libnapi.ndk.json).
......
...@@ -210,6 +210,9 @@ ...@@ -210,6 +210,9 @@
- [@ohos.multimedia.camera (Camera Management)](js-apis-camera.md) - [@ohos.multimedia.camera (Camera Management)](js-apis-camera.md)
- [@ohos.multimedia.image (Image Processing)](js-apis-image.md) - [@ohos.multimedia.image (Image Processing)](js-apis-image.md)
- [@ohos.multimedia.media (Media)](js-apis-media.md) - [@ohos.multimedia.media (Media)](js-apis-media.md)
- [@ohos.multimedia.systemSoundManager (System Sound Management)](js-apis-systemSoundManager.md)
- multimedia
- [ringtonePlayer (Ringtone Player)](js-apis-inner-multimedia-ringtonePlayer.md)
- Resource Manager - Resource Manager
- [@ohos.i18n (Internationalization)](js-apis-i18n.md) - [@ohos.i18n (Internationalization)](js-apis-i18n.md)
...@@ -319,6 +322,7 @@ ...@@ -319,6 +322,7 @@
- [@ohos.InputMethodExtensionAbility (InputMethodExtensionAbility)](js-apis-inputmethod-extension-ability.md) - [@ohos.InputMethodExtensionAbility (InputMethodExtensionAbility)](js-apis-inputmethod-extension-ability.md)
- [@ohos.InputMethodExtensionContext (InputMethodExtensionContext)](js-apis-inputmethod-extension-context.md) - [@ohos.InputMethodExtensionContext (InputMethodExtensionContext)](js-apis-inputmethod-extension-context.md)
- [@ohos.InputMethodSubtype (Input Method Subtype)](js-apis-inputmethod-subtype.md) - [@ohos.InputMethodSubtype (Input Method Subtype)](js-apis-inputmethod-subtype.md)
- [@ohos.logLibrary (Log Library)](js-apis-loglibrary.md)
- [@ohos.pasteboard (Pasteboard)](js-apis-pasteboard.md) - [@ohos.pasteboard (Pasteboard)](js-apis-pasteboard.md)
- [@ohos.screenLock (Screenlock)](js-apis-screen-lock.md) - [@ohos.screenLock (Screenlock)](js-apis-screen-lock.md)
- [@ohos.systemDateTime (System Time and Time Zone)](js-apis-system-date-time.md) - [@ohos.systemDateTime (System Time and Time Zone)](js-apis-system-date-time.md)
......
...@@ -247,7 +247,7 @@ Cancels the listener for changes in the list of enabled accessibility extension ...@@ -247,7 +247,7 @@ Cancels the listener for changes in the list of enabled accessibility extension
| Name| Type| Mandatory| Description| | Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
| type | string | Yes| Listening type. The value is fixed at **'enabledAccessibilityExtensionListChange'**, indicating listening for changes in the list of enabled accessibility extension abilities.| | type | string | Yes| Listening type. The value is fixed at **'enabledAccessibilityExtensionListChange'**, indicating listening for changes in the list of enabled accessibility extension abilities.|
| callback | Callback<void> | No| Callback invoked when the list of enabled accessibility extension abilities changes.| | callback | Callback<void> | No| Callback for the event.|
**Example** **Example**
...@@ -425,7 +425,7 @@ Cancels the listener for attribute changes. This API uses an asynchronous callba ...@@ -425,7 +425,7 @@ Cancels the listener for attribute changes. This API uses an asynchronous callba
| Name| Type| Mandatory| Description| | Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
| callback | Callback<T> | No| Callback invoked when the list of enabled accessibility extension abilities changes.| | callback | Callback<T> | No| Callback for the event.|
**Example** **Example**
......
...@@ -22,9 +22,9 @@ Checks whether this application is undergoing a stability test. This API uses an ...@@ -22,9 +22,9 @@ Checks whether this application is undergoing a stability test. This API uses an
**Parameters** **Parameters**
| Type| Description| | Type| Description|
| -------- | -------- | | -------- | -------- |
|AsyncCallback<boolean> |Callback used to return the API call result and the result **true** or **false**. You can perform error handling or custom processing in this callback. The value **true** means that the application is undergoing a stability test, and **false** means the opposite.| |AsyncCallback<boolean> |Callback used to return the API call result and the result **true** or **false**. You can perform error handling or custom processing in this callback. The value **true** means that the application is undergoing a stability test, and **false** means the opposite.|
**Error codes** **Error codes**
...@@ -59,9 +59,9 @@ Checks whether this application is undergoing a stability test. This API uses a ...@@ -59,9 +59,9 @@ Checks whether this application is undergoing a stability test. This API uses a
**Return value** **Return value**
| Type| Description| | Type| Description|
| -------- | -------- | | -------- | -------- |
| Promise<boolean> | Promise used to return the API call result and the result **true** or **false**. You can perform error handling or custom processing in this callback. The value **true** means that the application is undergoing a stability test, and **false** means the opposite.| | Promise<boolean> | Promise used to return the API call result and the result **true** or **false**. You can perform error handling or custom processing in this callback. The value **true** means that the application is undergoing a stability test, and **false** means the opposite.|
**Error codes** **Error codes**
...@@ -94,9 +94,9 @@ Checks whether this application is running on a RAM constrained device. This API ...@@ -94,9 +94,9 @@ Checks whether this application is running on a RAM constrained device. This API
**Return value** **Return value**
| Type| Description| | Type| Description|
| -------- | -------- | | -------- | -------- |
| Promise<boolean> | Promise used to return the API call result and the result **true** or **false**. You can perform error handling or custom processing in this callback. The value **true** means that the application is running on a RAM constrained device, and **false** means the opposite.| | Promise<boolean> | Promise used to return the API call result and the result **true** or **false**. You can perform error handling or custom processing in this callback. The value **true** means that the application is running on a RAM constrained device, and **false** means the opposite.|
**Error codes** **Error codes**
...@@ -128,9 +128,9 @@ Checks whether this application is running on a RAM constrained device. This API ...@@ -128,9 +128,9 @@ Checks whether this application is running on a RAM constrained device. This API
**Parameters** **Parameters**
| Type| Description| | Type| Description|
| -------- | -------- | | -------- | -------- |
| AsyncCallback<boolean> |Callback used to return the API call result and the result **true** or **false**. You can perform error handling or custom processing in this callback. The value **true** means that the application is running on a RAM constrained device, and **false** means the opposite.| | AsyncCallback<boolean> |Callback used to return the API call result and the result **true** or **false**. You can perform error handling or custom processing in this callback. The value **true** means that the application is running on a RAM constrained device, and **false** means the opposite.|
**Error codes** **Error codes**
...@@ -164,9 +164,9 @@ Obtains the memory size of this application. This API uses a promise to return t ...@@ -164,9 +164,9 @@ Obtains the memory size of this application. This API uses a promise to return t
**Return value** **Return value**
| Type| Description| | Type| Description|
| -------- | -------- | | -------- | -------- |
| Promise<number> | Promise used to return the API call result and the memory size. You can perform error handling or custom processing in this callback.| | Promise<number> | Promise used to return the API call result and the memory size. You can perform error handling or custom processing in this callback.|
**Error codes** **Error codes**
...@@ -198,9 +198,9 @@ Obtains the memory size of this application. This API uses an asynchronous callb ...@@ -198,9 +198,9 @@ Obtains the memory size of this application. This API uses an asynchronous callb
**Parameters** **Parameters**
| Type| Description| | Type| Description|
| -------- | -------- | | -------- | -------- |
|AsyncCallback<number> |Callback used to return the API call result and the memory size. You can perform error handling or custom processing in this callback.| |AsyncCallback<number> |Callback used to return the API call result and the memory size. You can perform error handling or custom processing in this callback.|
**Error codes** **Error codes**
...@@ -298,6 +298,82 @@ appManager.getRunningProcessInformation((err, data) => { ...@@ -298,6 +298,82 @@ appManager.getRunningProcessInformation((err, data) => {
}); });
``` ```
## appManager.isSharedBundleRunning
isSharedBundleRunning(bundleName: string, versionCode: number): Promise\<boolean>;
Checks whether the shared library is in use. This API uses a promise to return the result.
**Required permissions**: ohos.permission.GET_RUNNING_INFO
**System capability**: SystemCapability.Ability.AbilityRuntime.Core
**System API**: This is a system API.
**Parameters**
| Name | Type | Mandatory | Description |
| --------- | ---------------------------------------- | ---- | -------------- |
| bundleName | string | Yes | Bundle name of the shared library.|
| versionCode | number | Yes | Version number of the shared library. |
**Return value**
| Type| Description|
| -------- | -------- |
| Promise\<boolean> | Promise used to return the result. The value **true** means that the shared library is in use, and **false** means the opposite.|
**Example**
```ts
import appManager from '@ohos.app.ability.appManager';
appManager.isSharedBundleRunning(bundleName, versionCode).then((data) => {
console.log('The shared bundle running is: ${JSON.stringify(data)}');
}).catch((error) => {
console.error('error: ${JSON.stringify(error)}');
});
```
## appManager.isSharedBundleRunning
isSharedBundleRunning(bundleName: string, versionCode: number, callback: AsyncCallback\<boolean>): void;
Checks whether the shared library is in use. This API uses an asynchronous callback to return the result.
**Required permissions**: ohos.permission.GET_RUNNING_INFO
**System capability**: SystemCapability.Ability.AbilityRuntime.Core
**System API**: This is a system API.
**Parameters**
| Name | Type | Mandatory | Description |
| --------- | ---------------------------------------- | ---- | -------------- |
| bundleName | string | Yes | Bundle name of the shared library.|
| versionCode | number | Yes | Version number of the shared library. |
**Return value**
| Type| Description|
| -------- | -------- |
|AsyncCallback\<boolean>> | Callback used to return the result. The value **true** means that the shared library is in use, and **false** means the opposite.|
**Example**
```ts
import appManager from '@ohos.app.ability.appManager';
appManager.isSharedBundleRunning(bundleName, versionCode, (err, data) => {
if (err) {
console.error('err: ${JSON.stringify(err)}');
} else {
console.log('The shared bundle running is: ${JSON.stringify(data)}');
}
});
```
## appManager.on ## appManager.on
on(type: 'applicationState', observer: ApplicationStateObserver): number; on(type: 'applicationState', observer: ApplicationStateObserver): number;
...@@ -641,7 +717,7 @@ Obtains applications that are running in the foreground. This API uses a promise ...@@ -641,7 +717,7 @@ Obtains applications that are running in the foreground. This API uses a promise
| Type| Description| | Type| Description|
| -------- | -------- | | -------- | -------- |
| Promise\<Array\<[AppStateData](js-apis-inner-application-appStateData.md)>> | Promise used to return an array holding the application state data. | | Promise\<Array\<[AppStateData](js-apis-inner-application-appStateData.md)>> | Promise used to return an array holding the application state data.|
**Error codes** **Error codes**
...@@ -731,11 +807,11 @@ Kills a process by bundle name and account ID. This API uses an asynchronous cal ...@@ -731,11 +807,11 @@ Kills a process by bundle name and account ID. This API uses an asynchronous cal
**Parameters** **Parameters**
| Name| Type| Mandatory| Description| | Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
| bundleName | string | Yes| Bundle name.| | bundleName | string | Yes| Bundle name.|
| accountId | number | Yes| ID of a system account. For details, see [getCreatedOsAccountsCount](js-apis-osAccount.md#getosaccountlocalidfromprocess).| | accountId | number | Yes| ID of a system account. For details, see [getCreatedOsAccountsCount](js-apis-osAccount.md#getosaccountlocalidfromprocess).|
| callback | AsyncCallback\<void\> | Yes| Callback used to return the API call result. You can perform error handling or custom processing in this callback.| | callback | AsyncCallback\<void\> | Yes| Callback used to return the API call result. You can perform error handling or custom processing in this callback.|
**Error codes** **Error codes**
......
...@@ -116,8 +116,8 @@ struct SnapshotExample { ...@@ -116,8 +116,8 @@ struct SnapshotExample {
Image(this.pixmap) Image(this.pixmap)
.width(300).height(300) .width(300).height(300)
// ...Component // ...Component
// ...Components // ...Component
// ...Components // ...Component
Button("click to generate UI snapshot") Button("click to generate UI snapshot")
.onClick(() => { .onClick(() => {
componentSnapshot.get("root") componentSnapshot.get("root")
......
...@@ -2,8 +2,7 @@ ...@@ -2,8 +2,7 @@
> **NOTE** > **NOTE**
> >
> - The initial APIs of this module are supported since API version 9. Newly added APIs will be marked with a superscript to indicate their earliest API version. > The initial APIs of this module are supported since API version 10. Newly added APIs will be marked with a superscript to indicate their earliest API version.
> - The APIs provided by this module are system APIs.
## Modules to Import ## Modules to Import
...@@ -110,17 +109,18 @@ Enumerates the camera error codes, which are returned when an API call is incorr ...@@ -110,17 +109,18 @@ Enumerates the camera error codes, which are returned when an API call is incorr
**System capability**: SystemCapability.Multimedia.Camera.Core **System capability**: SystemCapability.Multimedia.Camera.Core
| Name | Value | Description | | Name | Value | Description |
| ------------------------- | ---- | ------------ | | ------------------------- | ---- | ------------ |
| INVALID_ARGUMENT | 7400101 | A parameter is missing or the parameter type is incorrect. | | INVALID_ARGUMENT | 7400101 | A parameter is missing or the parameter type is incorrect. |
| OPERATION_NOT_ALLOWED | 7400102 | The operation is not allowed. | | OPERATION_NOT_ALLOWED | 7400102 | The operation is not allowed. |
| SESSION_NOT_CONFIG | 7400103 | The session is not configured. | | SESSION_NOT_CONFIG | 7400103 | The session is not configured. |
| SESSION_NOT_RUNNING | 7400104 | The session is not running. | | SESSION_NOT_RUNNING | 7400104 | The session is not running. |
| SESSION_CONFIG_LOCKED | 7400105 | The session configuration is locked. | | SESSION_CONFIG_LOCKED | 7400105 | The session configuration is locked. |
| DEVICE_SETTING_LOCKED | 7400106 | The device setting is locked. | | DEVICE_SETTING_LOCKED | 7400106 | The device setting is locked. |
| CONFILICT_CAMERA | 7400107 | The device is already started. | | CONFLICT_CAMERA | 7400107 | The device is already started. |
| DEVICE_DISABLED | 7400108 | The camera is disabled for security reasons. | | DEVICE_DISABLED | 7400108 | The camera is disabled for security reasons. |
| SERVICE_FATAL_ERROR | 7400201 | An error occurs in the camera service. | | DEVICE_PREEMPTED | 7400109 | The camera is preempted. |
| SERVICE_FATAL_ERROR | 7400201 | An error occurs in the camera service. |
## CameraManager ## CameraManager
...@@ -203,7 +203,7 @@ isCameraMuteSupported(): boolean ...@@ -203,7 +203,7 @@ isCameraMuteSupported(): boolean
Checks whether the camera can be muted. Checks whether the camera can be muted.
This is a system API. **System API**: This is a system API.
**System capability**: SystemCapability.Multimedia.Camera.Core **System capability**: SystemCapability.Multimedia.Camera.Core
...@@ -225,7 +225,7 @@ muteCamera(mute: boolean): void ...@@ -225,7 +225,7 @@ muteCamera(mute: boolean): void
Mutes or unmutes the camera. Mutes or unmutes the camera.
This is a system API. **System API**: This is a system API.
**System capability**: SystemCapability.Multimedia.Camera.Core **System capability**: SystemCapability.Multimedia.Camera.Core
...@@ -562,7 +562,7 @@ on(type: 'cameraMute', callback: AsyncCallback\<boolean\>): void ...@@ -562,7 +562,7 @@ on(type: 'cameraMute', callback: AsyncCallback\<boolean\>): void
Listens for camera mute status changes. This API uses an asynchronous callback to return the result. Listens for camera mute status changes. This API uses an asynchronous callback to return the result.
This is a system API. **System API**: This is a system API.
**System capability**: SystemCapability.Multimedia.Camera.Core **System capability**: SystemCapability.Multimedia.Camera.Core
...@@ -630,6 +630,20 @@ Enumerates the camera connection types. ...@@ -630,6 +630,20 @@ Enumerates the camera connection types.
| CAMERA_CONNECTION_USB_PLUGIN | 1 | Camera connected using USB.| | CAMERA_CONNECTION_USB_PLUGIN | 1 | Camera connected using USB.|
| CAMERA_CONNECTION_REMOTE | 2 | Remote camera.| | CAMERA_CONNECTION_REMOTE | 2 | Remote camera.|
## HostDeviceType
Enumerates the remote camera types.
**System API**: This is a system API.
**System capability**: SystemCapability.Multimedia.Camera.Core
| Name | Value | Description |
| ---------------------------- | ---- | ------------- |
| UNKNOWN_TYPE | 0 | Unknown type. |
| PHONE | 0x0E | Camera of a smartphone.|
| TABLET | 0x11 | Camera of a tablet.|
## CameraDevice ## CameraDevice
Defines the camera device information. Defines the camera device information.
...@@ -642,6 +656,8 @@ Defines the camera device information. ...@@ -642,6 +656,8 @@ Defines the camera device information.
| cameraPosition | [CameraPosition](#cameraposition) | Yes | Camera position. | | cameraPosition | [CameraPosition](#cameraposition) | Yes | Camera position. |
| cameraType | [CameraType](#cameratype) | Yes | Camera type. | | cameraType | [CameraType](#cameratype) | Yes | Camera type. |
| connectionType | [ConnectionType](#connectiontype) | Yes | Camera connection type.| | connectionType | [ConnectionType](#connectiontype) | Yes | Camera connection type.|
| hostDeviceName | string | Yes | Name of the remote device.<br>**System API**: This is a system API.|
| hostDeviceType | [hostDeviceType](#hostdevicetype) | Yes | Type of the remote device.<br>**System API**: This is a system API.|
## Size ## Size
...@@ -1754,7 +1770,7 @@ Before the setting, you are advised to use **[getExposureBiasRange](#getexposure ...@@ -1754,7 +1770,7 @@ Before the setting, you are advised to use **[getExposureBiasRange](#getexposure
| Name | Type | Mandatory| Description | | Name | Type | Mandatory| Description |
| -------- | -------------------------------| ---- | ------------------- | | -------- | -------------------------------| ---- | ------------------- |
| exposureBias | number | Yes | EV. The supported EV range can be obtained by calling **getExposureBiasRange**. If calling the API fails, an error code defined in [CameraErrorCode](#cameraerrorcode) will be returned. If the value passed is not within the supported range, the nearest critical point is used.| | exposureBias | number | Yes | EV. The supported EV range can be obtained by calling **getExposureBiasRange**. If the value passed is not within the supported range, the nearest critical point is used. There is a step for EV. For example, if the step is 0.5 and this parameter is set to 1.2, the EV that takes effect is 1.0. If the operation fails, an error code defined in [CameraErrorCode](#cameraerrorcode) is returned. |
**Error codes** **Error codes**
...@@ -1788,7 +1804,7 @@ Obtains the exposure value in use. ...@@ -1788,7 +1804,7 @@ Obtains the exposure value in use.
| Type | Description | | Type | Description |
| ---------- | ----------------------------- | | ---------- | ----------------------------- |
| number | Exposure value obtained. If the operation fails, an error code defined in [CameraErrorCode](#cameraerrorcode) is returned.| | number | Exposure value obtained. There is a step for EV. For example, if the step is 0.5 and this parameter is set to 1.2, the EV that takes effect is 1.0. If the operation fails, an error code defined in [CameraErrorCode](#cameraerrorcode) is returned. |
**Error codes** **Error codes**
......
...@@ -433,7 +433,7 @@ try { ...@@ -433,7 +433,7 @@ try {
getWindows(callback: AsyncCallback\<Array\<AccessibilityElement>>): void; getWindows(callback: AsyncCallback\<Array\<AccessibilityElement>>): void;
Obtains the list of windows on a display. This API uses an asynchronous callback to return the result. Obtains the list of windows on this display. This API uses an asynchronous callback to return the result.
**System capability**: SystemCapability.BarrierFree.Accessibility.Core **System capability**: SystemCapability.BarrierFree.Accessibility.Core
...@@ -610,7 +610,7 @@ Defines the accessibilityelement. Before calling APIs of **AccessibilityElement* ...@@ -610,7 +610,7 @@ Defines the accessibilityelement. Before calling APIs of **AccessibilityElement*
**System capability**: SystemCapability.BarrierFree.Accessibility.Core **System capability**: SystemCapability.BarrierFree.Accessibility.Core
## attributeNames ### attributeNames
attributeNames\<T extends keyof ElementAttributeValues>(): Promise\<Array\<T>>; attributeNames\<T extends keyof ElementAttributeValues>(): Promise\<Array\<T>>;
...@@ -636,7 +636,7 @@ rootElement.attributeNames().then((data) => { ...@@ -636,7 +636,7 @@ rootElement.attributeNames().then((data) => {
console.log('failed to get attribute names, because ${JSON.stringify(err)}'); console.log('failed to get attribute names, because ${JSON.stringify(err)}');
}); });
``` ```
## attributeNames ### attributeNames
attributeNames\<T extends keyof ElementAttributeValues>(callback: AsyncCallback\<Array\<T>>): void; attributeNames\<T extends keyof ElementAttributeValues>(callback: AsyncCallback\<Array\<T>>): void;
...@@ -664,7 +664,7 @@ rootElement.attributeNames((err, data) => { ...@@ -664,7 +664,7 @@ rootElement.attributeNames((err, data) => {
console.info('get attribute names success'); console.info('get attribute names success');
}); });
``` ```
## AccessibilityElement.attributeValue ### attributeValue
attributeValue\<T extends keyof ElementAttributeValues>(attributeName: T): Promise\<ElementAttributeValues[T]>; attributeValue\<T extends keyof ElementAttributeValues>(attributeName: T): Promise\<ElementAttributeValues[T]>;
...@@ -709,7 +709,7 @@ try { ...@@ -709,7 +709,7 @@ try {
console.error('failed to get attribute value, because ${JSON.stringify(exception)}'); console.error('failed to get attribute value, because ${JSON.stringify(exception)}');
} }
``` ```
## AccessibilityElement.attributeValue ### attributeValue
attributeValue\<T extends keyof ElementAttributeValues>(attributeName: T, attributeValue\<T extends keyof ElementAttributeValues>(attributeName: T,
callback: AsyncCallback\<ElementAttributeValues[T]>): void; callback: AsyncCallback\<ElementAttributeValues[T]>): void;
...@@ -752,7 +752,7 @@ try { ...@@ -752,7 +752,7 @@ try {
console.error('failed to get attribute value, because ${JSON.stringify(exception)}'); console.error('failed to get attribute value, because ${JSON.stringify(exception)}');
} }
``` ```
## actionNames ### actionNames
actionNames(): Promise\<Array\<string>>; actionNames(): Promise\<Array\<string>>;
...@@ -778,7 +778,7 @@ rootElement.actionNames().then((data) => { ...@@ -778,7 +778,7 @@ rootElement.actionNames().then((data) => {
console.error('failed to get action names because ${JSON.stringify(err)}'); console.error('failed to get action names because ${JSON.stringify(err)}');
}); });
``` ```
## actionNames ### actionNames
actionNames(callback: AsyncCallback\<Array\<string>>): void; actionNames(callback: AsyncCallback\<Array\<string>>): void;
...@@ -806,7 +806,7 @@ rootElement.actionNames((err, data) => { ...@@ -806,7 +806,7 @@ rootElement.actionNames((err, data) => {
console.info('get action names success'); console.info('get action names success');
}); });
``` ```
## performAction ### performAction
performAction(actionName: string, parameters?: object): Promise\<void>; performAction(actionName: string, parameters?: object): Promise\<void>;
...@@ -818,8 +818,8 @@ Performs an action based on the specified action name. This API uses a promise t ...@@ -818,8 +818,8 @@ Performs an action based on the specified action name. This API uses a promise t
| Name | Type | Mandatory | Description | | Name | Type | Mandatory | Description |
| ----------- | ---------------------------------------- | ---- | -------------- | | ----------- | ---------------------------------------- | ---- | -------------- |
| actionName | string | Yes | Action name. For details, see [Action](./js-apis-accessibility.md#action). | | actionName | string | Yes | Action name. For details, see [Action](./js-apis-accessibility.md#action).
| parameters | object | No | Parameters required for performing the target action. Not supported currently. | | parameters | object | No | Parameters required for performing the target action. Empty by default. Not supported currently. |
**Return value** **Return value**
...@@ -849,7 +849,7 @@ try { ...@@ -849,7 +849,7 @@ try {
console.error('failed to perform action, because ${JSON.stringify(exception)}'); console.error('failed to perform action, because ${JSON.stringify(exception)}');
} }
``` ```
## performAction ### performAction
performAction(actionName: string, callback: AsyncCallback\<void>): void; performAction(actionName: string, callback: AsyncCallback\<void>): void;
...@@ -861,7 +861,7 @@ Performs an action based on the specified action name. This API uses an asynchro ...@@ -861,7 +861,7 @@ Performs an action based on the specified action name. This API uses an asynchro
| Name | Type | Mandatory | Description | | Name | Type | Mandatory | Description |
| ----------- | ---------------------------------------- | ---- | -------------- | | ----------- | ---------------------------------------- | ---- | -------------- |
| actionName | string | Yes | Action name. For details, see [Action](./js-apis-accessibility.md#action). | | actionName | string | Yes | Action name. For details, see [Action](./js-apis-accessibility.md#action).
| callback | AsyncCallback&lt;void&gt; | Yes | Callback used to return the result.| | callback | AsyncCallback&lt;void&gt; | Yes | Callback used to return the result.|
**Error codes** **Error codes**
...@@ -888,7 +888,7 @@ try { ...@@ -888,7 +888,7 @@ try {
console.error('failed to perform action, because ${JSON.stringify(exception)}'); console.error('failed to perform action, because ${JSON.stringify(exception)}');
} }
``` ```
## performAction ### performAction
performAction(actionName: string, parameters: object, callback: AsyncCallback\<void>): void; performAction(actionName: string, parameters: object, callback: AsyncCallback\<void>): void;
...@@ -901,7 +901,7 @@ Performs an action based on the specified action name. This API uses an asynchro ...@@ -901,7 +901,7 @@ Performs an action based on the specified action name. This API uses an asynchro
| Name | Type | Mandatory | Description | | Name | Type | Mandatory | Description |
| ---------- | ------------------------- | ---- | ---------------------------------------- | | ---------- | ------------------------- | ---- | ---------------------------------------- |
| actionName | string | Yes | Action name. For details, see [Action](./js-apis-accessibility.md#action).| | actionName | string | Yes | Action name. For details, see [Action](./js-apis-accessibility.md#action).|
| parameters | object | Yes | Parameters required for performing the target action. Not supported currently. | | parameters | object | Yes | Parameters required for performing the target action. Empty by default. Not supported currently. |
| callback | AsyncCallback&lt;void&gt; | Yes | Callback used to return the result. | | callback | AsyncCallback&lt;void&gt; | Yes | Callback used to return the result. |
**Error codes** **Error codes**
...@@ -932,7 +932,7 @@ try { ...@@ -932,7 +932,7 @@ try {
console.error('failed to perform action, because ${JSON.stringify(exception)}'); console.error('failed to perform action, because ${JSON.stringify(exception)}');
} }
``` ```
## findElement('content') ### findElement('content')
findElement(type: 'content', condition: string): Promise\<Array\<AccessibilityElement>>; findElement(type: 'content', condition: string): Promise\<Array\<AccessibilityElement>>;
...@@ -971,7 +971,7 @@ try { ...@@ -971,7 +971,7 @@ try {
console.error('failed to find element, because ${JSON.stringify(exception)}'); console.error('failed to find element, because ${JSON.stringify(exception)}');
} }
``` ```
## findElement('content') ### findElement('content')
findElement(type: 'content', condition: string, callback: AsyncCallback\<Array\<AccessibilityElement>>): void; findElement(type: 'content', condition: string, callback: AsyncCallback\<Array\<AccessibilityElement>>): void;
...@@ -1007,7 +1007,7 @@ try { ...@@ -1007,7 +1007,7 @@ try {
console.error('failed to find element, because ${JSON.stringify(exception)}'); console.error('failed to find element, because ${JSON.stringify(exception)}');
} }
``` ```
## findElement('focusType') ### findElement('focusType')
findElement(type: 'focusType', condition: FocusType): Promise\<AccessibilityElement>; findElement(type: 'focusType', condition: FocusType): Promise\<AccessibilityElement>;
...@@ -1046,7 +1046,7 @@ try { ...@@ -1046,7 +1046,7 @@ try {
console.error('failed to find element, because ${JSON.stringify(exception)}'); console.error('failed to find element, because ${JSON.stringify(exception)}');
} }
``` ```
## findElement('focusType') ### findElement('focusType')
findElement(type: 'focusType', condition: FocusType, callback: AsyncCallback\<AccessibilityElement>): void; findElement(type: 'focusType', condition: FocusType, callback: AsyncCallback\<AccessibilityElement>): void;
...@@ -1082,7 +1082,7 @@ try { ...@@ -1082,7 +1082,7 @@ try {
console.error('failed to find element, because ${JSON.stringify(exception)}'); console.error('failed to find element, because ${JSON.stringify(exception)}');
} }
``` ```
## findElement('focusDirection') ### findElement('focusDirection')
findElement(type: 'focusDirection', condition: FocusDirection): Promise\<AccessibilityElement>; findElement(type: 'focusDirection', condition: FocusDirection): Promise\<AccessibilityElement>;
...@@ -1121,7 +1121,7 @@ try { ...@@ -1121,7 +1121,7 @@ try {
console.error('failed to find element, because ${JSON.stringify(exception)}'); console.error('failed to find element, because ${JSON.stringify(exception)}');
} }
``` ```
## findElement('focusDirection') ### findElement('focusDirection')
findElement(type: 'focusDirection', condition: FocusDirection, callback: AsyncCallback\<AccessibilityElement>): void; findElement(type: 'focusDirection', condition: FocusDirection, callback: AsyncCallback\<AccessibilityElement>): void;
......
...@@ -43,5 +43,5 @@ let applicationStateObserver = { ...@@ -43,5 +43,5 @@ let applicationStateObserver = {
console.log('onProcessStateChanged onProcessStateChanged: ${JSON.stringify(processData)}'); console.log('onProcessStateChanged onProcessStateChanged: ${JSON.stringify(processData)}');
} }
}; };
let observerCode = appManager.registerApplicationStateObserver(applicationStateObserver); let observerCode = appManager.on('applicationState', applicationStateObserver);
``` ```
# ringtonePlayer (Ringtone Player)
The **ringtonePlayer** module provides APIs for playing, configuring, and obtaining system ringtones.
This module must work with [@ohos.multimedia.systemSoundManager](js-apis-systemSoundManager.md) to manage system ringtones.
> **NOTE**
>
> The initial APIs of this module are supported since API version 10. Newly added APIs will be marked with a superscript to indicate their earliest API version.
>
> The APIs provided by this module are system APIs.
## Modules to Import
```js
import systemSoundManager from '@ohos.multimedia.systemSoundManager';
```
## RingtoneOptions
Enumerates the ringtone parameters.
**System API**: This is a system API.
**System capability**: SystemCapability.Multimedia.SystemSound.Core
| Name | Type |Mandatory | Description |
| --------- | -------------- | ---- | --------------------------------- |
| volume | number | Yes | Relative volume. The value ranges from 0.00 to 1.00. The value **1.00** indicates the maximum volume (100%).|
| loop | boolean | Yes | Whether to enable loop playback. The value **true** means to enable loop playback, and **false** means the opposite.|
## RingtonePlayer
Provides APIs for setting and obtaining system ringtone parameters as well as playing and stopping system ringtones. Before calling any API in **RingtonePlayer**, you must use [getSystemRingtonePlayer](js-apis-systemSoundManager.md#getsystemringtoneplayer) to create a **RingtonePlayer** instance.
### Attributes
**System API**: This is a system API.
**System capability**: SystemCapability.Multimedia.SystemSound.Core
| Name | Type | Readable| Writable| Description |
| ----- | -------------------------- | ---- | ---- | ------------------ |
| state | [media.AVPlayerState](js-apis-media.md#avplayerstate9) | Yes | No | Audio renderer state.|
**Example**
```js
let state = systemRingtonePlayer.state;
```
### getTitle
getTitle(callback: AsyncCallback&lt;string&gt;): void
Obtains the title of a system ringtone. This API uses an asynchronous callback to return the result.
**System API**: This is a system API.
**System capability**: SystemCapability.Multimedia.SystemSound.Core
**Parameters**
| Name | Type | Mandatory| Description |
| -------- | -----------------------------------------| ---- | ------------------------- |
| callback | AsyncCallback&lt;string&gt; | Yes | Callback used to return the ringtone title obtained. |
**Example**
```js
systemRingtonePlayer.getTitle((err, value) => {
if (err) {
console.error(`Failed to get system ringtone title. ${err}`);
return;
}
console.info(`Callback invoked to indicate the value of the system ringtone title is obtained ${value}.`);
});
```
### getTitle
getTitle(): Promise&lt;string&gt;
Obtains the title of a system ringtone. This API uses a promise to return the result.
**System API**: This is a system API.
**System capability**: SystemCapability.Multimedia.SystemSound.Core
**Return value**
| Type | Description |
| --------------------- | -------------------------------- |
| Promise&lt;string&gt; | Promise used to return the ringtone title obtained.|
**Example**
```js
systemRingtonePlayer.getTitle().then((value) => {
console.info(`Promise returned to indicate that the value of the system ringtone title is obtained ${value}.`);
}).catch ((err) => {
console.error(`Failed to get the system ringtone title ${err}`);
});
```
### getAudioRendererInfo
getAudioRendererInfo(callback: AsyncCallback&lt;audio.AudioRendererInfo&gt;): void
Obtains the information about the audio renderer used by the ringtone. This API uses an asynchronous callback to return the result.
**System API**: This is a system API.
**System capability**: SystemCapability.Multimedia.SystemSound.Core
**Parameters**
| Name | Type | Mandatory| Description |
| -------- | -----------------------------------------| ---- | ------------------------- |
| callback | AsyncCallback&lt;[audio.AudioRendererInfo](js-apis-audio.md#audiorendererinfo8)&gt; | Yes| Callback used to return the audio renderer information obtained.|
**Example**
```js
import audio from '@ohos.multimedia.audio';
let audioRendererInfo: audio.AudioRendererInfo = null;
systemRingtonePlayer.getAudioRendererInfo((err, value) => {
if (err) {
console.error(`Failed to get ringtone AudioRendererInfo. ${err}`);
return;
}
console.info(`Callback invoked to indicate the value of the ringtone AudioRendererInfo is obtained.`);
audioRendererInfo = value;
});
```
### getAudioRendererInfo
getAudioRendererInfo(): Promise&lt;audio.AudioRendererInfo&gt;
Obtains the information about the audio renderer used by the ringtone. This API uses a promise to return the result.
**System API**: This is a system API.
**System capability**: SystemCapability.Multimedia.SystemSound.Core
**Return value**
| Type | Description |
| ------------------- | ------------------------------- |
| Promise&lt;[audio.AudioRendererInfo](js-apis-audio.md#audiorendererinfo8)&gt; | Promise used to return the audio renderer information obtained.|
**Example**
```js
import audio from '@ohos.multimedia.audio';
let audioRendererInfo: audio.AudioRendererInfo = null;
systemRingtonePlayer.getAudioRendererInfo().then((value) => {
console.info(`Promise returned to indicate that the value of the ringtone AudioRendererInfo is obtained ${value}.`);
audioRendererInfo = value;
}).catch ((err) => {
console.error(`Failed to get the ringtone AudioRendererInfo ${err}`);
});
```
### configure
configure(options: RingtoneOptions, callback: AsyncCallback&lt;void&gt;): void
Sets ringtone parameters. This API uses an asynchronous callback to return the result.
**System API**: This is a system API.
**System capability**: SystemCapability.Multimedia.SystemSound.Core
**Parameters**
| Name | Type | Mandatory| Description |
| -------- | -----------------------------------------| ---- | ------------------------- |
| options | [RingtoneOptions](#ringtoneoptions) | Yes | Ringtone parameters. |
| callback | AsyncCallback&lt;void&gt; | Yes | Callback used to return the result.|
**Example**
```js
let ringtoneOptions = {volume: 0.5, loop: true};
systemRingtonePlayer.configure(ringtoneOptions, (err) => {
if (err) {
console.error(`Failed to configure ringtone options. ${err}`);
return;
}
console.info(`Callback invoked to indicate a successful setting of ringtone options.`);
});
```
### configure
configure(options: RingtoneOptions): Promise&lt;void&gt;
Sets ringtone parameters. This API uses a promise to return the result.
**System API**: This is a system API.
**System capability**: SystemCapability.Multimedia.SystemSound.Core
**Parameters**
| Name | Type | Mandatory| Description |
| -------- | -----------------------------------------| ---- | ------------------------- |
| options | [RingtoneOptions](#ringtoneoptions) | Yes | Ringtone parameters. |
**Return value**
| Type | Description |
| ------------------- | ------------------------------- |
| Promise&lt;void&gt; | Promise used to return the result.|
**Example**
```js
let ringtoneOptions = {volume: 0.5, loop: true};
systemRingtonePlayer.configure(ringtoneOptions).then(() => {
console.info(`Promise returned to indicate a successful setting of ringtone options.`);
}).catch ((err) => {
console.error(`Failed to configure ringtone options. ${err}`);
});
```
### start
start(callback: AsyncCallback&lt;void&gt;): void
Starts playing the ringtone. This API uses an asynchronous callback to return the result.
**System API**: This is a system API.
**System capability**: SystemCapability.Multimedia.SystemSound.Core
**Parameters**
| Name | Type | Mandatory| Description |
| -------- | -----------------------------------------| ---- | ------------------------- |
| callback | AsyncCallback&lt;void&gt; | Yes | Callback used to return the result.|
**Example**
```js
systemRingtonePlayer.start((err) => {
if (err) {
console.error(`Failed to start playing ringtone. ${err}`);
return;
}
console.info(`Callback invoked to indicate a successful starting of ringtone.`);
});
```
### start
start(): Promise&lt;void&gt;
Starts playing the ringtone. This API uses a promise to return the result.
**System API**: This is a system API.
**System capability**: SystemCapability.Multimedia.SystemSound.Core
**Return value**
| Type | Description |
| ------------------- | -------------------------------- |
| Promise&lt;void&gt; | Promise used to return the result.|
**Example**
```js
systemRingtonePlayer.start().then(() => {
console.info(`Promise returned to indicate a successful starting of ringtone.`);
}).catch ((err) => {
console.error(`Failed to start playing ringtone. ${err}`);
});
```
### stop
stop(callback: AsyncCallback&lt;void&gt;): void
Stops playing the ringtone. This API uses an asynchronous callback to return the result.
**System API**: This is a system API.
**System capability**: SystemCapability.Multimedia.SystemSound.Core
**Parameters**
| Name | Type | Mandatory| Description |
| -------- | -----------------------------------------| ---- | ------------------------- |
| callback | AsyncCallback&lt;void&gt; | Yes | Callback used to return the result.|
**Example**
```js
systemRingtonePlayer.stop((err) => {
if (err) {
console.error(`Failed to stop playing ringtone. ${err}`);
return;
}
console.info(`Callback invoked to indicate a successful stopping of ringtone.`);
});
```
### stop
stop(): Promise&lt;void&gt;
Stops playing the ringtone. This API uses a promise to return the result.
**System API**: This is a system API.
**System capability**: SystemCapability.Multimedia.SystemSound.Core
**Return value**
| Type | Description |
| ------------------- | -------------------------------- |
| Promise&lt;void&gt; | Promise used to return the result.|
**Example**
```js
systemRingtonePlayer.stop().then(() => {
console.info(`Promise returned to indicate a successful stopping of ringtone.`);
}).catch ((err) => {
console.error(`Failed to stop playing ringtone. ${err}`);
});
```
### release
release(callback: AsyncCallback&lt;void&gt;): void
Releases the ringtone player. This API uses an asynchronous callback to return the result.
**System API**: This is a system API.
**System capability**: SystemCapability.Multimedia.SystemSound.Core
**Parameters**
| Name | Type | Mandatory| Description |
| -------- | -----------------------------------------| ---- | ------------------------- |
| callback | AsyncCallback&lt;void&gt; | Yes | Callback used to return the result. |
**Example**
```js
systemRingtonePlayer.release((err) => {
if (err) {
console.error(`Failed to release ringtone player. ${err}`);
return;
}
console.info(`Callback invoked to indicate a successful releasing of ringtone player.`);
});
```
### release
release(): Promise&lt;void&gt;
Releases the ringtone player. This API uses a promise to return the result.
**System API**: This is a system API.
**System capability**: SystemCapability.Multimedia.SystemSound.Core
**Return value**
| Type | Description |
| ------------------- | ------------------------------- |
| Promise&lt;void&gt; | Promise used to return the result. |
**Example**
```js
systemRingtonePlayer.release().then(() => {
console.info(`Promise returned to indicate a successful releasing of ringtone player.`);
}).catch ((err) => {
console.error(`Failed to release ringtone player. ${err}`);
});
```
### on('audioInterrupt')
on(type: 'audioInterrupt', callback: Callback&lt;audio.InterruptEvent&gt;): void
Subscribes to audio interruption events. This API uses a callback to obtain interrupt events.
**System API**: This is a system API.
**System capability**: SystemCapability.Multimedia.SystemSound.Core
**Parameters**
| Name | Type | Mandatory| Description |
| -------- | ----------------------- | ---- | -------------------------------------------------------------------------- |
| type | string | Yes | Event type. The value **'audioInterrupt'** means the audio interruption event, which is triggered when audio rendering is interrupted.|
| callback | Callback&lt;[audio.InterruptEvent](js-apis-audio.md#interruptevent9)&gt; | Yes | Callback used to return the audio interruption event. |
**Error codes**
For details about the error codes, see [Audio Error Codes](../errorcodes/errorcode-audio.md).
| ID| Error Message|
| ------- | --------------------------------------------|
| 401 | if input parameter type or number mismatch |
| 6800101 | if input parameter value error |
**Example**
```js
import audio from '@ohos.multimedia.audio';
let isPlaying; // An identifier specifying whether rendering is in progress.
let isDucked; // An identifier specifying whether the audio volume is reduced.
systemRingtonePlayer.on('audioInterrupt', async(interruptEvent) => {
if (interruptEvent.forceType == audio.InterruptForceType.INTERRUPT_FORCE) {
// The system forcibly interrupts audio rendering. The application must update the status and displayed content accordingly.
switch (interruptEvent.hintType) {
case audio.InterruptHint.INTERRUPT_HINT_PAUSE:
// The audio stream has been paused and temporarily loses the focus. It will receive the interruptEvent corresponding to resume when it is able to regain the focus.
console.info('Force paused. Update playing status and stop writing');
isPlaying = false; // A simplified processing indicating several operations for switching the application to the paused state.
break;
case audio.InterruptHint.INTERRUPT_HINT_STOP:
// The audio stream has been stopped and permanently loses the focus. The user must manually trigger the operation to resume rendering.
console.info('Force stopped. Update playing status and stop writing');
isPlaying = false; // A simplified processing indicating several operations for switching the application to the paused state.
break;
case audio.InterruptHint.INTERRUPT_HINT_DUCK:
// The audio stream is rendered at a reduced volume.
console.info('Force ducked. Update volume status');
isDucked = true; // A simplified processing indicating several operations for updating the volume status.
break;
case audio.InterruptHint.INTERRUPT_HINT_UNDUCK:
// The audio stream is rendered at the normal volume.
console.info('Force ducked. Update volume status');
isDucked = false; // A simplified processing indicating several operations for updating the volume status.
break;
default:
break;
}
} else if (interruptEvent.forceType == audio.InterruptForceType.INTERRUPT_SHARE) {
// The application can choose to take action or ignore.
switch (interruptEvent.hintType) {
case audio.InterruptHint.INTERRUPT_HINT_RESUME:
// It is recommended that the application continue rendering. (The audio stream has been forcibly paused and temporarily lost the focus. It can resume rendering now.)
console.info('Resume force paused renderer or ignore');
// To continue rendering, the application must perform the required operations.
break;
default:
break;
}
}
});
```
...@@ -57,7 +57,9 @@ Provides the constant values of function keys, edit boxes, and the cursor. ...@@ -57,7 +57,9 @@ Provides the constant values of function keys, edit boxes, and the cursor.
getInputMethodAbility(): InputMethodAbility getInputMethodAbility(): InputMethodAbility
Obtains an [InputMethodAbility](#inputmethodability) instance for the input method. Obtains an [InputMethodAbility](#inputmethodability) instance for the input method.
This API can be called only by an input method. This API can be called only by an input method.
The input method can use the obtained instance to subscribe to a soft keyboard display/hide request event, create/destroy an input method panel, and the like. The input method can use the obtained instance to subscribe to a soft keyboard display/hide request event, create/destroy an input method panel, and the like.
**System capability**: SystemCapability.MiscServices.InputMethodFramework **System capability**: SystemCapability.MiscServices.InputMethodFramework
...@@ -494,7 +496,7 @@ This API can be called only by an input method. Only one SOFT_KEYBOARD panel and ...@@ -494,7 +496,7 @@ This API can be called only by an input method. Only one SOFT_KEYBOARD panel and
| Name | Type | Mandatory| Description | | Name | Type | Mandatory| Description |
| ------- | ----------- | ---- | ------------------------ | | ------- | ----------- | ---- | ------------------------ |
| ctx | [BaseContext](https://gitee.com/openharmony/docs/blob/master/zh-cn/application-dev/reference/apis/js-apis-inner-application-baseContext.md) | Yes | Context of the current input method.| | ctx | [BaseContext](js-apis-inner-application-baseContext.md) | Yes | Context of the current input method.|
| info | [PanelInfo](#panelinfo10) | Yes | Information about the input method panel.| | info | [PanelInfo](#panelinfo10) | Yes | Information about the input method panel.|
| callback | AsyncCallback\<[Panel](#panel10)> | Yes | Callback used to return the result. If the operation is successful, the created input method panel is returned. | | callback | AsyncCallback\<[Panel](#panel10)> | Yes | Callback used to return the result. If the operation is successful, the created input method panel is returned. |
...@@ -538,7 +540,7 @@ This API can be called only by an input method. Only one SOFT_KEYBOARD panel and ...@@ -538,7 +540,7 @@ This API can be called only by an input method. Only one SOFT_KEYBOARD panel and
| Name | Type | Mandatory| Description | | Name | Type | Mandatory| Description |
| ------- | ----------- | ---- | ------------------------ | | ------- | ----------- | ---- | ------------------------ |
| ctx | [BaseContext](https://gitee.com/openharmony/docs/blob/master/zh-cn/application-dev/reference/apis/js-apis-inner-application-baseContext.md) | Yes | Context of the current input method.| | ctx | [BaseContext](js-apis-inner-application-baseContext.md) | Yes | Context of the current input method.|
| info | [PanelInfo](#panelinfo10) | Yes | Information about the input method panel.| | info | [PanelInfo](#panelinfo10) | Yes | Information about the input method panel.|
**Return value** **Return value**
...@@ -953,7 +955,7 @@ Loads content from a page linked to LocalStorage to this panel. This API uses an ...@@ -953,7 +955,7 @@ Loads content from a page linked to LocalStorage to this panel. This API uses an
| Name | Type | Mandatory| Description | | Name | Type | Mandatory| Description |
| -------- | ---------------------- | ---- | -------- | | -------- | ---------------------- | ---- | -------- |
| path | string | Yes | Path of the page from which the content will be loaded.| | path | string | Yes | Path of the page from which the content will be loaded.|
| storage | [LocalStorage](../../quick-start/arkts-localstorage.md) | Yes | Storage unit that provides storage for mutable and immutable state variables in the application.| | storage | [LocalStorage](../arkui-ts/ts-state-management.md#localstorage9) | Yes | Storage unit that provides storage for mutable and immutable state variables in the application.|
| callback | AsyncCallback\<void> | Yes | Callback used to return the result. If the operation is successful, **err** is **undefined**. Otherwise, **err** is an error object.| | callback | AsyncCallback\<void> | Yes | Callback used to return the result. If the operation is successful, **err** is **undefined**. Otherwise, **err** is an error object.|
**Example** **Example**
...@@ -987,7 +989,7 @@ Loads content from a page linked to LocalStorage to this panel. This API uses a ...@@ -987,7 +989,7 @@ Loads content from a page linked to LocalStorage to this panel. This API uses a
| Name | Type | Mandatory| Description | | Name | Type | Mandatory| Description |
| -------- | ---------------------- | ---- | -------- | | -------- | ---------------------- | ---- | -------- |
| path | string | Yes | Path of the page from which the content will be loaded.| | path | string | Yes | Path of the page from which the content will be loaded.|
| storage | [LocalStorage](../../quick-start/arkts-localstorage.md) | Yes | Storage unit that provides storage for mutable and immutable state variables in the application.| | storage | [LocalStorage](../arkui-ts/ts-state-management.md#localstorage9) | Yes | Storage unit that provides storage for mutable and immutable state variables in the application.|
**Return value** **Return value**
...@@ -1067,7 +1069,7 @@ The panel width cannot exceed the screen width, and the panel height cannot be h ...@@ -1067,7 +1069,7 @@ The panel width cannot exceed the screen width, and the panel height cannot be h
| Type | Description | | Type | Description |
| ------- | ------------------------------ | | ------- | ------------------------------ |
| Promise<void> | Promise that returns no value. | | Promise\<void> | Promise that returns no value. |
**Example** **Example**
...@@ -1139,7 +1141,7 @@ This API does not work on panels in the FLG_FIXED state. ...@@ -1139,7 +1141,7 @@ This API does not work on panels in the FLG_FIXED state.
| Type | Description | | Type | Description |
| ------- | ------------------------------ | | ------- | ------------------------------ |
| Promise<void> | Promise that returns no value. | | Promise\<void> | Promise that returns no value. |
**Example** **Example**
...@@ -1558,7 +1560,7 @@ Sends the function key. This API uses a promise to return the result. ...@@ -1558,7 +1560,7 @@ Sends the function key. This API uses a promise to return the result.
| Name| Type| Mandatory| Description| | Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
| action | number | Yes| Action of the function key.<br>**0**: invalid key.<br>**1**: confirm key (Enter key).| | action | number | Yes| Action of the function key.<br>- **0**: invalid key.<br>- **1**: confirm key (Enter key).|
**Return value** **Return value**
...@@ -2521,8 +2523,8 @@ Describes the attribute of a key. ...@@ -2521,8 +2523,8 @@ Describes the attribute of a key.
| Name | Type| Readable| Writable| Description | | Name | Type| Readable| Writable| Description |
| --------- | -------- | ---- | ---- | ------------ | | --------- | -------- | ---- | ---- | ------------ |
| keyCode | number | Yes | No | Key value.| | keyCode | number | Yes | No | Key value. For detail, see [KeyCode](js-apis-keycode.md#keycode).|
| keyAction | number | Yes | No | Key status.| | keyAction | number | Yes | No | Key event type.<br>- **2**: keydown event.<br>- **3**: keyup event.|
## PanelFlag<sup>10+</sup> ## PanelFlag<sup>10+</sup>
......
...@@ -77,7 +77,6 @@ let media = mediaLibrary.getMediaLibrary(); ...@@ -77,7 +77,6 @@ let media = mediaLibrary.getMediaLibrary();
### getFileAssets<sup>7+</sup> ### getFileAssets<sup>7+</sup>
getFileAssets(options: MediaFetchOptions, callback: AsyncCallback&lt;FetchFileResult&gt;): void getFileAssets(options: MediaFetchOptions, callback: AsyncCallback&lt;FetchFileResult&gt;): void
Obtains file assets (also called files). This API uses an asynchronous callback to return the result. Obtains file assets (also called files). This API uses an asynchronous callback to return the result.
...@@ -105,7 +104,7 @@ async function example() { ...@@ -105,7 +104,7 @@ async function example() {
selectionArgs: [imageType.toString()], selectionArgs: [imageType.toString()],
}; };
// Obtain the files in asynchronous callback mode. // Obtain the files in asynchronous callback mode.
media.getFileAssets(imagesFetchOp, (error, fetchFileResult) => { media.getFileAssets(imagesFetchOp, async (error, fetchFileResult) => {
// Check whether the result set of the obtained files is undefined. If yes, the API call fails. // Check whether the result set of the obtained files is undefined. If yes, the API call fails.
if (fetchFileResult == undefined) { if (fetchFileResult == undefined) {
console.error('get fetchFileResult failed with error: ' + error); console.error('get fetchFileResult failed with error: ' + error);
...@@ -124,8 +123,8 @@ async function example() { ...@@ -124,8 +123,8 @@ async function example() {
return; return;
} }
console.info('Get fetchFileResult successfully, count: ' + count); console.info('Get fetchFileResult successfully, count: ' + count);
// Obtain the first file in the result set in asynchronous callback mode. // Obtain the first file in the result set in asynchronous callback mode. If there are a large number of files, use getAllObject instead.
fetchFileResult.getFirstObject((error, fileAsset) => { fetchFileResult.getFirstObject(async (error, fileAsset) => {
// Check whether the first file is undefined. If yes, the API call fails. // Check whether the first file is undefined. If yes, the API call fails.
if (fileAsset == undefined) { if (fileAsset == undefined) {
console.error('get first object failed with error: ' + error); console.error('get first object failed with error: ' + error);
...@@ -178,7 +177,7 @@ async function example() { ...@@ -178,7 +177,7 @@ async function example() {
selectionArgs: [imageType.toString()], selectionArgs: [imageType.toString()],
}; };
// Obtain the files in promise mode. // Obtain the files in promise mode.
media.getFileAssets(imagesFetchOp).then((fetchFileResult) => { media.getFileAssets(imagesFetchOp).then(async (fetchFileResult) => {
// Obtain the total number of files in the result set. // Obtain the total number of files in the result set.
const count = fetchFileResult.getCount(); const count = fetchFileResult.getCount();
// Check whether the number is less than 0. If yes, the API call fails. // Check whether the number is less than 0. If yes, the API call fails.
...@@ -192,8 +191,8 @@ async function example() { ...@@ -192,8 +191,8 @@ async function example() {
return; return;
} }
console.info('Get fetchFileResult successfully, count: ' + count); console.info('Get fetchFileResult successfully, count: ' + count);
// Obtain the first file in the result set in promise mode. // Obtain the first file in the result set in promise mode. If there are a large number of files, use getAllObject instead.
fetchFileResult.getFirstObject().then((fileAsset) => { fetchFileResult.getFirstObject().then(async (fileAsset) => {
console.info('fileAsset.displayName ' + '0 : ' + fileAsset.displayName); console.info('fileAsset.displayName ' + '0 : ' + fileAsset.displayName);
// Call getNextObject to obtain the next file until the last one. // Call getNextObject to obtain the next file until the last one.
for (let i = 1; i < count; i++) { for (let i = 1; i < count; i++) {
...@@ -514,17 +513,18 @@ Obtains the albums. This API uses an asynchronous callback to return the result. ...@@ -514,17 +513,18 @@ Obtains the albums. This API uses an asynchronous callback to return the result.
```js ```js
async function example() { async function example() {
let AlbumNoArgsfetchOp = { // To obtain the file assets in an album, you must preset the album and resources. The sample code below presets 'New Album 1'.
selections: '', let AlbumNoArgsfetchOp = {
selectionArgs: [], selections: mediaLibrary.FileKey.ALBUM_NAME + '= ?',
}; selectionArgs:['New Album 1'],
media.getAlbums(AlbumNoArgsfetchOp, (error, albumList) => { };
if (albumList != undefined) { media.getAlbums(AlbumNoArgsfetchOp, (error, albumList) => {
console.info('getAlbums successfully: ' + JSON.stringify(albumList)); if (albumList != undefined) {
} else { console.info('getAlbums successfully: ' + JSON.stringify(albumList));
console.error('getAlbums failed with error: ' + error); } else {
} console.error('getAlbums failed with error: ' + error);
}) }
})
} }
``` ```
...@@ -554,15 +554,16 @@ Obtains the albums. This API uses a promise to return the result. ...@@ -554,15 +554,16 @@ Obtains the albums. This API uses a promise to return the result.
```js ```js
async function example() { async function example() {
let AlbumNoArgsfetchOp = { // To obtain the file assets in an album, you must preset the album and resources. The sample code below presets 'New Album 1'.
selections: '', let AlbumNoArgsfetchOp = {
selectionArgs: [], selections: mediaLibrary.FileKey.ALBUM_NAME + '= ?',
}; selectionArgs:['New Album 1'],
media.getAlbums(AlbumNoArgsfetchOp).then((albumList) => { };
console.info('getAlbums successfully: ' + JSON.stringify(albumList)); media.getAlbums(AlbumNoArgsfetchOp).then((albumList) => {
}).catch((error) => { console.info('getAlbums successfully: ' + JSON.stringify(albumList));
console.error('getAlbums failed with error: ' + error); }).catch((error) => {
}); console.error('getAlbums failed with error: ' + error);
});
} }
``` ```
...@@ -2021,7 +2022,7 @@ async function example() { ...@@ -2021,7 +2022,7 @@ async function example() {
### getNextObject<sup>7+</sup> ### getNextObject<sup>7+</sup>
getNextObject(callback: AsyncCallback&lt;FileAsset&gt;): void getNextObject(callback: AsyncCallback&lt;FileAsset&gt;): void
Obtains the next file asset in the result set. This API uses an asynchronous callback to return the result. Obtains the next file asset in the result set. This API uses an asynchronous callback to return the result.
> **NOTE** > **NOTE**
...@@ -2049,7 +2050,8 @@ async function example() { ...@@ -2049,7 +2050,8 @@ async function example() {
}; };
let fetchFileResult = await media.getFileAssets(getImageOp); let fetchFileResult = await media.getFileAssets(getImageOp);
let fileAsset = await fetchFileResult.getFirstObject(); let fileAsset = await fetchFileResult.getFirstObject();
if (!fileAsset.isAfterLast) { console.log('fetchFileResult getFirstObject successfully, displayName: ' + fileAsset.displayName);
if (!fetchFileResult.isAfterLast()) {
fetchFileResult.getNextObject((error, fileAsset) => { fetchFileResult.getNextObject((error, fileAsset) => {
if (error) { if (error) {
console.error('fetchFileResult getNextObject failed with error: ' + error); console.error('fetchFileResult getNextObject failed with error: ' + error);
...@@ -2065,7 +2067,7 @@ async function example() { ...@@ -2065,7 +2067,7 @@ async function example() {
### getNextObject<sup>7+</sup> ### getNextObject<sup>7+</sup>
getNextObject(): Promise&lt;FileAsset&gt; getNextObject(): Promise&lt;FileAsset&gt;
Obtains the next file asset in the result set. This API uses a promise to return the result. Obtains the next file asset in the result set. This API uses a promise to return the result.
> **NOTE** > **NOTE**
...@@ -2093,7 +2095,8 @@ async function example() { ...@@ -2093,7 +2095,8 @@ async function example() {
}; };
let fetchFileResult = await media.getFileAssets(getImageOp); let fetchFileResult = await media.getFileAssets(getImageOp);
let fileAsset = await fetchFileResult.getFirstObject(); let fileAsset = await fetchFileResult.getFirstObject();
if (!fileAsset.isAfterLast) { console.log('fetchFileResult getFirstObject successfully, displayName: ' + fileAsset.displayName);
if (!fetchFileResult.isAfterLast()) {
fetchFileResult.getNextObject().then((fileAsset) => { fetchFileResult.getNextObject().then((fileAsset) => {
console.info('fetchFileResult getNextObject successfully, displayName: ' + fileAsset.displayName); console.info('fetchFileResult getNextObject successfully, displayName: ' + fileAsset.displayName);
fetchFileResult.close(); fetchFileResult.close();
...@@ -2369,20 +2372,21 @@ Commits the modification in the album attributes to the database. This API uses ...@@ -2369,20 +2372,21 @@ Commits the modification in the album attributes to the database. This API uses
```js ```js
async function example() { async function example() {
let AlbumNoArgsfetchOp = { // To obtain the file assets in an album, you must preset the album and resources. The sample code below presets 'New Album 1'.
selections: '', let AlbumNoArgsfetchOp = {
selectionArgs: [], selections: mediaLibrary.FileKey.ALBUM_NAME + '= ?',
}; selectionArgs:['New Album 1'],
const albumList = await media.getAlbums(AlbumNoArgsfetchOp); };
const album = albumList[0]; const albumList = await media.getAlbums(AlbumNoArgsfetchOp);
album.albumName = 'hello'; const album = albumList[0];
album.commitModify((error) => { album.albumName = 'hello';
if (error) { album.commitModify((error) => {
console.error('commitModify failed with error: ' + error); if (error) {
return; console.error('commitModify failed with error: ' + error);
} return;
console.info('commitModify successful.'); }
}) console.info('commitModify successful.');
})
} }
``` ```
...@@ -2406,18 +2410,60 @@ Commits the modification in the album attributes to the database. This API uses ...@@ -2406,18 +2410,60 @@ Commits the modification in the album attributes to the database. This API uses
```js ```js
async function example() { async function example() {
let AlbumNoArgsfetchOp = { // To obtain the file assets in an album, you must preset the album and resources. The sample code below presets 'New Album 1'.
selections: '', let AlbumNoArgsfetchOp = {
selectionArgs: [], selections: mediaLibrary.FileKey.ALBUM_NAME + '= ?',
}; selectionArgs:['New Album 1'],
const albumList = await media.getAlbums(AlbumNoArgsfetchOp); };
const album = albumList[0]; const albumList = await media.getAlbums(AlbumNoArgsfetchOp);
album.albumName = 'hello'; const album = albumList[0];
album.commitModify().then(() => { album.albumName = 'hello';
console.info('commitModify successfully'); album.commitModify().then(() => {
}).catch((error) => { console.info('commitModify successfully');
console.error('commitModify failed with error: ' + error); }).catch((error) => {
}); console.error('commitModify failed with error: ' + error);
});
}
```
### getFileAssets<sup>7+</sup>
getFileAssets(callback: AsyncCallback&lt;FetchFileResult&gt;): void
Obtains the file assets in this album. This API uses an asynchronous callback to return the result.
**Required permissions**: ohos.permission.READ_MEDIA
**System capability**: SystemCapability.Multimedia.MediaLibrary.Core
**Parameters**
| Name | Type | Mandatory| Description |
| -------- | --------------------------------------------------- | ---- | ----------------------------------- |
| callback | AsyncCallback<[FetchFileResult](#fetchfileresult7)> | Yes | Callback used to return the file assets.|
**Example**
```js
async function example() {
// To obtain the file assets in an album, you must preset the album and resources. The sample code below presets 'New Album 1'.
let AlbumNoArgsfetchOp = {
selections: mediaLibrary.FileKey.ALBUM_NAME + '= ?',
selectionArgs:['New Album 1'],
};
// Obtain the albums that meet the retrieval options and return the album list.
const albumList = await media.getAlbums(AlbumNoArgsfetchOp);
const album = albumList[0];
// Obtain an album from the album list and obtain all media assets that meet the retrieval options in the album.
album.getFileAssets((error, fetchFileResult) => {
if (error) {
console.error('album getFileAssets failed with error: ' + error);
return;
}
let count = fetchFileResult.getCount();
console.info('album getFileAssets successfully, count: ' + count);
fetchFileResult.close();
});
} }
``` ```
...@@ -2442,27 +2488,28 @@ Obtains the file assets in this album. This API uses an asynchronous callback to ...@@ -2442,27 +2488,28 @@ Obtains the file assets in this album. This API uses an asynchronous callback to
```js ```js
async function example() { async function example() {
let AlbumNoArgsfetchOp = { // To obtain the file assets in an album, you must preset the album and resources. The sample code below presets 'New Album 1'.
selections: '', let AlbumNoArgsfetchOp = {
selectionArgs: [], selections: mediaLibrary.FileKey.ALBUM_NAME + '= ?',
}; selectionArgs:['New Album 1'],
let fileNoArgsfetchOp = { };
selections: '', let fileNoArgsfetchOp = {
selectionArgs: [], selections: '',
selectionArgs: [],
}
// Obtain the albums that meet the retrieval options and return the album list.
const albumList = await media.getAlbums(AlbumNoArgsfetchOp);
const album = albumList[0];
// Obtain an album from the album list and obtain all media assets that meet the retrieval options in the album.
album.getFileAssets(fileNoArgsfetchOp, (error, fetchFileResult) => {
if (error) {
console.error('album getFileAssets failed with error: ' + error);
return;
} }
// Obtain the albums that meet the retrieval options and return the album list. let count = fetchFileResult.getCount();
const albumList = await media.getAlbums(AlbumNoArgsfetchOp); console.info('album getFileAssets successfully, count: ' + count);
const album = albumList[0]; fetchFileResult.close();
// Obtain an album from the album list and obtain all media assets that meet the retrieval options in the album. });
album.getFileAssets(fileNoArgsfetchOp, (error, fetchFileResult) => {
if (error) {
console.error('album getFileAssets failed with error: ' + error);
return;
}
let count = fetchFileResult.getCount();
console.info('album getFileAssets successfully, count: ' + count);
fetchFileResult.close();
});
} }
``` ```
...@@ -2492,25 +2539,26 @@ Obtains the file assets in this album. This API uses a promise to return the res ...@@ -2492,25 +2539,26 @@ Obtains the file assets in this album. This API uses a promise to return the res
```js ```js
async function example() { async function example() {
let AlbumNoArgsfetchOp = { // To obtain the file assets in an album, you must preset the album and resources. The sample code below presets 'New Album 1'.
selections: '', let AlbumNoArgsfetchOp = {
selectionArgs: [], selections: mediaLibrary.FileKey.ALBUM_NAME + '= ?',
}; selectionArgs:['New Album 1'],
let fileNoArgsfetchOp = { };
selections: '', let fileNoArgsfetchOp = {
selectionArgs: [], selections: '',
}; selectionArgs: [],
// Obtain the albums that meet the retrieval options and return the album list. };
const albumList = await media.getAlbums(AlbumNoArgsfetchOp); // Obtain the albums that meet the retrieval options and return the album list.
const album = albumList[0]; const albumList = await media.getAlbums(AlbumNoArgsfetchOp);
// Obtain an album from the album list and obtain all media assets that meet the retrieval options in the album. const album = albumList[0];
album.getFileAssets(fileNoArgsfetchOp).then((fetchFileResult) => { // Obtain an album from the album list and obtain all media assets that meet the retrieval options in the album.
let count = fetchFileResult.getCount(); album.getFileAssets(fileNoArgsfetchOp).then((fetchFileResult) => {
console.info('album getFileAssets successfully, count: ' + count); let count = fetchFileResult.getCount();
fetchFileResult.close(); console.info('album getFileAssets successfully, count: ' + count);
}).catch((error) => { fetchFileResult.close();
console.error('album getFileAssets failed with error: ' + error); }).catch((error) => {
}); console.error('album getFileAssets failed with error: ' + error);
});
} }
``` ```
......
...@@ -20,9 +20,7 @@ import reminderAgent from'@ohos.reminderAgent'; ...@@ -20,9 +20,7 @@ import reminderAgent from'@ohos.reminderAgent';
## reminderAgent.publishReminder<sup>(deprecated)</sup> ## reminderAgent.publishReminder<sup>(deprecated)</sup>
```ts
publishReminder(reminderReq: ReminderRequest, callback: AsyncCallback\<number>): void publishReminder(reminderReq: ReminderRequest, callback: AsyncCallback\<number>): void
```
Publishes a reminder through the reminder agent. This API uses an asynchronous callback to return the result. It can be called only when notification is enabled for the application through [Notification.requestEnableNotification](js-apis-notification.md#notificationrequestenablenotification8). Publishes a reminder through the reminder agent. This API uses an asynchronous callback to return the result. It can be called only when notification is enabled for the application through [Notification.requestEnableNotification](js-apis-notification.md#notificationrequestenablenotification8).
...@@ -39,7 +37,7 @@ Publishes a reminder through the reminder agent. This API uses an asynchronous c ...@@ -39,7 +37,7 @@ Publishes a reminder through the reminder agent. This API uses an asynchronous c
| Name| Type| Mandatory| Description| | Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
| reminderReq | [ReminderRequest](#reminderrequest) | Yes| Reminder to be published.| | reminderReq | [ReminderRequest](#reminderrequest) | Yes| Reminder to be published.|
| callback | AsyncCallback\<number\> | Yes| Callback used to return the published reminder's ID.| | callback | AsyncCallback\<number> | Yes| Callback used to return the published reminder's ID.|
**Example** **Example**
```ts ```ts
...@@ -56,9 +54,7 @@ Publishes a reminder through the reminder agent. This API uses an asynchronous c ...@@ -56,9 +54,7 @@ Publishes a reminder through the reminder agent. This API uses an asynchronous c
## reminderAgent.publishReminder<sup>(deprecated)</sup> ## reminderAgent.publishReminder<sup>(deprecated)</sup>
```ts
publishReminder(reminderReq: ReminderRequest): Promise\<number> publishReminder(reminderReq: ReminderRequest): Promise\<number>
```
Publishes a reminder through the reminder agent. This API uses a promise to return the result. It can be called only when notification is enabled for the application through [Notification.requestEnableNotification](js-apis-notification.md#notificationrequestenablenotification8). Publishes a reminder through the reminder agent. This API uses a promise to return the result. It can be called only when notification is enabled for the application through [Notification.requestEnableNotification](js-apis-notification.md#notificationrequestenablenotification8).
...@@ -78,7 +74,7 @@ Publishes a reminder through the reminder agent. This API uses a promise to retu ...@@ -78,7 +74,7 @@ Publishes a reminder through the reminder agent. This API uses a promise to retu
**Return value** **Return value**
| Type| Description| | Type| Description|
| -------- | -------- | | -------- | -------- |
| Promise\<number\> | Promise used to return the published reminder's ID.| | Promise\<number> | Promise used to return the published reminder's ID.|
**Example** **Example**
```ts ```ts
...@@ -95,9 +91,7 @@ Publishes a reminder through the reminder agent. This API uses a promise to retu ...@@ -95,9 +91,7 @@ Publishes a reminder through the reminder agent. This API uses a promise to retu
## reminderAgent.cancelReminder<sup>(deprecated)</sup> ## reminderAgent.cancelReminder<sup>(deprecated)</sup>
```ts
cancelReminder(reminderId: number, callback: AsyncCallback\<void>): void cancelReminder(reminderId: number, callback: AsyncCallback\<void>): void
```
Cancels the reminder with the specified ID. This API uses an asynchronous callback to return the cancellation result. Cancels the reminder with the specified ID. This API uses an asynchronous callback to return the cancellation result.
...@@ -112,7 +106,7 @@ Cancels the reminder with the specified ID. This API uses an asynchronous callba ...@@ -112,7 +106,7 @@ Cancels the reminder with the specified ID. This API uses an asynchronous callba
| Name| Type| Mandatory| Description| | Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
| reminderId | number | Yes| ID of the reminder to cancel. The value is obtained by calling [publishReminder](#reminderagentpublishreminder).| | reminderId | number | Yes| ID of the reminder to cancel. The value is obtained by calling [publishReminder](#reminderagentpublishreminder).|
| callback | AsyncCallback\<void\> | Yes| Callback used to return the result.| | callback | AsyncCallback\<void> | Yes| Callback used to return the result.|
**Example** **Example**
...@@ -125,9 +119,7 @@ reminderAgent.cancelReminder(1, (err, data) => { ...@@ -125,9 +119,7 @@ reminderAgent.cancelReminder(1, (err, data) => {
## reminderAgent.cancelReminder<sup>(deprecated)</sup> ## reminderAgent.cancelReminder<sup>(deprecated)</sup>
```ts
cancelReminder(reminderId: number): Promise\<void> cancelReminder(reminderId: number): Promise\<void>
```
Cancels the reminder with the specified ID. This API uses a promise to return the cancellation result. Cancels the reminder with the specified ID. This API uses a promise to return the cancellation result.
...@@ -147,7 +139,7 @@ Cancels the reminder with the specified ID. This API uses a promise to return th ...@@ -147,7 +139,7 @@ Cancels the reminder with the specified ID. This API uses a promise to return th
| Type| Description| | Type| Description|
| -------- | -------- | | -------- | -------- |
| Promise\<void\> | Promise used to return the result.| | Promise\<void> | Promise used to return the result.|
**Example** **Example**
...@@ -159,9 +151,7 @@ reminderAgent.cancelReminder(1).then(() => { ...@@ -159,9 +151,7 @@ reminderAgent.cancelReminder(1).then(() => {
## reminderAgent.getValidReminders<sup>(deprecated)</sup> ## reminderAgent.getValidReminders<sup>(deprecated)</sup>
```ts
getValidReminders(callback: AsyncCallback\<Array\<ReminderRequest>>): void getValidReminders(callback: AsyncCallback\<Array\<ReminderRequest>>): void
```
Obtains all valid (not yet expired) reminders set by the current application. This API uses an asynchronous callback to return the reminders. Obtains all valid (not yet expired) reminders set by the current application. This API uses an asynchronous callback to return the reminders.
...@@ -175,7 +165,7 @@ Obtains all valid (not yet expired) reminders set by the current application. Th ...@@ -175,7 +165,7 @@ Obtains all valid (not yet expired) reminders set by the current application. Th
| Name| Type| Mandatory| Description| | Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
| callback | AsyncCallback\<Array\<[ReminderRequest](#reminderrequest)\>\> | Yes| Callback used to return an array of all valid reminders set by the current application.| | callback | AsyncCallback\<Array\<[ReminderRequest](#reminderrequest)>> | Yes| Callback used to return an array of all valid reminders set by the current application.|
**Example** **Example**
...@@ -209,9 +199,7 @@ reminderAgent.getValidReminders((err, reminders) => { ...@@ -209,9 +199,7 @@ reminderAgent.getValidReminders((err, reminders) => {
## reminderAgent.getValidReminders<sup>(deprecated)</sup> ## reminderAgent.getValidReminders<sup>(deprecated)</sup>
```ts
getValidReminders(): Promise\<Array\<ReminderRequest>> getValidReminders(): Promise\<Array\<ReminderRequest>>
```
Obtains all valid (not yet expired) reminders set by the current application. This API uses a promise to return the reminders. Obtains all valid (not yet expired) reminders set by the current application. This API uses a promise to return the reminders.
...@@ -225,7 +213,7 @@ Obtains all valid (not yet expired) reminders set by the current application. Th ...@@ -225,7 +213,7 @@ Obtains all valid (not yet expired) reminders set by the current application. Th
| Type| Description| | Type| Description|
| -------- | -------- | | -------- | -------- |
| Promise\<Array\<[ReminderRequest](#reminderrequest)\>\> | Promise used to return an array of all valid reminders set by the current application.| | Promise\<Array\<[ReminderRequest](#reminderrequest)>> | Promise used to return an array of all valid reminders set by the current application.|
**Example** **Example**
...@@ -259,9 +247,7 @@ reminderAgent.getValidReminders().then((reminders) => { ...@@ -259,9 +247,7 @@ reminderAgent.getValidReminders().then((reminders) => {
## reminderAgent.cancelAllReminders<sup>(deprecated)</sup> ## reminderAgent.cancelAllReminders<sup>(deprecated)</sup>
```ts
cancelAllReminders(callback: AsyncCallback\<void>): void cancelAllReminders(callback: AsyncCallback\<void>): void
```
Cancels all reminders set by the current application. This API uses an asynchronous callback to return the cancellation result. Cancels all reminders set by the current application. This API uses an asynchronous callback to return the cancellation result.
...@@ -275,7 +261,7 @@ Cancels all reminders set by the current application. This API uses an asynchron ...@@ -275,7 +261,7 @@ Cancels all reminders set by the current application. This API uses an asynchron
| Name| Type| Mandatory| Description| | Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
| callback | AsyncCallback\<void\> | Yes| Callback used to return the result.| | callback | AsyncCallback\<void> | Yes| Callback used to return the result.|
**Example** **Example**
...@@ -288,9 +274,7 @@ reminderAgent.cancelAllReminders((err, data) =>{ ...@@ -288,9 +274,7 @@ reminderAgent.cancelAllReminders((err, data) =>{
## reminderAgent.cancelAllReminders<sup>(deprecated)</sup> ## reminderAgent.cancelAllReminders<sup>(deprecated)</sup>
```ts
cancelAllReminders(): Promise\<void> cancelAllReminders(): Promise\<void>
```
Cancels all reminders set by the current application. This API uses a promise to return the cancellation result. Cancels all reminders set by the current application. This API uses a promise to return the cancellation result.
...@@ -304,7 +288,7 @@ Cancels all reminders set by the current application. This API uses a promise to ...@@ -304,7 +288,7 @@ Cancels all reminders set by the current application. This API uses a promise to
| Type| Description| | Type| Description|
| -------- | -------- | | -------- | -------- |
| Promise\<void\> | Promise used to return the result.| | Promise\<void> | Promise used to return the result.|
**Example** **Example**
...@@ -316,9 +300,7 @@ reminderAgent.cancelAllReminders().then(() => { ...@@ -316,9 +300,7 @@ reminderAgent.cancelAllReminders().then(() => {
## reminderAgent.addNotificationSlot<sup>(deprecated)</sup> ## reminderAgent.addNotificationSlot<sup>(deprecated)</sup>
```ts
addNotificationSlot(slot: NotificationSlot, callback: AsyncCallback\<void>): void addNotificationSlot(slot: NotificationSlot, callback: AsyncCallback\<void>): void
```
Adds a notification slot. This API uses an asynchronous callback to return the result. Adds a notification slot. This API uses an asynchronous callback to return the result.
...@@ -333,7 +315,7 @@ Adds a notification slot. This API uses an asynchronous callback to return the r ...@@ -333,7 +315,7 @@ Adds a notification slot. This API uses an asynchronous callback to return the r
| Name| Type| Mandatory| Description| | Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
| slot | [NotificationSlot](js-apis-notification.md#notificationslot) | Yes| Notification slot, whose type can be set.| | slot | [NotificationSlot](js-apis-notification.md#notificationslot) | Yes| Notification slot, whose type can be set.|
| callback | AsyncCallback\<void\> | Yes| Callback used to return the result.| | callback | AsyncCallback\<void> | Yes| Callback used to return the result.|
**Example** **Example**
...@@ -351,9 +333,7 @@ reminderAgent.addNotificationSlot(mySlot, (err, data) => { ...@@ -351,9 +333,7 @@ reminderAgent.addNotificationSlot(mySlot, (err, data) => {
## reminderAgent.addNotificationSlot<sup>(deprecated)</sup> ## reminderAgent.addNotificationSlot<sup>(deprecated)</sup>
```ts
addNotificationSlot(slot: NotificationSlot): Promise\<void> addNotificationSlot(slot: NotificationSlot): Promise\<void>
```
Adds a notification slot. This API uses a promise to return the result. Adds a notification slot. This API uses a promise to return the result.
...@@ -373,7 +353,7 @@ Adds a notification slot. This API uses a promise to return the result. ...@@ -373,7 +353,7 @@ Adds a notification slot. This API uses a promise to return the result.
| Type| Description| | Type| Description|
| -------- | -------- | | -------- | -------- |
| Promise\<void\> | Promise used to return the result.| | Promise\<void> | Promise used to return the result.|
**Example** **Example**
...@@ -391,9 +371,7 @@ reminderAgent.addNotificationSlot(mySlot).then(() => { ...@@ -391,9 +371,7 @@ reminderAgent.addNotificationSlot(mySlot).then(() => {
## reminderAgent.removeNotificationSlot<sup>(deprecated)</sup> ## reminderAgent.removeNotificationSlot<sup>(deprecated)</sup>
```ts
removeNotificationSlot(slotType: notification.SlotType, callback: AsyncCallback<void>): void removeNotificationSlot(slotType: notification.SlotType, callback: AsyncCallback<void>): void
```
Removes a notification slot of a specified type. This API uses an asynchronous callback to return the result. Removes a notification slot of a specified type. This API uses an asynchronous callback to return the result.
...@@ -408,7 +386,7 @@ Removes a notification slot of a specified type. This API uses an asynchronous c ...@@ -408,7 +386,7 @@ Removes a notification slot of a specified type. This API uses an asynchronous c
| Name| Type| Mandatory| Description| | Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
| slotType | [notification.SlotType](js-apis-notification.md#slottype) | Yes| Type of the reminder notification slot to remove.| | slotType | [notification.SlotType](js-apis-notification.md#slottype) | Yes| Type of the reminder notification slot to remove.|
| callback | AsyncCallback\<void\> | Yes| Callback used to return the result.| | callback | AsyncCallback\<void> | Yes| Callback used to return the result.|
**Example** **Example**
...@@ -423,9 +401,7 @@ reminderAgent.removeNotificationSlot(notification.SlotType.CONTENT_INFORMATION, ...@@ -423,9 +401,7 @@ reminderAgent.removeNotificationSlot(notification.SlotType.CONTENT_INFORMATION,
## reminderAgent.removeNotificationSlot<sup>(deprecated)</sup> ## reminderAgent.removeNotificationSlot<sup>(deprecated)</sup>
```ts
removeNotificationSlot(slotType: notification.SlotType): Promise<void> removeNotificationSlot(slotType: notification.SlotType): Promise<void>
```
Removes a notification slot of a specified type. This API uses a promise to return the result. Removes a notification slot of a specified type. This API uses a promise to return the result.
...@@ -445,7 +421,7 @@ Removes a notification slot of a specified type. This API uses a promise to retu ...@@ -445,7 +421,7 @@ Removes a notification slot of a specified type. This API uses a promise to retu
| Type| Description| | Type| Description|
| -------- | -------- | | -------- | -------- |
| Promise\<void\> | Promise used to return the result.| | Promise\<void> | Promise used to return the result.|
**Example** **Example**
...@@ -568,7 +544,6 @@ Defines the reminder to publish. ...@@ -568,7 +544,6 @@ Defines the reminder to publish.
## ReminderRequestCalendar<sup>(deprecated)</sup> ## ReminderRequestCalendar<sup>(deprecated)</sup>
ReminderRequestCalendar extends ReminderRequest
Defines a reminder for a calendar event. Defines a reminder for a calendar event.
...@@ -581,13 +556,12 @@ Defines a reminder for a calendar event. ...@@ -581,13 +556,12 @@ Defines a reminder for a calendar event.
| Name| Type| Mandatory| Description| | Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
| dateTime | [LocalDateTime](#localdatetime) | Yes| Reminder time.| | dateTime | [LocalDateTime](#localdatetime) | Yes| Reminder time.|
| repeatMonths | Array\<number\> | No| Month in which the reminder repeats.| | repeatMonths | Array\<number> | No| Month in which the reminder repeats.|
| repeatDays | Array\<number\> | No| Date on which the reminder repeats.| | repeatDays | Array\<number> | No| Date on which the reminder repeats.|
## ReminderRequestAlarm<sup>(deprecated)</sup> ## ReminderRequestAlarm<sup>(deprecated)</sup>
ReminderRequestAlarm extends ReminderRequest
Defines a reminder for an alarm. Defines a reminder for an alarm.
...@@ -601,13 +575,11 @@ Defines a reminder for an alarm. ...@@ -601,13 +575,11 @@ Defines a reminder for an alarm.
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
| hour | number | Yes| Hour portion of the reminder time.| | hour | number | Yes| Hour portion of the reminder time.|
| minute | number | Yes| Minute portion of the reminder time.| | minute | number | Yes| Minute portion of the reminder time.|
| daysOfWeek | Array\<number\> | No| Days of a week when the reminder repeats. The value ranges from 1 to 7, corresponding to the data from Monday to Sunday.| | daysOfWeek | Array\<number> | No| Days of a week when the reminder repeats. The value ranges from 1 to 7, corresponding to the data from Monday to Sunday.|
## ReminderRequestTimer<sup>(deprecated)</sup> ## ReminderRequestTimer<sup>(deprecated)</sup>
ReminderRequestTimer extends ReminderRequest
Defines a reminder for a scheduled timer. Defines a reminder for a scheduled timer.
> **NOTE** > **NOTE**
......
...@@ -170,7 +170,7 @@ Cancels the reminder with the specified ID. This API uses a promise to return th ...@@ -170,7 +170,7 @@ Cancels the reminder with the specified ID. This API uses a promise to return th
| Type| Description| | Type| Description|
| -------- | -------- | | -------- | -------- |
| PPromise\<void> | Promise used to return the result.| | Promise\<void> | Promise used to return the result.|
**Error codes** **Error codes**
...@@ -611,7 +611,7 @@ Defines the reminder to publish. ...@@ -611,7 +611,7 @@ Defines the reminder to publish.
| Name| Type| Mandatory| Description| | Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
| reminderType | [ReminderType](#remindertype) | Yes| Type of the reminder.| | reminderType | [ReminderType](#remindertype) | Yes| Type of the reminder.|
| actionButton<sup>10+</sup> | [ActionButton](#actionbutton) | No| Button displayed for the reminder in the notification panel. For common applications, a maximum of two buttons are supported. For system applications, a maximum of two buttons are supported in API version 9, and a maximum of three buttons are supported in API version 10 and later versions. | | actionButton<sup>10+</sup> | [ActionButton](#actionbutton) | No| Button displayed for the reminder in the notification panel. For common applications, a maximum of two buttons are supported. For system applications, a maximum of two buttons are supported in API version 9, and a maximum of three buttons are supported in API version 10 and later versions.|
| wantAgent | [WantAgent](#wantagent) | No| Information about the ability that is redirected to when the reminder is clicked.| | wantAgent | [WantAgent](#wantagent) | No| Information about the ability that is redirected to when the reminder is clicked.|
| maxScreenWantAgent | [MaxScreenWantAgent](#maxscreenwantagent) | No| Information about the ability that is automatically started when the reminder arrives. If the device is in use, a notification will be displayed.| | maxScreenWantAgent | [MaxScreenWantAgent](#maxscreenwantagent) | No| Information about the ability that is automatically started when the reminder arrives. If the device is in use, a notification will be displayed.|
| ringDuration | number | No| Ringing duration, in seconds. The default value is **1**.| | ringDuration | number | No| Ringing duration, in seconds. The default value is **1**.|
......
# @ohos.multimedia.systemSoundManager (System Sound Management)
The **systemSoundManager** module provides basic capabilities for managing system sounds, including setting and obtaining system ringtones and obtaining a player to play the system ringtone.
> **NOTE**
>
> The initial APIs of this module are supported since API version 10. Newly added APIs will be marked with a superscript to indicate their earliest API version.
>
> The APIs provided by this module are system APIs.
## Modules to Import
```js
import systemSoundManager from '@ohos.multimedia.systemSoundManager';
```
## RingtoneType
Enumerates the ringtone types.
**System API**: This is a system API.
**System capability**: SystemCapability.Multimedia.SystemSound.Core
| Name | Value | Description |
| ------------------------------- | ------ | -------------------------------------------- |
| RINGTONE_TYPE_DEFAULT | 0 | Default ringtone type. |
| RINGTONE_TYPE_MULTISIM | 1 | Multi-SIM ringtone type. |
## systemSoundManager.getSystemSoundManager
getSystemSoundManager(): SystemSoundManager
Obtains a system sound manager.
**System API**: This is a system API.
**System capability**: SystemCapability.Multimedia.SystemSound.Core
**Return value**
| Type | Description |
| ----------------------------- | ------------ |
| [SystemSoundManager](#systemsoundmanager) | System sound manager obtained.|
**Example**
```js
let systemSoundManagerInstance = systemSoundManager.getSystemSoundManager();
```
## SystemSoundManager
Provides APIs to manage system sounds. Before calling any API in **SystemSoundManager**, you must use [getSystemSoundManager](#systemsoundmanagergetsystemsoundmanager) to create a **SystemSoundManager** instance.
### setSystemRingtoneUri
setSystemRingtoneUri(context: Context, uri: string, type: RingtoneType, callback: AsyncCallback&lt;void&gt;): void
Sets a URI for the system ringtone. This API uses an asynchronous callback to return the result.
**System API**: This is a system API.
**System capability**: SystemCapability.Multimedia.SystemSound.Core
**Parameters**
| Name | Type | Mandatory| Description |
| -------- | ---------------------------------------- | ---- | ------------------------ |
| context | Context | Yes | Application context. |
| uri | string | Yes | URI of the system ringtone. For details, see [media.AVPlayer](js-apis-media.md#avplayer9).|
| type | [RingtoneType](#ringtonetype) | Yes | Type of the system ringtone. |
| callback | AsyncCallback&lt;void&gt; | Yes | Callback used to return the result. |
**Example**
```js
let context = this.context;
let uri = 'file://data/test.wav'; // Set the URI of the target ringtone file.
let type = systemSoundManager.RingtoneType.RINGTONE_TYPE_DEFAULT;
systemSoundManagerInstance.setSystemRingtoneUri(context, uri, type, (err) => {
if (err) {
console.error(`Failed to set system ringtone uri. ${err}`);
return;
}
console.info(`Callback invoked to indicate a successful setting of the system ringtone uri.`);
});
```
### setSystemRingtoneUri
setSystemRingtoneUri(context: Context, uri: string, type: RingtoneType): Promise&lt;void&gt;
Sets a URI for the system ringtone. This API uses a promise to return the result.
**System API**: This is a system API.
**System capability**: SystemCapability.Multimedia.SystemSound.Core
**Parameters**
| Name | Type | Mandatory| Description |
| -------- | ---------------------------------------- | ---- | ------------------------ |
| context | Context | Yes | Application context. |
| uri | string | Yes | URI of the system ringtone. For details, see [media.AVPlayer](js-apis-media.md#avplayer9).|
| type | [RingtoneType](#ringtonetype) | Yes | Type of the system ringtone. |
**Return value**
| Type | Description |
| ------------------- | ------------------------------- |
| Promise&lt;void&gt; | Promise used to return the result. |
**Example**
```js
let context = this.context;
let uri = 'file://data/test.wav'; // Set the URI of the target ringtone file.
let type = systemSoundManager.RingtoneType.RINGTONE_TYPE_DEFAULT;
systemSoundManagerInstance.setSystemRingtoneUri(context, uri, type).then(() => {
console.info(`Promise returned to indicate a successful setting of the system ringtone uri.`);
}).catch ((err) => {
console.error(`Failed to set the system ringtone uri ${err}`);
});
```
### getSystemRingtoneUri
getSystemRingtoneUri(context: Context, type: RingtoneType, callback: AsyncCallback&lt;string&gt;): void
Obtains the URI of a system ringtone. This API uses an asynchronous callback to return the result.
**System API**: This is a system API.
**System capability**: SystemCapability.Multimedia.SystemSound.Core
**Parameters**
| Name | Type | Mandatory| Description |
| -------- | ---------------------------------------- | ---- | ------------------------ |
| context | Context | Yes | Application context. |
| type | [RingtoneType](#ringtonetype) | Yes | Type of the system ringtone. |
| callback | AsyncCallback&lt;string&gt; | Yes | Callback used to return the ringtone URI obtained.|
**Example**
```js
let context = this.context;
let type = systemSoundManager.RingtoneType.RINGTONE_TYPE_DEFAULT;
systemSoundManagerInstance.getSystemRingtoneUri(context, type, (err, value) => {
if (err) {
console.error(`Failed to get system ringtone uri. ${err}`);
return;
}
console.info(`Callback invoked to indicate the value of the system ringtone uri is obtained ${value}.`);
});
```
### getSystemRingtoneUri
getSystemRingtoneUri(context: Context, type: RingtoneType): Promise&lt;string&gt;
Obtains the URI of a system ringtone. This API uses a promise to return the result.
**System API**: This is a system API.
**System capability**: SystemCapability.Multimedia.SystemSound.Core
**Parameters**
| Name | Type | Mandatory| Description |
| -------- | ---------------------------------------- | ---- | ------------------------ |
| context | Context | Yes | Application context. |
| type | [RingtoneType](#ringtonetype) | Yes | Type of the system ringtone. |
**Return value**
| Type | Description |
| ------------------- | ---------------------------------- |
| Promise&lt;string&gt; | Promise used to return the ringtone URI obtained.|
**Example**
```js
let context = this.context;
let type = systemSoundManager.RingtoneType.RINGTONE_TYPE_DEFAULT;
systemSoundManagerInstance.getSystemRingtoneUri(context, type).then((value) => {
console.info(`Promise returned to indicate that the value of the system ringtone uri is obtained ${value}.`);
}).catch ((err) => {
console.error(`Failed to get the system ringtone uri ${err}`);
});
```
### getSystemRingtonePlayer
getSystemRingtonePlayer(context: Context, type: RingtoneType, callback: AsyncCallback&lt;RingtonePlayer&gt;): void
Obtains a player to play the system ringtone. This API uses an asynchronous callback to return the result.
**System API**: This is a system API.
**System capability**: SystemCapability.Multimedia.SystemSound.Core
**Parameters**
| Name | Type | Mandatory| Description |
| -------- | -----------------------------------------| ---- | --------------------------- |
| context | Context | Yes | Application context. |
| type | [RingtoneType](#ringtonetype) | Yes | Type of the system ringtone.|
| callback | AsyncCallback&lt;[RingtonePlayer](js-apis-inner-multimedia-ringtonePlayer.md#ringtoneplayer)&gt; | Yes| Callback used to return the ringtone player obtained.|
**Example**
```js
let context = this.context;
let type = systemSoundManager.RingtoneType.RINGTONE_TYPE_DEFAULT;
let systemRingtonePlayer = null;
systemSoundManagerInstance.getSystemRingtonePlayer(context, type, (err, value) => {
if (err) {
console.error(`Failed to get system ringtone player. ${err}`);
return;
}
console.info(`Callback invoked to indicate the value of the system ringtone player is obtained.`);
systemRingtonePlayer = value;
});
```
### getSystemRingtonePlayer
getSystemRingtonePlayer(context: Context, type: RingtoneType): Promise&lt;RingtonePlayer&gt;
Obtains a player to play the system ringtone. This API uses a promise to return the result.
**System API**: This is a system API.
**System capability**: SystemCapability.Multimedia.SystemSound.Core
**Parameters**
| Name | Type | Mandatory| Description |
| -------- | -----------------------------------------| ---- | --------------------------- |
| context | Context | Yes | Application context. |
| type | [RingtoneType](#ringtonetype) | Yes | Type of the system ringtone.|
**Return value**
| Type | Description |
| ------------------- | ------------------------------- |
| Promise&lt;[RingtonePlayer](js-apis-inner-multimedia-ringtonePlayer.md#ringtoneplayer)&gt; | Promise used to return the ringtone player obtained.|
**Example**
```js
let context = this.context;
let type = systemSoundManager.RingtoneType.RINGTONE_TYPE_DEFAULT;
let systemRingtonePlayer = null;
systemSoundManagerInstance.getSystemRingtonePlayer(context, type).then((value) => {
console.info(`Promise returned to indicate that the value of the system ringtone player is obtained.`);
systemRingtonePlayer = value;
}).catch ((err) => {
console.error(`Failed to get the system ringtone player ${err}`);
});
```
# @ohos.taskpool (Using the Task Pool) # @ohos.taskpool (Starting the Task Pool)
The task pool provides a multi-thread running environment for applications. It helps reduce resource consumption and improve system performance. It also frees you from caring about the lifecycle of thread instances. You can use the **TaskPool** APIs to create background tasks and perform operations on them, for example, executing or canceling a task. Theoretically, you can create an unlimited number of tasks, but this is not recommended for memory considerations. In addition, you are not advised performing blocking operations in a task, especially indefinite blocking. Long-time blocking operations occupy worker threads and may block other task scheduling, adversely affecting your application performance. The task pool provides a multi-thread running environment for applications. It helps reduce resource consumption and improve system performance. It also frees you from caring about the lifecycle of thread instances. You can use the **TaskPool** APIs to create background tasks and perform operations on them, for example, executing or canceling a task. Theoretically, you can create an unlimited number of tasks, but this is not recommended for memory considerations. In addition, you are not advised performing blocking operations in a task, especially indefinite blocking. Long-time blocking operations occupy worker threads and may block other task scheduling, adversely affecting your application performance.
You can determine the execution sequence of tasks with the same priority. They are executed in the same sequence as you call the task execution APIs. The default task priority is **MEDIUM**. (The task priority mechanism is not supported yet.) You can determine the execution sequence of tasks with the same priority. They are executed in the same sequence as you call the task execution APIs. The default task priority is **MEDIUM**.
If the number of tasks to be executed is greater than the number of worker threads in the task pool, the task pool scales out based on load balancing to minimize the waiting duration. Similarly, when the number of tasks to be executed falls below the number of worker threads, the task pool scales in to reduce the number of worker threads. (The load balancing mechanism is not supported yet.) If the number of tasks to be executed is greater than the number of worker threads in the task pool, the task pool scales out based on load balancing to minimize the waiting duration. Similarly, when the number of tasks to be executed falls below the number of worker threads, the task pool scales in to reduce the number of worker threads.
The **TaskPool** APIs return error codes in numeric format. For details about the error codes, see [Utils Error Codes](../errorcodes/errorcode-utils.md). The **TaskPool** APIs return error codes in numeric format. For details about the error codes, see [Utils Error Codes](../errorcodes/errorcode-utils.md).
...@@ -32,13 +32,13 @@ Enumerates the priorities available for created tasks. ...@@ -32,13 +32,13 @@ Enumerates the priorities available for created tasks.
**Example** **Example**
```ts ```ts
function func(args) { @Concurrent
"use concurrent"; function printArgs(args) {
console.log("func: " + args); console.log("printArgs: " + args);
return args; return args;
} }
async function taskpoolTest() { async function taskpoolPriority() {
let task = new taskpool.Task(func, 100); let task = new taskpool.Task(printArgs, 100);
let highCount = 0; let highCount = 0;
let mediumCount = 0; let mediumCount = 0;
...@@ -65,7 +65,7 @@ async function taskpoolTest() { ...@@ -65,7 +65,7 @@ async function taskpoolTest() {
}) })
} }
} }
taskpoolTest(); taskpoolPriority();
``` ```
## Task ## Task
...@@ -99,12 +99,12 @@ For details about the error codes, see [Utils Error Codes](../errorcodes/errorco ...@@ -99,12 +99,12 @@ For details about the error codes, see [Utils Error Codes](../errorcodes/errorco
```ts ```ts
@Concurrent @Concurrent
function func(args) { function printArgs(args) {
console.log("func: " + args); console.log("printArgs: " + args);
return args; return args;
} }
let task = new taskpool.Task(func, "this is my first Task"); let task = new taskpool.Task(printArgs, "this is my first Task");
``` ```
### Attributes ### Attributes
...@@ -151,17 +151,17 @@ For details about the error codes, see [Utils Error Codes](../errorcodes/errorco ...@@ -151,17 +151,17 @@ For details about the error codes, see [Utils Error Codes](../errorcodes/errorco
```ts ```ts
@Concurrent @Concurrent
function func(args) { function printArgs(args) {
console.log("func: " + args); console.log("printArgs: " + args);
return args; return args;
} }
async function taskpoolTest() { async function taskpoolExecute() {
let value = await taskpool.execute(func, 100); let value = await taskpool.execute(printArgs, 100);
console.log("taskpool result: " + value); console.log("taskpool result: " + value);
} }
taskpoolTest(); taskpoolExecute();
``` ```
## taskpool.execute ## taskpool.execute
...@@ -199,18 +199,18 @@ For details about the error codes, see [Utils Error Codes](../errorcodes/errorco ...@@ -199,18 +199,18 @@ For details about the error codes, see [Utils Error Codes](../errorcodes/errorco
```ts ```ts
@Concurrent @Concurrent
function func(args) { function printArgs(args) {
console.log("func: " + args); console.log("printArgs: " + args);
return args; return args;
} }
async function taskpoolTest() { async function taskpoolExecute() {
let task = new taskpool.Task(func, 100); let task = new taskpool.Task(printArgs, 100);
let value = await taskpool.execute(task); let value = await taskpool.execute(task);
console.log("taskpool result: " + value); console.log("taskpool result: " + value);
} }
taskpoolTest(); taskpoolExecute();
``` ```
## taskpool.cancel ## taskpool.cancel
...@@ -239,14 +239,14 @@ For details about the error codes, see [Utils Error Codes](../errorcodes/errorco ...@@ -239,14 +239,14 @@ For details about the error codes, see [Utils Error Codes](../errorcodes/errorco
**Example of successful task cancellation** **Example of successful task cancellation**
```ts ```ts
function func(args) { @Concurrent
"use concurrent"; function printArgs(args) {
console.log("func: " + args); console.log("printArgs: " + args);
return args; return args;
} }
async function taskpoolTest() { async function taskpoolCancel() {
let task = new taskpool.Task(func, 100); let task = new taskpool.Task(printArgs, 100);
taskpool.execute(task); taskpool.execute(task);
try { try {
taskpool.cancel(task); taskpool.cancel(task);
...@@ -255,20 +255,20 @@ async function taskpoolTest() { ...@@ -255,20 +255,20 @@ async function taskpoolTest() {
} }
} }
taskpoolTest(); taskpoolCancel();
``` ```
**Example of a failure to cancel a task that has been executed** **Example of a failure to cancel a task that has been executed**
```ts ```ts
function func(args) { @Concurrent
"use concurrent"; function printArgs(args) {
console.log("func: " + args); console.log("printArgs: " + args);
return args; return args;
} }
async function taskpoolTest() { async function taskpoolCancel() {
let task = new taskpool.Task(func, 100); let task = new taskpool.Task(printArgs, 100);
let value = taskpool.execute(task); let value = taskpool.execute(task);
let start = new Date().getTime(); let start = new Date().getTime();
while (new Date().getTime() - start < 1000) {// Wait for 1s to ensure that the task has been executed. while (new Date().getTime() - start < 1000) {// Wait for 1s to ensure that the task has been executed.
...@@ -282,25 +282,25 @@ async function taskpoolTest() { ...@@ -282,25 +282,25 @@ async function taskpoolTest() {
} }
} }
taskpoolTest(); taskpoolCancel();
``` ```
**Example of a failure to cancel an ongoing task** **Example of a failure to cancel an ongoing task**
```ts ```ts
function func(args) { @Concurrent
"use concurrent"; function printArgs(args) {
console.log("func: " + args); console.log("printArgs: " + args);
return args; return args;
} }
async function taskpoolTest() { async function taskpoolCancel() {
let task1 = new taskpool.Task(func, 100); let task1 = new taskpool.Task(printArgs, 100);
let task2 = new taskpool.Task(func, 200); let task2 = new taskpool.Task(printArgs, 200);
let task3 = new taskpool.Task(func, 300); let task3 = new taskpool.Task(printArgs, 300);
let task4 = new taskpool.Task(func, 400); let task4 = new taskpool.Task(printArgs, 400);
let task5 = new taskpool.Task(func, 500); let task5 = new taskpool.Task(printArgs, 500);
let task6 = new taskpool.Task(func, 600); let task6 = new taskpool.Task(printArgs, 600);
let res1 = taskpool.execute(task1); let res1 = taskpool.execute(task1);
let res2 = taskpool.execute(task2); let res2 = taskpool.execute(task2);
...@@ -315,7 +315,7 @@ async function taskpoolTest() { ...@@ -315,7 +315,7 @@ async function taskpoolTest() {
} }
} }
taskpoolTest(); taskpoolCancel();
``` ```
## Additional Information ## Additional Information
...@@ -327,7 +327,7 @@ The following sequenceable data types are supported: All Primitive Type (excludi ...@@ -327,7 +327,7 @@ The following sequenceable data types are supported: All Primitive Type (excludi
- The task pool APIs can be used only in the module with **compileMode** set to **esmodule** in the stage model. To check the **compileMode** setting of a module, open the **build-profile.json5** file of the module and check for **"compileMode": "esmodule"** under **buildOption**. - The task pool APIs can be used only in the module with **compileMode** set to **esmodule** in the stage model. To check the **compileMode** setting of a module, open the **build-profile.json5** file of the module and check for **"compileMode": "esmodule"** under **buildOption**.
- A task in the task pool can reference only variables passed in by input parameters or imported variables, rather than closure variables. The decorator **@Concurrent** is used to intercept unsupported variables. - A task in the task pool can reference only variables passed in by input parameters or imported variables, rather than closure variables. The decorator **@Concurrent** is used to intercept unsupported variables.
- A task in the task pool supports only common functions or async functions, rather than class member functions or anonymous functions. The decorator **@Concurrent** is used to intercept unsupported functions. - A task in the task pool supports only common functions or async functions, rather than class member functions or anonymous functions. The decorator **@Concurrent** is used to intercept unsupported functions.
- The decorator **@Concurrent** can be used only in the .ets file. To create a task in the task pool in the .ts file, use the statement **use concurrent**. - The decorator **@Concurrent** can be used only in .ets files.
### Using the Task Pool in Simple Mode ### Using the Task Pool in Simple Mode
...@@ -336,23 +336,23 @@ The following sequenceable data types are supported: All Primitive Type (excludi ...@@ -336,23 +336,23 @@ The following sequenceable data types are supported: All Primitive Type (excludi
```ts ```ts
// Common functions are supported, and variables passed in by input parameters are also supported. // Common functions are supported, and variables passed in by input parameters are also supported.
@Concurrent @Concurrent
function func(args) { function printArgs(args) {
console.log("func: " + args); console.log("func: " + args);
return args; return args;
} }
async function taskpoolTest() { async function taskpoolExecute() {
// taskpool.execute(task) // taskpool.execute(task)
let task = new taskpool.Task(func, "create task, then execute"); let task = new taskpool.Task(printArgs, "create task, then execute");
let val1 = await taskpool.execute(task); let val1 = await taskpool.execute(task);
console.log("taskpool.execute(task) result: " + val1); console.log("taskpool.execute(task) result: " + val1);
// taskpool.execute(function) // taskpool.execute(function)
let val2 = await taskpool.execute(func, "execute task by func"); let val2 = await taskpool.execute(printArgs, "execute task by func");
console.log("taskpool.execute(function) result: " + val2); console.log("taskpool.execute(function) result: " + val2);
} }
taskpoolTest(); taskpoolExecute();
``` ```
**Example 2** **Example 2**
...@@ -367,24 +367,24 @@ export var c = 2000; ...@@ -367,24 +367,24 @@ export var c = 2000;
import { c } from "./b"; import { c } from "./b";
@Concurrent @Concurrent
function test(a) { function printArgs(a) {
console.log(a); console.log(a);
console.log(c); console.log(c);
return a; return a;
} }
async function taskpoolTest() { async function taskpoolExecute() {
// taskpool.execute(task) // taskpool.execute(task)
let task = new taskpool.Task(test, "create task, then execute"); let task = new taskpool.Task(printArgs, "create task, then execute");
let val1 = await taskpool.execute(task); let val1 = await taskpool.execute(task);
console.log("taskpool.execute(task) result: " + val1); console.log("taskpool.execute(task) result: " + val1);
// taskpool.execute(function) // taskpool.execute(function)
let val2 = await taskpool.execute(test, "execute task by func"); let val2 = await taskpool.execute(printArgs, "execute task by func");
console.log("taskpool.execute(function) result: " + val2); console.log("taskpool.execute(function) result: " + val2);
} }
taskpoolTest(); taskpoolExecute();
``` ```
**Example 3** **Example 3**
...@@ -392,57 +392,52 @@ taskpoolTest(); ...@@ -392,57 +392,52 @@ taskpoolTest();
```ts ```ts
// The async functions are supported. // The async functions are supported.
@Concurrent @Concurrent
async function task() { async function delayExcute() {
let ret = await Promise.all([ let ret = await Promise.all([
new Promise(resolve => setTimeout(resolve, 1000, "resolved")) new Promise(resolve => setTimeout(resolve, 1000, "resolved"))
]); ]);
return ret; return ret;
} }
async function taskpoolTest() { async function taskpoolExecute() {
taskpool.execute(task).then((result) => { taskpool.execute(delayExcute).then((result) => {
console.log("TaskPoolTest task result: " + result); console.log("TaskPoolTest task result: " + result);
}); });
} }
taskpoolTest(); taskpoolExecute();
``` ```
**Example 4** **Example 4**
```ts ```ts
// Use use concurrent to create a task in the task pool in the .ts file. // c.ets
// c.ts @Concurrent
function test1(n) { function strSort(inPutArr) {
"use concurrent" let newArr = inPutArr.sort();
return n; return newArr;
} }
export async function taskpoolTest1() { export async function func1() {
console.log("taskpoolTest1 start"); console.log("taskpoolTest start");
var task = new taskpool.Task(test1, 100); let strArray = ['c test string', 'b test string', 'a test string'];
var task = new taskpool.Task(strSort, strArray);
var result = await taskpool.execute(task); var result = await taskpool.execute(task);
console.log("taskpoolTest1 result:" + result); console.log("func1 result:" + result);
} }
async function test2() { export async function func2() {
"use concurrent"
var ret = await Promise.all([
new Promise(resolve => setTimeout(resolve, 1000, "resolved"))
]);
return ret;
}
export async function taskpoolTest2() {
console.log("taskpoolTest2 start"); console.log("taskpoolTest2 start");
taskpool.execute(test2).then((result) => { let strArray = ['c test string', 'b test string', 'a test string'];
console.log("TaskPoolTest2 result: " + result); taskpool.execute(strSort, strArray).then((result) => {
console.log("func2 result: " + result);
}); });
} }
``` ```
```ts ```ts
/ / a.ets (in the same directory as c.ts) / / a.ets (in the same directory as c.ets)
import { taskpoolTest1, taskpoolTest2 } from "./c"; import { taskpoolTest1, taskpoolTest2 } from "./c";
taskpoolTest1(); func1();
taskpoolTest2(); func2();
``` ```
# Blank # Blank
The **\<Blank>** component is able to automatically fill the empty spaces in the container along the main axis. It is valid only when the parent container is **\<Row>** or **\<Column>**. The **\<Blank>** component is able to automatically fill the empty spaces in the container along the main axis. It works only when the parent component is **\<Row>**, **\<Column>**, or **\<Flex>**.
> **NOTE** > **NOTE**
> >
...@@ -30,7 +30,7 @@ In addition to the [universal attributes](ts-universal-attributes-size.md), the ...@@ -30,7 +30,7 @@ In addition to the [universal attributes](ts-universal-attributes-size.md), the
| Name| Type| Description| | Name| Type| Description|
| -------- | -------- | -------- | | -------- | -------- | -------- |
| color | [ResourceColor](ts-types.md#resourcecolor) | Color to fill the empty spaces.<br>Default value: **Color.Transparent**<br>Since API version 9, this API is supported in ArkTS widgets. | | color | [ResourceColor](ts-types.md#resourcecolor) | Color to fill the empty spaces.<br>Default value: **Color.Transparent**<br>Since API version 9, this API is supported in ArkTS widgets.|
## Events ## Events
...@@ -50,7 +50,7 @@ struct BlankExample { ...@@ -50,7 +50,7 @@ struct BlankExample {
Row() { Row() {
Text('Bluetooth').fontSize(18) Text('Bluetooth').fontSize(18)
Blank() Blank()
Toggle({ type: ToggleType.Switch }) Toggle({ type: ToggleType.Switch }).margin({ top: 14, bottom: 14, left: 6, right: 6 })
}.width('100%').backgroundColor(0xFFFFFF).borderRadius(15).padding({ left: 12 }) }.width('100%').backgroundColor(0xFFFFFF).borderRadius(15).padding({ left: 12 })
}.backgroundColor(0xEFEFEF).padding(20) }.backgroundColor(0xEFEFEF).padding(20)
} }
...@@ -80,16 +80,16 @@ struct BlankExample { ...@@ -80,16 +80,16 @@ struct BlankExample {
Row() { Row() {
Text('Bluetooth').fontSize(18) Text('Bluetooth').fontSize(18)
Blank().color(Color.Yellow) Blank().color(Color.Yellow)
Toggle({ type: ToggleType.Switch }) Toggle({ type: ToggleType.Switch }).margin({ top: 14, bottom: 14, left: 6, right: 6 })
}.backgroundColor(0xFFFFFF).borderRadius(15).padding({ left: 12 }) }.backgroundColor(0xFFFFFF).borderRadius(15).padding({ left: 12 })
Row() { Row() {
Text('Bluetooth').fontSize(18) Text('Bluetooth').fontSize(18)
// Set the minimum width to 160. // Set the minimum width to 160.
Blank('160').color(Color.Yellow) Blank('160').color(Color.Yellow)
Toggle({ type: ToggleType.Switch }) Toggle({ type: ToggleType.Switch }).margin({ top: 14, bottom: 14, left: 6, right: 6 })
}.backgroundColor(0xFFFFFF).borderRadius(15).padding({ left: 12 }) }.backgroundColor(0xFFFFFF).borderRadius(15).padding({ left: 12 })
}.backgroundColor(0xEFEFEF).padding(20).width('100%') }.backgroundColor(0xEFEFEF).padding(20).width('100%')
} }
} }
......
...@@ -24,7 +24,7 @@ Since API version 9, this API is supported in ArkTS widgets. ...@@ -24,7 +24,7 @@ Since API version 9, this API is supported in ArkTS widgets.
| Name| Type| Mandatory| Description| | Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
| value | string | Yes| Content of the QR code. A maximum of 256 characters are supported. If the number of characters exceeds 256, the first 256 characters are used.| | value | string | Yes| Content of the QR code. A maximum of 256 characters are supported. If the number of characters exceeds 256, the first 256 characters are used.<br>**NOTE**<br>The string cannot be **null**, **undefined**, or empty.|
## Attributes ## Attributes
......
此差异已折叠。
此差异已折叠。
此差异已折叠。
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册