提交 b20350c5 编写于 作者: W wusongqing

add apis en against master

Signed-off-by: Nwusongqing <wusongqing@huawei.com>
上级 40192463
...@@ -4,53 +4,58 @@ ...@@ -4,53 +4,58 @@
- Ability Framework - Ability Framework
- [@ohos.ability.dataUriUtils](js-apis-DataUriUtils.md) - FA Model
- [@ohos.ability.errorCode](js-apis-ability-errorCode.md) - [@ohos.ability.featureAbility](js-apis-featureAbility.md)
- [@ohos.ability.wantConstant](js-apis-ability-wantConstant.md) - [@ohos.ability.particleAbility](js-apis-particleAbility.md)
- [@ohos.application.Ability](js-apis-application-ability.md) - ability/[dataAbilityHelper](js-apis-dataAbilityHelper.md)
- [@ohos.application.AbilityConstant](js-apis-application-abilityConstant.md) - app/[context](js-apis-Context.md)
- [@ohos.application.abilityDelegatorRegistry](js-apis-abilityDelegatorRegistry.md) - Stage Model
- [@ohos.application.AbilityStage ](js-apis-application-abilitystage.md) - [@ohos.application.Ability](js-apis-application-ability.md)
- [@ohos.application.abilityLifecycleCallback](js-apis-application-abilityLifecycleCallback.md) - [@ohos.application.AbilityConstant](js-apis-application-abilityConstant.md)
- [@ohos.application.appManager](js-apis-appmanager.md) - [@ohos.application.AbilityStage](js-apis-application-abilitystage.md)
- [@ohos.application.Configuration](js-apis-configuration.md) - [@ohos.application.abilityLifecycleCallback](js-apis-application-abilityLifecycleCallback.md)
- [@ohos.application.ConfigurationConstant](js-apis-configurationconstant.md) - [@ohos.application.DataShareExtensionAbility](js-apis-application-DataShareExtensionAbility.md)
- [@ohos.application.DataShareExtensionAbility](js-apis-application-DataShareExtensionAbility.md) - [@ohos.application.FormExtension](js-apis-formextension.md)
- [@ohos.ability.featureAbility](js-apis-featureAbility.md) - [@ohos.application.ServiceExtensionAbility](js-apis-service-extension-ability.md)
- [@ohos.application.formBindingData](js-apis-formbindingdata.md) - [@ohos.application.StartOptions](js-apis-application-StartOptions.md)
- [@ohos.application.FormExtension](js-apis-formextension.md) - [@ohos.application.StaticSubscriberExtensionAbility](js-apis-application-staticSubscriberExtensionAbility.md)
- [@ohos.application.formError](js-apis-formerror.md) - application/[AbilityContext](js-apis-ability-context.md)
- [@ohos.application.formHost](js-apis-formhost.md) - application/[ApplicationContext](js-apis-application-applicationContext.md)
- [@ohos.application.formInfo](js-apis-formInfo.md) - application/[AbilityStageContext](js-apis-abilitystagecontext.md)
- [@ohos.application.missionManager](js-apis-missionManager.md) - application/[Context](js-apis-application-context.md)
- [@ohos.application.formProvider](js-apis-formprovider.md) - application/[ExtensionContext](js-apis-extension-context.md)
- [@ohos.ability.particleAbility](js-apis-particleAbility.md) - application/[FormExtensionContext](js-apis-formextensioncontext.md)
- [@ohos.application.ServiceExtensionAbility](js-apis-service-extension-ability.md) - application/[PermissionRequestResult](js-apis-permissionrequestresult.md)
- [@ohos.application.StartOptions](js-apis-application-StartOptions.md) - application/[ServiceExtensionContext](js-apis-service-extension-context.md)
- [@ohos.application.StaticSubscriberExtensionAbility](js-apis-application-staticSubscriberExtensionAbility.md) - FA and Stage Models
- [@ohos.application.uriPermissionManager](js-apis-uripermissionmanager.md) - [@ohos.ability.dataUriUtils](js-apis-DataUriUtils.md)
- [@ohos.application.Want](js-apis-application-Want.md) - [@ohos.ability.errorCode](js-apis-ability-errorCode.md)
- [@ohos.wantAgent](js-apis-wantAgent.md) - [@ohos.ability.wantConstant](js-apis-ability-wantConstant.md)
- ability/[dataAbilityHelper](js-apis-dataAbilityHelper.md) - [@ohos.application.abilityDelegatorRegistry](js-apis-abilityDelegatorRegistry.md)
- app/[context](js-apis-Context.md) - [@ohos.application.abilityManager](js-apis-application-abilityManager.md)
- application/[AbilityContext](js-apis-ability-context.md) - [@ohos.application.appManager](js-apis-appmanager.md)
- application/[ApplicationContext](js-apis-application-applicationContext.md) - [@ohos.application.Configuration](js-apis-configuration.md)
- application/[abilityDelegator](js-apis-application-abilityDelegator.md) - [@ohos.application.ConfigurationConstant](js-apis-configurationconstant.md)
- application/[abilityDelegatorArgs](js-apis-application-abilityDelegatorArgs.md) - [@ohos.application.EnvironmentCallback](js-apis-application-EnvironmentCallback.md)
- application/[abilityMonitor](js-apis-application-abilityMonitor.md) - [@ohos.application.formBindingData](js-apis-formbindingdata.md)
- application/[AbilityRunningInfo](js-apis-abilityrunninginfo.md) - [@ohos.application.formError](js-apis-formerror.md)
- application/[AbilityStageContext](js-apis-abilitystagecontext.md) - [@ohos.application.formHost](js-apis-formhost.md)
- application/[Context](js-apis-application-context.md) - [@ohos.application.formInfo](js-apis-formInfo.md)
- application/[ExtensionContext](js-apis-extension-context.md) - [@ohos.application.formProvider](js-apis-formprovider.md)
- application/[ExtensionRunningInfo](js-apis-extensionrunninginfo.md) - [@ohos.application.missionManager](js-apis-missionManager.md)
- application/[FormExtensionContext](js-apis-formextensioncontext.md) - [@ohos.application.Want](js-apis-application-Want.md)
- application/[MissionSnapshot](js-apis-application-MissionSnapshot.md) - [@ohos.continuation.continuationManager](js-apis-continuation-continuationExtraParams.md)
- application/[PermissionRequestResult](js-apis-permissionrequestresult.md) - [@ohos.continuation.continuationManager](js-apis-continuation-continuationManager.md)
- application/[ProcessRunningInfo](js-apis-processrunninginfo.md) - [@ohos.wantAgent](js-apis-wantAgent.md)
- application/[ServiceExtensionContext](js-apis-service-extension-context.md) - application/[abilityDelegator](js-apis-application-abilityDelegator.md)
- application/[shellCmdResult](js-apis-application-shellCmdResult.md) - application/[abilityDelegatorArgs](js-apis-application-abilityDelegatorArgs.md)
- application/[MissionInfo](js-apis-application-missionInfo.md) - application/[abilityMonitor](js-apis-application-abilityMonitor.md)
- application/[AbilityRunningInfo](js-apis-abilityrunninginfo.md)
- application/[ExtensionRunningInfo](js-apis-extensionrunninginfo.md)
- application/[MissionSnapshot](js-apis-application-MissionSnapshot.md)
- application/[ProcessRunningInfo](js-apis-processrunninginfo.md)
- application/[shellCmdResult](js-apis-application-shellCmdResult.md)
- continuation/[ContinuationResult](js-apis-continuation-continuationResult.md)
- Common Event and Notification - Common Event and Notification
- [@ohos.commonEvent](js-apis-commonEvent.md) - [@ohos.commonEvent](js-apis-commonEvent.md)
...@@ -58,7 +63,7 @@ ...@@ -58,7 +63,7 @@
- [@ohos.notification](js-apis-notification.md) - [@ohos.notification](js-apis-notification.md)
- [@ohos.reminderAgent](js-apis-reminderAgent.md) - [@ohos.reminderAgent](js-apis-reminderAgent.md)
- application/[EventHub](js-apis-eventhub.md) - application/[EventHub](js-apis-eventhub.md)
- Bundle Management - Bundle Management
- [@ohos.bundle](js-apis-Bundle.md) - [@ohos.bundle](js-apis-Bundle.md)
...@@ -69,26 +74,30 @@ ...@@ -69,26 +74,30 @@
- bundle/[ApplicationInfo](js-apis-bundle-ApplicationInfo.md) - bundle/[ApplicationInfo](js-apis-bundle-ApplicationInfo.md)
- bundle/[BundleInfo](js-apis-bundle-BundleInfo.md) - bundle/[BundleInfo](js-apis-bundle-BundleInfo.md)
- bundle/[CustomizeData](js-apis-bundle-CustomizeData.md) - bundle/[CustomizeData](js-apis-bundle-CustomizeData.md)
- bundle/[ElementName](js-apis-bundle-ElementName.md)
- bundle/[ExtensionAbilityInfo](js-apis-bundle-ExtensionAbilityInfo.md) - bundle/[ExtensionAbilityInfo](js-apis-bundle-ExtensionAbilityInfo.md)
- bundle/[HapModuleInfo](js-apis-bundle-HapModuleInfo.md) - bundle/[HapModuleInfo](js-apis-bundle-HapModuleInfo.md)
- bundle/[Metadata](js-apis-bundle-Metadata.md) - bundle/[Metadata](js-apis-bundle-Metadata.md)
- bundle/[ModuleInfo](js-apis-bundle-ModuleInfo.md) - bundle/[ModuleInfo](js-apis-bundle-ModuleInfo.md)
- UI Page - UI Page
- [@ohos.animator](js-apis-animator.md) - [@ohos.animator](js-apis-animator.md)
- [@ohos.mediaquery](js-apis-mediaquery.md) - [@ohos.mediaquery](js-apis-mediaquery.md)
- [@ohos.prompt](js-apis-prompt.md) - [@ohos.prompt](js-apis-prompt.md)
- [@ohos.router](js-apis-router.md) - [@ohos.router](js-apis-router.md)
- [@ohos.uiAppearance](js-apis-uiappearance.md)
- Graphics - Graphics
- [@ohos.display ](js-apis-display.md) - [@ohos.display ](js-apis-display.md)
- [@ohos.effectKit](js-apis-effectKit.md)
- [@ohos.screen](js-apis-screen.md)
- [@ohos.screenshot](js-apis-screenshot.md) - [@ohos.screenshot](js-apis-screenshot.md)
- [@ohos.window](js-apis-window.md) - [@ohos.window](js-apis-window.md)
- [webgl](js-apis-webgl.md) - [webgl](js-apis-webgl.md)
- [webgl2](js-apis-webgl2.md) - [webgl2](js-apis-webgl2.md)
- Media - Media
- [@ohos.multimedia.audio](js-apis-audio.md) - [@ohos.multimedia.audio](js-apis-audio.md)
...@@ -96,32 +105,33 @@ ...@@ -96,32 +105,33 @@
- [@ohos.multimedia.image](js-apis-image.md) - [@ohos.multimedia.image](js-apis-image.md)
- [@ohos.multimedia.media](js-apis-media.md) - [@ohos.multimedia.media](js-apis-media.md)
- [@ohos.multimedia.medialibrary](js-apis-medialibrary.md) - [@ohos.multimedia.medialibrary](js-apis-medialibrary.md)
- Resource Management - Resource Management
- [@ohos.i18n](js-apis-i18n.md) - [@ohos.i18n](js-apis-i18n.md)
- [@ohos.intl](js-apis-intl.md) - [@ohos.intl](js-apis-intl.md)
- [@ohos.resourceManager](js-apis-resource-manager.md) - [@ohos.resourceManager](js-apis-resource-manager.md)
- Resource Scheduling - Resource Scheduling
- [@ohos.backgroundTaskManager](js-apis-backgroundTaskManager.md) - [@ohos.backgroundTaskManager](js-apis-backgroundTaskManager.md)
- [@ohos.workScheduler ](js-apis-workScheduler.md) - [@ohos.workScheduler ](js-apis-workScheduler.md)
- [@ohos.WorkSchedulerExtensionAbility](js-apis-WorkSchedulerExtensionAbility.md) - [@ohos.WorkSchedulerExtensionAbility](js-apis-WorkSchedulerExtensionAbility.md)
- Custom Management - Custom Management
- [@ohos.configPolicy](js-apis-config-policy.md) - [@ohos.configPolicy](js-apis-config-policy.md)
- [@ohos.enterpriseDeviceManager](js-apis-enterprise-device-manager.md) - [@ohos.enterpriseDeviceManager](js-apis-enterprise-device-manager.md)
- [@ohos.EnterpriseAdminExtensionAbility](js-apis-EnterpriseAdminExtensionAbility.md) - [@ohos.EnterpriseAdminExtensionAbility](js-apis-EnterpriseAdminExtensionAbility.md)
- Security - Security
- [@ohos.abilityAccessCtrl](js-apis-abilityAccessCtrl.md) - [@ohos.abilityAccessCtrl](js-apis-abilityAccessCtrl.md)
- [@ohos.privacyManager](js-apis-privacyManager.md)
- [@ohos.security.huks ](js-apis-huks.md) - [@ohos.security.huks ](js-apis-huks.md)
- [@ohos.userIAM.userAuth ](js-apis-useriam-userauth.md) - [@ohos.userIAM.userAuth ](js-apis-useriam-userauth.md)
- [@system.cipher](js-apis-system-cipher.md) - [@system.cipher](js-apis-system-cipher.md)
- Data Management - Data Management
- [@ohos.data.dataAbility ](js-apis-data-ability.md) - [@ohos.data.dataAbility ](js-apis-data-ability.md)
...@@ -134,7 +144,7 @@ ...@@ -134,7 +144,7 @@
- [@ohos.data.rdb](js-apis-data-rdb.md) - [@ohos.data.rdb](js-apis-data-rdb.md)
- [@ohos.data.ValuesBucket](js-apis-data-ValuesBucket.md) - [@ohos.data.ValuesBucket](js-apis-data-ValuesBucket.md)
- data/rdb/[resultSet](js-apis-data-resultset.md) - data/rdb/[resultSet](js-apis-data-resultset.md)
- File Management - File Management
- [@ohos.document](js-apis-document.md) - [@ohos.document](js-apis-document.md)
...@@ -145,7 +155,7 @@ ...@@ -145,7 +155,7 @@
- [@ohos.storageStatistics](js-apis-storage-statistics.md) - [@ohos.storageStatistics](js-apis-storage-statistics.md)
- [@ohos.volumeManager](js-apis-volumemanager.md) - [@ohos.volumeManager](js-apis-volumemanager.md)
- [@ohos.securityLabel](js-apis-securityLabel.md) - [@ohos.securityLabel](js-apis-securityLabel.md)
- Telephony Service - Telephony Service
- [@ohos.contact](js-apis-contact.md) - [@ohos.contact](js-apis-contact.md)
...@@ -155,7 +165,7 @@ ...@@ -155,7 +165,7 @@
- [@ohos.telephony.sim](js-apis-sim.md) - [@ohos.telephony.sim](js-apis-sim.md)
- [@ohos.telephony.sms](js-apis-sms.md) - [@ohos.telephony.sms](js-apis-sms.md)
- [@ohos.telephony.data](js-apis-telephony-data.md) - [@ohos.telephony.data](js-apis-telephony-data.md)
- Network Management - Network Management
- [@ohos.net.connection](js-apis-net-connection.md) - [@ohos.net.connection](js-apis-net-connection.md)
...@@ -163,7 +173,7 @@ ...@@ -163,7 +173,7 @@
- [@ohos.request](js-apis-request.md) - [@ohos.request](js-apis-request.md)
- [@ohos.net.socket](js-apis-socket.md) - [@ohos.net.socket](js-apis-socket.md)
- [@ohos.net.webSocket](js-apis-webSocket.md) - [@ohos.net.webSocket](js-apis-webSocket.md)
- Connectivity - Connectivity
- [@ohos.bluetooth](js-apis-bluetooth.md) - [@ohos.bluetooth](js-apis-bluetooth.md)
...@@ -174,7 +184,7 @@ ...@@ -174,7 +184,7 @@
- [@ohos.rpc](js-apis-rpc.md) - [@ohos.rpc](js-apis-rpc.md)
- [@ohos.wifi](js-apis-wifi.md) - [@ohos.wifi](js-apis-wifi.md)
- [@ohos.wifiext](js-apis-wifiext.md) - [@ohos.wifiext](js-apis-wifiext.md)
- Basic Features - Basic Features
- [@ohos.accessibility](js-apis-accessibility.md) - [@ohos.accessibility](js-apis-accessibility.md)
...@@ -193,7 +203,7 @@ ...@@ -193,7 +203,7 @@
- [@ohos.systemTime](js-apis-system-time.md) - [@ohos.systemTime](js-apis-system-time.md)
- [@ohos.wallpaper](js-apis-wallpaper.md) - [@ohos.wallpaper](js-apis-wallpaper.md)
- [Timer](js-apis-timer.md) - [Timer](js-apis-timer.md)
- Device Management - Device Management
- [@ohos.batteryInfo ](js-apis-battery-info.md) - [@ohos.batteryInfo ](js-apis-battery-info.md)
...@@ -219,13 +229,13 @@ ...@@ -219,13 +229,13 @@
- [@ohos.update](js-apis-update.md) - [@ohos.update](js-apis-update.md)
- [@ohos.usb](js-apis-usb.md) - [@ohos.usb](js-apis-usb.md)
- [@ohos.vibrator](js-apis-vibrator.md) - [@ohos.vibrator](js-apis-vibrator.md)
- Account Management - Account Management
- [@ohos.account.appAccount](js-apis-appAccount.md) - [@ohos.account.appAccount](js-apis-appAccount.md)
- [@ohos.account.distributedAccount](js-apis-distributed-account.md) - [@ohos.account.distributedAccount](js-apis-distributed-account.md)
- [@ohos.account.osAccount](js-apis-osAccount.md) - [@ohos.account.osAccount](js-apis-osAccount.md)
- Language Base Class Library - Language Base Class Library
- [@ohos.convertxml](js-apis-convertxml.md) - [@ohos.convertxml](js-apis-convertxml.md)
...@@ -249,12 +259,12 @@ ...@@ -249,12 +259,12 @@
- [@ohos.util.Vector](js-apis-vector.md) - [@ohos.util.Vector](js-apis-vector.md)
- [@ohos.worker](js-apis-worker.md) - [@ohos.worker](js-apis-worker.md)
- [@ohos.xml](js-apis-xml.md) - [@ohos.xml](js-apis-xml.md)
- Test - Test
- [@ohos.application.testRunner](js-apis-testRunner.md) - [@ohos.application.testRunner](js-apis-testRunner.md)
- [@ohos.uitest](js-apis-uitest.md) - [@ohos.uitest](js-apis-uitest.md)
- APIs No Longer Maintained - APIs No Longer Maintained
- [@ohos.bytrace](js-apis-bytrace.md) - [@ohos.bytrace](js-apis-bytrace.md)
......
# EnvironmentCallback
The **EnvironmentCallback** module provides the **onConfigurationUpdated** API for the application context to listen for system environment changes.
> **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 APIs of this module can be used only in the stage model.
## Modules to Import
```js
import EnvironmentCallback from "@ohos.application.EnvironmentCallback";
```
## EnvironmentCallback.onConfigurationUpdated
onConfigurationUpdated(config: Configuration): void;
Called when the system environment changes.
**System capability**: SystemCapability.Ability.AbilityRuntime.AbilityCore
**Parameters**
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| config | [Configuration](js-apis-configuration.md) | Yes| **Configuration** object after the change.|
**Example**
```js
import AbilityStage from "@ohos.application.AbilityStage";
var callbackId;
export default class MyAbilityStage extends AbilityStage {
onCreate() {
console.log("MyAbilityStage onCreate")
globalThis.applicationContext = this.context.getApplicationContext();
let EnvironmentCallback = {
onConfigurationUpdated(config){
console.log("onConfigurationUpdated config:" + JSON.stringify(config));
},
}
// 1. Obtain an applicationContext object.
let applicationContext = globalThis.applicationContext;
// 2. Register a listener for the environment changes through the applicationContext object.
callbackId = applicationContext.registerEnvironmentCallback(EnvironmentCallback);
console.log("registerEnvironmentCallback number: " + JSON.stringify(callbackId));
}
onDestroy() {
let applicationContext = globalThis.applicationContext;
applicationContext.unregisterEnvironmentCallback(callbackId, (error, data) => {
console.log("unregisterEnvironmentCallback success, err: " + JSON.stringify(error));
});
}
}
```
# AbilityManager
The **AbilityManager** module provides APIs for obtaining, adding, and modifying ability running information and state information.
> **NOTE**
>
> The initial APIs of this module are supported since API version 8. Newly added APIs will be marked with a superscript to indicate their earliest API version.
> The APIs of this module are system APIs and cannot be called by third-party applications.
# Modules to Import
```js
import AbilityManager from '@ohos.application.abilityManager'
```
## AbilityState
Enumerates the ability states.
**System capability**: SystemCapability.Ability.AbilityRuntime.Core
| Name| Value| Description|
| -------- | -------- | -------- |
| INITIAL | 0 | The ability is in the initial state.|
| FOREGROUND | 9 | The ability is in the foreground state. |
| BACKGROUND | 10 | The ability is in the background state. |
| FOREGROUNDING | 11 | The ability is in the foregrounding state. |
| BACKGROUNDING | 12 | The ability is in the backgrounding state. |
## updateConfiguration
updateConfiguration(config: Configuration, callback: AsyncCallback\<void>): void
Updates the configuration. This API uses an asynchronous callback to return the result.
**Permission required**: ohos.permission.UPDATE_CONFIGURATION
**System capability**: SystemCapability.Ability.AbilityRuntime.Core
**Parameters**
| Name | Type | Mandatory | Description |
| --------- | ---------------------------------------- | ---- | -------------- |
| config | Configuration | Yes | New configuration.|
| callback | AsyncCallback\<void> | Yes | Callback used to return the result. |
**Example**
```js
import abilitymanager from '@ohos.application.abilityManager';
var config = {
language: 'chinese'
}
abilitymanager.updateConfiguration(config, () => {
console.log('------------ updateConfiguration -----------');
})
```
## updateConfiguration
updateConfiguration(config: Configuration): Promise\<void>
Updates the configuration. This API uses a promise to return the result.
**Permission required**: ohos.permission.UPDATE_CONFIGURATION
**System capability**: SystemCapability.Ability.AbilityRuntime.Core
**Parameters**
| Name | Type | Mandatory | Description |
| --------- | ---------------------------------------- | ---- | -------------- |
| config | Configuration | Yes | New configuration.|
**Return value**
| Type | Description |
| ---------------------------------------- | ------- |
| Promise\<void> | Promise used to return the result.|
**Example**
```js
import abilitymanager from '@ohos.application.abilityManager';
var config = {
language: 'chinese'
}
abilitymanager.updateConfiguration(config).then(() => {
console.log('updateConfiguration success');
}).catch((err) => {
console.log('updateConfiguration fail');
})
```
## getAbilityRunningInfos
getAbilityRunningInfos(callback: AsyncCallback\<Array\<AbilityRunningInfo>>): void
Obtains the ability running information. This API uses an asynchronous callback to return the result.
**Required permissions**: ohos.permission.GET_RUNNING_INFO
**System capability**: SystemCapability.Ability.AbilityRuntime.Core
**Parameters**
| Name | Type | Mandatory | Description |
| --------- | ---------------------------------------- | ---- | -------------- |
| callback | AsyncCallback\<Array\<AbilityRunningInfo>> | Yes | Callback used to return the result. |
**Example**
```js
import abilitymanager from '@ohos.application.abilityManager';
abilitymanager.getAbilityRunningInfos((err,data) => {
console.log("getAbilityRunningInfos err: " + err + " data: " + JSON.stringify(data));
});
```
## getAbilityRunningInfos
getAbilityRunningInfos(): Promise\<Array\<AbilityRunningInfo>>
Obtains the ability running information. This API uses a promise to return the result.
**Required permissions**: ohos.permission.GET_RUNNING_INFO
**System capability**: SystemCapability.Ability.AbilityRuntime.Core
**Return value**
| Type | Description |
| ---------------------------------------- | ------- |
| Promise\<Array\<AbilityRunningInfo>> | Promise used to return the result.|
**Example**
```js
import abilitymanager from '@ohos.application.abilityManager';
abilitymanager.getAbilityRunningInfos().then((data) => {
console.log("getAbilityRunningInfos data: " + JSON.stringify(data))
}).catch((err) => {
console.log("getAbilityRunningInfos err: " + err)
});
```
## getExtensionRunningInfos<sup>9+</sup>
getExtensionRunningInfos(upperLimit: number, callback: AsyncCallback\<Array\<ExtensionRunningInfo>>): void
Obtains the extension running information. This API uses an asynchronous callback to return the result.
**Required permissions**: ohos.permission.GET_RUNNING_INFO
**System capability**: SystemCapability.Ability.AbilityRuntime.Core
**Parameters**
| Name | Type | Mandatory | Description |
| --------- | ---------------------------------------- | ---- | -------------- |
| upperLimit | number | Yes| Maximum number of messages that can be obtained.|
| callback | AsyncCallback\<Array\<AbilityRunningInfo>> | Yes | Callback used to return the result. |
**Example**
```js
import abilitymanager from '@ohos.application.abilityManager';
var upperLimit = 0;
abilitymanager.getExtensionRunningInfos(upperLimit, (err,data) => {
console.log("getExtensionRunningInfos err: " + err + " data: " + JSON.stringify(data));
});
```
## getExtensionRunningInfos<sup>9+</sup>
getExtensionRunningInfos(upperLimit: number): Promise\<Array\<ExtensionRunningInfo>>
Obtains the extension running information. This API uses a promise to return the result.
**Required permissions**: ohos.permission.GET_RUNNING_INFO
**System capability**: SystemCapability.Ability.AbilityRuntime.Core
**Parameters**
| Name | Type | Mandatory | Description |
| --------- | ---------------------------------------- | ---- | -------------- |
| upperLimit | number | Yes| Maximum number of messages that can be obtained.|
**Return value**
| Type | Description |
| ---------------------------------------- | ------- |
| Promise\<Array\<AbilityRunningInfo>> | Promise used to return the result.|
**Example**
```js
import abilitymanager from '@ohos.application.abilityManager';
var upperLimit = 0;
abilitymanager.getExtensionRunningInfos(upperLimit).then((data) => {
console.log("getAbilityRunningInfos data: " + JSON.stringify(data));
}).catch((err) => {
console.log("getAbilityRunningInfos err: " + err);
})
```
## getTopAbility<sup>9+</sup>
getTopAbility(callback: AsyncCallback\<ElementName>): void;
Obtains the top ability, which is the ability that has the window focus. This API uses an asynchronous callback to return the result.
**System capability**: SystemCapability.Ability.AbilityRuntime.Core
**Parameters**
| Name | Type | Mandatory | Description |
| --------- | ---------------------------------------- | ---- | -------------- |
| callback | AsyncCallback\<ElementName> | Yes | Callback used to return the result. |
**Example**
```js
import abilitymanager from '@ohos.application.abilityManager';
abilitymanager.getTopAbility((err,data) => {
console.log("getTopAbility err: " + err + " data: " + JSON.stringify(data));
});
```
## getTopAbility<sup>9+</sup>
getTopAbility(): Promise\<ElementName>;
Obtains the top ability, which is the ability that has the window focus. This API uses a promise to return the result.
**System capability**: SystemCapability.Ability.AbilityRuntime.Core
**Return value**
| Type | Description |
| ---------------------------------------- | ------- |
| Promise\<ElementName>| Promise used to return the result.|
**Example**
```js
import abilitymanager from '@ohos.application.abilityManager';
abilitymanager.getTopAbility().then((data) => {
console.log("getTopAbility data: " + JSON.stringify(data));
}).catch((err) => {
console.log("getTopAbility err: " + err);
})
```
# ContinuationExtraParams
The **ContinuationExtraParams** module provides the extra parameters required by the device manager in the continuation management entry.
> **NOTE**
>
> The initial APIs of this module are supported since API version 8. Newly added APIs will be marked with a superscript to indicate their earliest API version.
## ContinuationExtraParams
Describes the extra parameters required by the device selection module in the continuation management entry.
**System capability**: SystemCapability.Ability.DistributedAbilityManager
| Name| Type| Readable| Writable| Description|
| -------- | -------- | -------- | -------- | -------- |
| deviceType | Array\<string> | Yes| Yes| Device type.|
| targetBundle | string | Yes| Yes| Target bundle name.|
| description | string | Yes| Yes| Device filtering description.|
| filter | any | Yes| Yes| Device filtering parameter.|
| continuationMode | [ContinuationMode](js-apis-continuation-continuationManager.md#continuationmode) | Yes| Yes| Continuation mode.|
| authInfo | { [key: string]: any } | Yes| Yes| Authentication information.|
# continuationManager
The **continuationManager** module provides the continuation management entry. You can use the APIs of this module to connect to and cancel the continuation management service, subscribe to and unsubscribe from device connection events, start the device selection module, and update the device connection state.
Currently, this module provides incomplete functions, and its APIs are mainly used to start the device selection module. **The continuation capability is not available for application development.**
> **NOTE**
>
> The initial APIs of this module are supported since API version 8. Newly added APIs will be marked with a superscript to indicate their earliest API version.
## Modules to Import
```js
import continuationManager from '@ohos.continuation.continuationManager'
```
## continuationManager.register
register(callback: AsyncCallback\<number>): void;
Registers the continuation management service and obtains a token. This API does not involve any filter parameters and uses an asynchronous callback to return the result.
**System capability**: SystemCapability.Ability.DistributedAbilityManager
**Parameters**
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| callback | AsyncCallback\<number> | Yes| Callback used to return the token generated after the continuation management service is connected.|
**Example**
```js
let token = -1;
continuationManager.register((err, data) => {
if (err.code != 0) {
console.error('register failed, cause: ' + JSON.stringify(err));
return;
}
console.info('register finished, ' + JSON.stringify(data));
token = data;
});
```
## continuationManager.register
register(options: ContinuationExtraParams, callback: AsyncCallback\<number>): void;
Registers the continuation management service and obtains a token. This API uses an asynchronous callback to return the result.
**System capability**: SystemCapability.Ability.DistributedAbilityManager
**Parameters**
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| options | [ContinuationExtraParams](js-apis-continuation-continuationExtraParams.md) | Yes| Extra parameters used to filter the list of available devices.|
| callback | AsyncCallback\<number> | Yes| Callback used to return the token generated after the continuation management service is connected.|
**Example**
```js
let token = -1;
let continuationExtraParams = {
deviceType: ["00E"]
};
continuationManager.register(continuationExtraParams, (err, data) => {
if (err.code != 0) {
console.error('register failed, cause: ' + JSON.stringify(err));
return;
}
console.info('register finished, ' + JSON.stringify(data));
token = data;
});
```
## continuationManager.register
register(options?: ContinuationExtraParams): Promise\<number>;
Registers the continuation management service and obtains a token. This API uses a promise to return the result.
**System capability**: SystemCapability.Ability.DistributedAbilityManager
**Parameters**
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| options | [ContinuationExtraParams](js-apis-continuation-continuationExtraParams.md) | No| Extra parameters used to filter the list of available devices. This parameter can be null.|
**Return value**
| Type | Description |
| ------------------------- | ------------------ |
| Promise\<number> | Promise used to return the token generated after the continuation management service is connected.|
**Example**
```js
let token = -1;
let continuationExtraParams = {
deviceType: ["00E"]
};
continuationManager.register(continuationExtraParams)
.then((data) => {
console.info('register finished, ' + JSON.stringify(data));
token = data;
})
.catch((err) => {
console.error('register failed, cause: ' + JSON.stringify(err));
});
```
## continuationManager.on("deviceConnect")<sup>(deprecated)</sup>
> This API is deprecated since API version 9. You are advised to use [on](#continuationmanagerondeviceconnect) instead.
on(type: "deviceConnect", callback: Callback\<ContinuationResult>): void;
Subscribes to device connection events. This API uses an asynchronous callback to return the result.
## continuationManager.on("deviceDisconnect")<sup>(deprecated)</sup>
> This API is deprecated since API version 9. You are advised to use [on](#continuationmanagerondevicedisconnect) instead.
on(type: "deviceDisconnect", callback: Callback\<string>): void;
Subscribes to device disconnection events. This API uses an asynchronous callback to return the result.
## continuationManager.off("deviceConnect")<sup>(deprecated)</sup>
> This API is deprecated since API version 9. You are advised to use [off](#continuationmanageroffdeviceconnect) instead.
off(type: "deviceConnect", callback?: Callback\<ContinuationResult>): void;
Unsubscribes from device connection events. This API uses an asynchronous callback to return the result.
## continuationManager.off("deviceDisconnect")<sup>(deprecated)</sup>
> This API is deprecated since API version 9. You are advised to use [off](#continuationmanageroffdevicedisconnect) instead.
off(type: "deviceDisconnect", callback?: Callback\<string>): void;
Unsubscribes from device disconnection events. This API uses an asynchronous callback to return the result.
## continuationManager.on("deviceConnect")<sup>9+</sup>
on(type: "deviceConnect", token: number, callback: Callback\<Array\<ContinuationResult>>): void;
Subscribes to device connection events. This API uses an asynchronous callback to return the result.
**System capability**: SystemCapability.Ability.DistributedAbilityManager
**Parameters**
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| type | string | Yes| Event type. The value is fixed at **deviceConnect**.|
| token | number | Yes| Token obtained after the registration of the continuation management service.|
| callback | Callback\<Array\<[ContinuationResult](js-apis-continuation-continuationResult.md)>> | Yes| Callback invoked when a device is selected from the device list provided by the device selection module. This callback returns the device ID, type, and name.|
**Example**
```js
let token = 1;
continuationManager.on("deviceConnect", token, (data) => {
console.info('onDeviceConnect len: ' + data.length);
for (let i = 0; i < data.length; i++) {
console.info('onDeviceConnect deviceId: ' + JSON.stringify(data[i].id));
console.info('onDeviceConnect deviceType: ' + JSON.stringify(data[i].type));
console.info('onDeviceConnect deviceName: ' + JSON.stringify(data[i].name));
}
});
```
## continuationManager.on("deviceDisconnect")<sup>9+</sup>
on(type: "deviceDisconnect", token: number, callback: Callback\<Array\<string>>): void;
Subscribes to device disconnection events. This API uses an asynchronous callback to return the result.
**System capability**: SystemCapability.Ability.DistributedAbilityManager
**Parameters**
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| type | string | Yes| Event type. The value is fixed at **deviceDisconnect**.|
| token | number | Yes| Token obtained after the registration of the continuation management service.|
| callback | Callback\<Array\<string>> | Yes| Callback invoked when a device is disconnected in the device selection module. This callback returns the device ID.|
**Example**
```js
let token = 1;
continuationManager.on("deviceDisconnect", token, (data) => {
console.info('onDeviceDisconnect len: ' + data.length);
for (let i = 0; i < data.length; i++) {
console.info('onDeviceDisconnect deviceId: ' + JSON.stringify(data[i]));
}
console.info('onDeviceDisconnect finished.');
});
```
## continuationManager.off("deviceConnect")<sup>9+</sup>
off(type: "deviceConnect", token: number): void;
Unsubscribes from device connection events.
**System capability**: SystemCapability.Ability.DistributedAbilityManager
**Parameters**
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| type | string | Yes| Event type. The value is fixed at **deviceConnect**.|
| token | number | Yes| Token obtained after the registration of the continuation management service.|
**Example**
```js
let token = 1;
continuationManager.off("deviceConnect", token);
```
## continuationManager.off("deviceDisconnect")<sup>9+</sup>
off(type: "deviceDisconnect", token: number): void;
Unsubscribes from device disconnection events.
**System capability**: SystemCapability.Ability.DistributedAbilityManager
**Parameters**
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| type | string | Yes| Event type. The value is fixed at **deviceDisconnect**.|
| token | number | Yes| Token obtained after the registration of the continuation management service.|
**Example**
```js
let token = 1;
continuationManager.off("deviceDisconnect", token);
```
## continuationManager.startDeviceManager
startDeviceManager(token: number, callback: AsyncCallback\<void>): void;
Starts the device selection module to show the list of available devices on the network. This API does not involve any filter parameters and uses an asynchronous callback to return the result.
**System capability**: SystemCapability.Ability.DistributedAbilityManager
**Parameters**
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| token | number | Yes| Token obtained after the registration of the continuation management service.|
| callback | AsyncCallback\<void> | Yes| Callback used to return the result.|
**Example**
```js
let token = 1;
continuationManager.startDeviceManager(token, (err, data) => {
if (err.code != 0) {
console.error('startDeviceManager failed, cause: ' + JSON.stringify(err));
return;
}
console.info('startDeviceManager finished, ' + JSON.stringify(data));
});
```
## continuationManager.startDeviceManager
startDeviceManager(token: number, options: ContinuationExtraParams, callback: AsyncCallback\<void>): void;
Starts the device selection module to show the list of available devices on the network. This API uses an asynchronous callback to return the result.
**System capability**: SystemCapability.Ability.DistributedAbilityManager
**Parameters**
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| token | number | Yes| Token obtained after the registration of the continuation management service.|
| options | [ContinuationExtraParams](js-apis-continuation-continuationExtraParams.md) | Yes| Extra parameters used to filter the list of available devices.|
| callback | AsyncCallback\<void> | Yes| Callback used to return the result.|
**Example**
```js
let token = 1;
let continuationExtraParams = {
deviceType: ["00E"]
};
continuationManager.startDeviceManager(token, continuationExtraParams, (err, data) => {
if (err.code != 0) {
console.error('startDeviceManager failed, cause: ' + JSON.stringify(err));
return;
}
console.info('startDeviceManager finished, ' + JSON.stringify(data));
});
```
## continuationManager.startDeviceManager
startDeviceManager(token: number, options?: ContinuationExtraParams): Promise\<void>;
Starts the device selection module to show the list of available devices on the network. This API uses a promise to return the result.
**System capability**: SystemCapability.Ability.DistributedAbilityManager
**Parameters**
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| token | number | Yes| Token obtained after the registration of the continuation management service.|
| options | [ContinuationExtraParams](js-apis-continuation-continuationExtraParams.md) | No| Extra parameters used to filter the list of available devices. This parameter can be null.|
**Return value**
| Type | Description |
| ------------------------- | ------------------ |
| Promise\<void> | Promise used to return the result.|
**Example**
```js
let token = 1;
let continuationExtraParams = {
deviceType: ["00E"]
};
continuationManager.startDeviceManager(token, continuationExtraParams)
.then((data) => {
console.info('startDeviceManager finished, ' + JSON.stringify(data));
})
.catch((err) => {
console.error('startDeviceManager failed, cause: ' + JSON.stringify(err));
});
```
## continuationManager.updateConnectStatus
updateConnectStatus(token: number, deviceId: string, status: DeviceConnectState, callback: AsyncCallback\<void>): void;
Instructs the device selection module to update the device connection state. This API uses an asynchronous callback to return the result.
**System capability**: SystemCapability.Ability.DistributedAbilityManager
**Parameters**
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| token | number | Yes| Token obtained after the registration of the continuation management service.|
| deviceId | string | Yes| Device ID.|
| status | [DeviceConnectState](#deviceconnectstate) | Yes| Device connection state.|
| callback | AsyncCallback\<void> | Yes| Callback used to return the result.|
**Example**
```js
let token = 1;
let deviceId: string = "test deviceId";
continuationManager.updateConnectStatus(token, deviceId, continuationManager.DeviceConnectState.CONNECTED, (err, data) => {
if (err.code != 0) {
console.error('updateConnectStatus failed, cause: ' + JSON.stringify(err));
return;
}
console.info('updateConnectStatus finished, ' + JSON.stringify(data));
});
```
## continuationManager.updateConnectStatus
updateConnectStatus(token: number, deviceId: string, status: DeviceConnectState): Promise\<void>;
Instructs the device selection module to update the device connection state. This API uses a promise to return the result.
**System capability**: SystemCapability.Ability.DistributedAbilityManager
**Parameters**
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| token | number | Yes| Token obtained after the registration of the continuation management service.|
| deviceId | string | Yes| Device ID.|
| status | [DeviceConnectState](#deviceconnectstate) | Yes| Device connection state.|
**Return value**
| Type | Description |
| ------------------------- | ------------------ |
| Promise\<void> | Promise used to return the result.|
**Example**
```js
let token = 1;
let deviceId: string = "test deviceId";
continuationManager.updateConnectStatus(token, deviceId, continuationManager.DeviceConnectState.CONNECTED)
.then((data) => {
console.info('updateConnectStatus finished, ' + JSON.stringify(data));
})
.catch((err) => {
console.error('updateConnectStatus failed, cause: ' + JSON.stringify(err));
});
```
## continuationManager.unregister
unregister(token: number, callback: AsyncCallback\<void>): void;
Deregisters the continuation management service. This API uses an asynchronous callback to return the result.
**System capability**: SystemCapability.Ability.DistributedAbilityManager
**Parameters**
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| token | number | Yes| Token obtained after the registration of the continuation management service.|
| callback | AsyncCallback\<void> | Yes| Callback used to return the result.|
**Example**
```js
let token = 1;
continuationManager.unregister(token, (err, data) => {
if (err.code != 0) {
console.error('unregister failed, cause: ' + JSON.stringify(err));
return;
}
console.info('unregister finished, ' + JSON.stringify(data));
});
```
## continuationManager.unregister
unregister(token: number): Promise\<void>;
Deregisters the continuation management service. This API uses a promise to return the result.
**System capability**: SystemCapability.Ability.DistributedAbilityManager
**Parameters**
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| token | number | Yes| Token obtained after the registration of the continuation management service.|
**Return value**
| Type | Description |
| ------------------------- | ------------------ |
| Promise\<void> | Promise used to return the result.|
**Example**
```js
let token = 1;
continuationManager.unregister(token)
.then((data) => {
console.info('unregister finished, ' + JSON.stringify(data));
})
.catch((err) => {
console.error('unregister failed, cause: ' + JSON.stringify(err));
});
```
## DeviceConnectState
Enumerates the device connection states.
**System capability**: SystemCapability.Ability.DistributedAbilityManager
**Parameters**
| Name| Type| Value| Description|
| -------- | -------- | -------- | -------- |
| IDLE | number | 0 | The device is in the initial state.|
| CONNECTING | number | 1 | The device is being connected.|
| CONNECTED | number | 2 | The device is connected.|
| DISCONNECTING | number | 3 | The device is being disconnected.|
## ContinuationMode
Enumerates the continuation modes provided by the device selection module.
**System capability**: SystemCapability.Ability.DistributedAbilityManager
**Parameters**
| Name| Type| Value| Description|
| -------- | -------- | -------- | -------- |
| COLLABORATION_SINGLE | number | 0 | Single-choice mode.|
| COLLABORATION_MULTIPLE | number | 1 | Multi-choice mode.|
# ContinuationResult
> **NOTE**
>
> The initial APIs of this module are supported since API version 8. Newly added APIs will be marked with a superscript to indicate their earliest API version.
## ContinuationResult
Describes the device information returned by the continuation management entry.
**System capability**: SystemCapability.Ability.DistributedAbilityManager
| Name| Type| Readable| Writable| Description|
| -------- | -------- | -------- | -------- | -------- |
| id | string | Yes| Yes| Device ID.|
| type | string | Yes| Yes| Device type.|
| name | string | Yes| Yes| Device name.|
# Image Effect
The **EffectKit** module provides basic image processing capabilities, including brightness adjustment, blurring, grayscale adjustment, and color picker.
This module provides the following classes:
- [Filter](#filter): a class that provides the effect chain.
- [Color](#color): a class used to store the color picked.
- [ColorPicker](#colorpicker): a smart color picker.
> **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.
## Modules to Import
```js
import effectKit from '@ohos.effectKit';
```
## effectKit.createEffect
createEffect(source: image.PixelMap): Filter
Creates a **Filter** instance based on the pixel map.
**System capability**: SystemCapability.Multimedia.Image.Core
**Parameters**
| Name | Type | Mandatory| Description |
| ------- | ----------------- | ---- | -------- |
| source | [image.PixelMap](js-apis-image.md#pixelmap7) | Yes | **PixelMap** instance created by the image module. |
**Return value**
| Type | Description |
| -------------------------------- | -------------- |
| [Filter](#filter) | Head node of the filter linked list without any effect. If the operation fails, **null** is returned.|
**Example**
```js
import image from "@ohos.multimedia.image"
const color = new ArrayBuffer(96);
let opts = { editable: true, pixelFormat: 3, size: { height: 4, width: 6 } };
image.createPixelMap(color, opts)
.then((pixelMap) => {
let headFilter = effectKit.createEffect(pixelMap)
})
```
## effectKit.createColorPicker
createColorPicker(source: image.PixelMap): Promise\<ColorPicker>
Creates a **ColorPicker** instance based on the pixel map. This API uses a promise to return the result.
**System capability**: SystemCapability.Multimedia.Image.Core
**Parameters**
| Name | Type | Mandatory| Description |
| -------- | ----------- | ---- | -------------------------- |
| source | [image.PixelMap](js-apis-image.md#pixelmap7) | Yes | **PixelMap** instance created by the image module.|
**Return value**
| Type | Description |
| ---------------------- | -------------- |
| Promisse\<[ColorPicker](#colorpicker)> | Promise used to return the **ColorPicker** instance created.|
**Example**
```js
import image from "@ohos.multimedia.image"
const color = new ArrayBuffer(96);
let opts = { editable: true, pixelFormat: 3, size: { height: 4, width: 6 } };
image.createPixelMap(color, opts, (pixelMap) => {
effectKit.createColorPicker(pixelMap).then(colorPicker => {
console.info("color picker=" + colorPicker);
})
.catch(ex => console.error(".error=" + ex.toString()))
})
```
## effectKit.createColorPicker
createColorPicker(source: image.PixelMap, callback: AsyncCallback\<ColorPicker>): void
Creates a **ColorPicker** instance based on the pixel map. This API uses an asynchronous callback to return the result.
**System capability**: SystemCapability.Multimedia.Image.Core
**Parameters**
| Name | Type | Mandatory| Description |
| -------- | ------------------ | ---- | -------------------------- |
| source | [image.PixelMap](js-apis-image.md#pixelmap7) | Yes |**PixelMap** instance created by the image module. |
| callback | AsyncCallback\<[ColorPicker](#colorpicker)> | Yes | Callback used to return the **ColorPicker** instance created.|
**Example**
```js
import image from "@ohos.multimedia.image"
const color = new ArrayBuffer(96);
let opts = { editable: true, pixelFormat: 3, size: { height: 4, width: 6 } };
image.createPixelMap(color, opts, (pixelMap) => {
effectKit.createColorPicker(pixelMap, (error, colorPicker) => {
if(error) {
console.log('Failed to create color picker.');
} else {
console.log('Succeeded in creating color picker.');
}
})
})
```
## Color
A class that stores the color picked.
**System capability**: SystemCapability.Multimedia.Image.Core
| Name | Type | Readable| Writable| Description |
| ------ | ----- | ---- | ---- | ---------------- |
| red | number | Yes | No | Value of the red component. |
| green | number | Yes | No | Value of the green component. |
| blue | number | Yes | No | Value of the blue component. |
| alpha | number | Yes | No | Value of the alpha component. |
## ColorPicker
A class used to obtain the main color of an image from its data. Before calling any method of **ColorPicker**, use [createColorPicker](#effectkitcreatecolorpicker) to create a **ColorPicker** instance.
### getMainColor
getMainColor(): Promise\<Color>
Obtains the main color of the image and writes the result to a **[Color](#color)** instance. This API uses a promise to return the result.
**System capability**: SystemCapability.Multimedia.Image.Core
**Return value**
| Type | Description |
| :------------- | :---------------------------------------------- |
| Promise\<[Color](#color)> | Promise used to return the color value of the main color. If the operation fails, an error message is returned.|
**Example**
```js
colorPicker.getMainColor().then(color => {
console.log('Succeeded in getting main color.')
console.info("color[ARGB]=" + color.alpha + "," + color.red + "," + color.green + "," + color.blue);
}).catch(error => {
console.log('Failed to get main color.');
})
```
### getMainColorSync
getMainColorSync(): Color
Obtains the main color of the image and writes the result to a **[Color](#color)** instance. This API returns the result in synchronous mode.
**System capability**: SystemCapability.Multimedia.Image.Core
**Return value**
| Type | Description |
| :------- | :----------------------------------- |
| [Color](#color) | Color value of the main color. If the operation fails, **null** is returned.|
**Example**
```js
let color = colorPicker.getMainColorSync();
console.log('get main color =' + color);
```
## Filter
A class used to add a specified effect to an image. Before calling any method of **Filter**, use [createEffect](#effectkitcreateeffect) to create a **Filter** instance.
### blur
blur(radius: number): Filter
Adds the blur effect to the filter linked list, and returns the head node of the linked list.
**System capability**: SystemCapability.Multimedia.Image.Core
**Parameters**
| Name| Type | Mandatory| Description |
| ------ | ----------- | ---- | ------------------------------------------------------------ |
| radius | number | Yes | Blur radius, in pixels. The blur effect is proportional to the configured value. A larger value indicates a more obvious effect.|
**Return value**
| Type | Description |
| :------------- | :---------------------------------------------- |
| [Filter](#filter) | Head node of the filter linked list.|
**Example**
```js
import image from "@ohos.multimedia.image"
const color = new ArrayBuffer(96);
let opts = { editable: true, pixelFormat: 3, size: { height: 4, width: 6 } };
image.createPixelMap(color, opts)
.then((pixelMap) => {
let radius = 5;
let headFilter = effectKit.createEffect(pixelMap)
if (headFilter != null) {
headFilter.blur(radius)
}
})
```
### brightness
brightness(bright: number): Filter
Adds the brightness effect to the filter linked list, and returns the head node of the linked list.
**System capability**: SystemCapability.Multimedia.Image.Core
**Parameters**
| Name| Type | Mandatory| Description |
| ------ | ----------- | ---- | ------------------------------------------------------------ |
| bright | number | Yes | Brightness value, ranging from 0 to 1. When the value is **0**, the image brightness remains unchanged.|
**Return value**
| Type | Description |
| :------------- | :---------------------------------------------- |
| [Filter](#filter) | Head node of the filter linked list.|
**Example**
```js
import image from "@ohos.multimedia.image"
const color = new ArrayBuffer(96);
let opts = { editable: true, pixelFormat: 3, size: { height: 4, width: 6 } };
image.createPixelMap(color, opts)
.then((pixelMap) => {
let bright = 0.5;
let headFilter = effectKit.createEffect(pixelMap)
if (headFilter != null) {
headFilter.brightness(bright)
}
})
```
### grayscale
grayscale(): Filter
Adds the grayscale effect to the filter linked list, and returns the head node of the linked list.
**System capability**: SystemCapability.Multimedia.Image.Core
**Return value**
| Type | Description |
| :------------- | :---------------------------------------------- |
| [Filter](#filter) | Head node of the filter linked list.|
**Example**
```js
import image from "@ohos.multimedia.image"
const color = new ArrayBuffer(96);
let opts = { editable: true, pixelFormat: 3, size: { height: 4, width: 6 } };
image.createPixelMap(color, opts)
.then((pixelMap) => {
let headFilter = effectKit.createEffect(pixelMap)
if (headFilter != null) {
headFilter.grayscale()
}
})
```
### getPixelMap
getPixelMap(): image.PixelMap
Obtains **image.PixelMap** of the source image to which the filter linked list is added.
**System capability**: SystemCapability.Multimedia.Image.Core
**Return value**
| Type | Description |
| :------------- | :---------------------------------------------- |
| [image.PixelMap](js-apis-image.md#pixelmap7) | **image.PixelMap** of the source image.|
**Example**
```js
import image from "@ohos.multimedia.image"
const color = new ArrayBuffer(96);
let opts = { editable: true, pixelFormat: 3, size: { height: 4, width: 6 } };
image.createPixelMap(color, opts)
.then((pixelMap) => {
let pixel = effectKit.createEffect(pixelMap).grayscale().getPixelMap()
})
```
# Screen
The **Screen** module implements basic screen management. You can use the APIs of this module to obtain a **Screen** object, listen for screen changes, and create and destroy virtual screens.
> **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 APIs provided by this module are system APIs.
## Modules to Import
```js
import screen from '@ohos.screen';
```
## screen.getAllScreens
getAllScreens(callback: AsyncCallback&lt;Array&lt;Screen&gt;&gt;): void
Obtains all screens. This API uses an asynchronous callback to return the result.
**System capability**: SystemCapability.WindowManager.WindowManager.Core
**Parameters**
| Name | Type | Mandatory| Description |
| -------- | --------------------------------------------------- | ---- | -------------------------------------- |
| callback | AsyncCallback&lt;Array&lt;[Screen](#screen)&gt;&gt; | Yes | Callback used to return all the **Screen** objects obtained.|
**Example**
```js
var screenClass = null;
screen.getAllScreens((err, data) => {
if (err.code) {
console.error('Failed to get all screens . Cause: ' + JSON.stringify(err));
return;
}
console.info('Succeeded in getting all screens . Data:' + JSON.stringify(data));
screenClass = data[0];
});
```
## screen.getAllScreens
getAllScreens(): Promise&lt;Array&lt;Screen&gt;&gt;
Obtains all screens. This API uses a promise to return the result.
**System capability**: SystemCapability.WindowManager.WindowManager.Core
**Return value**
| Type | Description |
| --------------------------------------------- | ----------------------------------------- |
| Promise&lt;Array&lt;[Screen](#screen)&gt;&gt; | Promise used to return all the **Screen** objects obtained.|
**Example**
```js
var screenClass = null;
let promise = screen.getAllScreens();
promise.then((data) => {
screenClass = data[0];
console.log('Succeeded in getting all screens . Data:'+ JSON.stringify(data));
}).catch((err) => {
console.log('Failed to get all screens . Cause: ' + JSON.stringify(err));
});
```
## screen.on('connect' | 'disconnect' | 'change')
on(eventType: 'connect' | 'disconnect' | 'change', callback: Callback&lt;number&gt;): void
Subscribes to events related to the screen state.
**System capability**: SystemCapability.WindowManager.WindowManager.Core
**Parameters**
| Name | Type | Mandatory| Description |
| --------- | ---------------------- | ---- | ------------------------------------------------------------ |
| eventType | string | Yes | Event type.<br>- **connect**: an event indicating that the screen is connected.<br>- **disconnect**: an event indicating that the screen is disconnected.<br>- **change**: an event indicating that the screen state changes.|
| callback | Callback&lt;number&gt; | Yes | Callback used to return the screen ID. |
**Example**
```js
var callback = (data) => {
console.info('Register the callback for screen changes. Data: ' + JSON.stringify(data))
};
screen.on("connect", callback);
```
## screen.off('connect' | 'disconnect' | 'change')
off(eventType: 'connect' | 'disconnect' | 'change', callback?: Callback&lt;number&gt;): void
Unsubscribes from events related to the screen state.
**System capability**: SystemCapability.WindowManager.WindowManager.Core
**Parameters**
| Name | Type | Mandatory| Description |
| --------- | ---------------------- | ---- | ------------------------------------------------------------ |
| eventType | string | Yes | Event type.<br>- **connect**: an event indicating that the screen is connected.<br>- **disconnect**: an event indicating that the screen is disconnected.<br>- **change**: an event indicating that the screen state changes.|
| callback | Callback&lt;number&gt; | No | Callback used to return the screen ID. |
**Example**
```js
var callback = (data) => {
console.info('Unegister the callback for screen changes. Data: ' + JSON.stringify(data))
};
screen.off("connect", callback);
```
## screen.makeExpand
makeExpand(options:Array&lt;ExpandOption&gt;, callback: AsyncCallback&lt;number&gt;): void
Sets the screen to the expanded mode. This API uses an asynchronous callback to return the result.
**System capability**: SystemCapability.WindowManager.WindowManager.Core
**Parameters**
| Name | Type | Mandatory| Description |
| -------- | ------------------------------------------ | ---- | -------------------------------- |
| options | Array&lt;[ExpandOption](#expandoption)&gt; | Yes | Parameters for expanding the screen. |
| callback | Callback&lt;number&gt; | Yes | Callback used to return the group ID of the expanded screens.|
**Example**
```js
var groupId = null;
screen.makeExpand([{screenId: 0, startX: 0, startY: 0}, {screenId: 1, startX: 1080, startY: 0}], (err, data) => {
if (err.code) {
console.error('Failed to make screens as expand-screen. Cause:' + JSON.stringify(err));
return;
}
groupId = data;
console.info('Succeeded in making screens as expand-screen.Data:' + JSON.stringify(data));
});
```
## screen.makeExpand
makeExpand(options:Array&lt;ExpandOption&gt;): Promise&lt;number&gt;
Sets the screen to the expanded mode. This API uses a promise to return the result.
**System capability**: SystemCapability.WindowManager.WindowManager.Core
**Parameters**
| Name | Type | Mandatory| Description |
| ------- | ------------------------------------------ | ---- | ------------------------ |
| options | Array&lt;[ExpandOption](#expandoption)&gt; | Yes | Parameters for expanding the screen.|
**Return value**
| Type | Description |
| --------------------- | ----------------------------------- |
| Promise&lt;number&gt; | Promise used to return the group ID of the expanded screens.|
**Example**
```js
screen.makeExpand([{screenId: 0, startX: 0, startY: 0}, {screenId: 1, startX: 1080, startY: 0}]).then((data) => {
console.info('Succeeded in making screens as expand-screen.Data:' + JSON.stringify(data));
}).catch((err) => {
console.error('Failed to make screens as expand-screen. Cause:' + JSON.stringify(err));
});
```
## screen.makeMirror
makeMirror(mainScreen:number, mirrorScreen:Array&lt;number&gt;, callback: AsyncCallback&lt;number&gt;): void
Sets screen mirroring. This API uses an asynchronous callback to return the result.
**System capability**: SystemCapability.WindowManager.WindowManager.Core
**Parameters**
| Name | Type | Mandatory| Description |
| ------------ | --------------------------- | ---- |-----------------|
| mainScreen | number | Yes | ID of the primary screen. |
| mirrorScreen | Array&lt;number&gt; | Yes | IDs of secondary screens. |
| callback | AsyncCallback&lt;number&gt; | Yes | Callback used to return the group ID of the secondary screens.|
**Example**
```js
var mainScreenId = 0;
var mirrorScreenIds = [1, 2, 3];
screen.makeMirror(mainScreenId, mirrorScreenIds, (err, data) => {
if (err.code) {
console.error('Failed to make screens as mirror-screen.Cause:' + JSON.stringify(err));
return;
}
console.info('Succeeded in making screens as mirror-screen.Data:' + JSON.stringify(data));
});
```
## screen.makeMirror
makeMirror(mainScreen:number, mirrorScreen:Array&lt;number&gt;): Promise&lt;number&gt;
Sets screen mirroring. This API uses a promise to return the result.
**System capability**: SystemCapability.WindowManager.WindowManager.Core
**Parameters**
| Name | Type | Mandatory| Description |
| ------------ | ------------------- | ---- |-----------|
| mainScreen | number | Yes | ID of the primary screen. |
| mirrorScreen | Array&lt;number&gt; | Yes | IDs of secondary screens.|
**Return value**
| Type | Description |
| --------------------- | ----------------------------------- |
| Promise&lt;number&gt; | Promise used to return the group ID of the secondary screens.|
**Example**
```js
var mainScreenId = 0;
var mirrorScreenIds = [1, 2, 3];
screen.makeMirror(mainScreenId, mirrorScreenIds).then((data) => {
console.info('Succeeded in making screens as mirror-screen.Data:' + JSON.stringify(data));
}).catch((err) => {
console.error('Failed to make screens as mirror-screen.Cause:' + JSON.stringify(err));
});
```
## screen.createVirtualScreen
createVirtualScreen(options:VirtualScreenOption, callback: AsyncCallback&lt;Screen&gt;): void
Creates a virtual screen. This API uses an asynchronous callback to return the result.
**System capability**: SystemCapability.WindowManager.WindowManager.Core
**Parameters**
| Name | Type | Mandatory| Description |
| -------- | ------------------------------------------- | ---- | ---------------------------------- |
| options | [VirtualScreenOption](#virtualscreenoption) | Yes | Virtual screen parameters. |
| callback | AsyncCallback&lt;[Screen](#screen)&gt; | Yes | Callback used to return the created virtual screen.|
**Example**
```js
var screenClass = null;
screen.createVirtualScreen({
name: 'screen01',
width: 1080,
height: 2340,
density: 2,
surfaceId: ''
}, (err, data) => {
if (err.code) {
console.error('Failed to create virtual screen.Cause:' + JSON.stringify(err));
return;
}
screenClass = data;
console.info('Succeeded in creating virtual screen.Data:' + JSON.stringify(data));
});
```
## screen.createVirtualScreen
createVirtualScreen(options:VirtualScreenOption): Promise&lt;Screen&gt;
Creates a virtual screen. This API uses a promise to return the result.
**System capability**: SystemCapability.WindowManager.WindowManager.Core
**Parameters**
| Name | Type | Mandatory| Description |
| ------- | ------------------------------------------- | ---- | ------------------------ |
| options | [VirtualScreenOption](#virtualscreenoption) | Yes | Virtual screen parameters.|
**Return value**
| Type | Description |
| -------------------------------- | ------------------------------------- |
| Promise&lt;[Screen](#screen)&gt; | Promise used to return the created virtual screen.|
**Example**
```js
var screenClass = null;
screen.createVirtualScreen({
name: 'screen01',
width: 1080,
height: 2340,
density: 2,
surfaceId: ''
}).then((data) => {
screenClass = data;
console.info('Succeeded in creating virtual screen.Data:' + JSON.stringify(data));
}).catch((err) => {
console.error('Failed to create virtual screen.Cause:' + JSON.stringify(err));
});
```
## screen.destroyVirtualScreen
destroyVirtualScreen(screenId:number, callback: AsyncCallback&lt;void&gt;): void
Destroys a virtual screen. This API uses an asynchronous callback to return the result.
**System capability**: SystemCapability.WindowManager.WindowManager.Core
**Parameters**
| Name | Type | Mandatory| Description |
| -------- | ------------------------- | ---- | ------------------------------------------------------------ |
| screenId | number | Yes | Screen ID. |
| callback | AsyncCallback&lt;void&gt; | Yes | Callback used to return the result. If the virtual screen is destroyed, **err** is **undefined**; otherwise, **err** is an error object.|
**Example**
```js
var screenId = 1;
screen.destroyVirtualScreen(screenId, (err,data) => {
if (err.code) {
console.error('Failed to destroy virtual screen.Cause:' + JSON.stringify(err));
return;
}
console.info('Succeeded in destroying virtual screen.');
});
```
## screen.destroyVirtualScreen
destroyVirtualScreen(screenId:number): Promise&lt;void&gt;
Destroys a virtual screen. This API uses a promise to return the result.
**System capability**: SystemCapability.WindowManager.WindowManager.Core
**Parameters**
| Name | Type | Mandatory| Description |
| -------- | ------ | ---- | ---------- |
| screenId | number | Yes | Screen ID.|
**Return value**
| Type | Description |
| ------------------- | ------------------------- |
| Promise&lt;void&gt; | Promise that returns no value.|
**Example**
```js
var screenId = 1;
screen.destroyVirtualScreen(screenId).then((data) => {
console.info('Succeeded in destroying virtual screen.');
}).catch((err) => {
console.error('Failed to destroy virtual screen.Cause:' + JSON.stringify(err));
});
```
## screen.setVirtualScreenSurface
setVirtualScreenSurface(screenId:number, surfaceId: string, callback: AsyncCallback&lt;void&gt;): void
Sets the surface for a virtual screen. This API uses an asynchronous callback to return the result.
**System capability**: SystemCapability.WindowManager.WindowManager.Core
**Parameters**
| Name | Type | Mandatory| Description |
| --------- | ------------------------- | ---- | ------------------------------------------------------------ |
| screenId | number | Yes | Screen ID. |
| surfaceId | string | Yes | Surface ID. |
| callback | AsyncCallback&lt;void&gt; | Yes | Callback used to return the result. If the virtual screen surface is successfully set, **err** is **undefined**; otherwise, **err** is an error object.|
**Example**
```js
var screenId = 1;
var surfaceId = '2048';
screen.setVirtualScreenSurface(screenId, surfaceId, (err,data) => {
if (err.code) {
console.error('Failed to set surface for the virtual screen. Cause:' + JSON.stringify(err));
return;
}
console.info('Succeeded in setting surface for the virtual screen.');
});
```
## screen.setVirtualScreenSurface
setVirtualScreenSurface(screenId:number, surfaceId: string): Promise&lt;void&gt;
Sets the surface for a virtual screen. This API uses a promise to return the result.
**System capability**: SystemCapability.WindowManager.WindowManager.Core
**Parameters**
| Name | Type | Mandatory| Description |
| --------- | ------ | ---- | ------------- |
| screenId | number | Yes | Screen ID. |
| surfaceId | string | Yes | Surface ID.|
**Return value**
| Type | Description |
| ------------------- | ------------------------- |
| Promise&lt;void&gt; | Promise that returns no value.|
**Example**
```js
var screenId = 1;
var surfaceId = '2048';
screen.setVirtualScreenSurface(screenId, surfaceId).then((data) => {
console.info('Succeeded in setting surface for the virtual screen.');
}).catch((err) => {
console.error('Failed to set surface for the virtual screen. Cause:' + JSON.stringify(err));
});
```
## screen.isScreenRotationLocked
isScreenRotationLocked(): Promise&lt;boolean&gt;
Checks whether auto rotate is locked. This API uses a promise to return the result.
**System capability**: SystemCapability.WindowManager.WindowManager.Core
**Return value**
| Type | Description |
| ---------------------- | ------------------------------------- |
| Promise&lt;boolean&gt; | Promise used to return the result. If **true** is returned, auto rotate is locked. If **false** is returned, auto rotate is unlocked.|
**Example**
```js
screen.isScreenRotationLocked().then((isLocked) => {
console.info('Succeeded in getting screen rotation lock status. isLocked:'+ JSON.stringify(isLocked));
}).catch((err) => {
console.error('Failed to get screen rotation lock status. Cause:' + JSON.stringify(err));
});
```
## screen.isScreenRotationLocked
isScreenRotationLocked(callback: AsyncCallback&lt;boolean&gt;): void
Checks whether auto rotate is locked. This API uses an asynchronous callback to return the result.
**System capability**: SystemCapability.WindowManager.WindowManager.Core
**Parameters**
| Name | Type | Mandatory| Description |
| --------- | ---------------------------- | ---- | ------------------------------------------------------------ |
| callback | AsyncCallback&lt;boolean&gt; | Yes | Callback used to return the result. If **true** is returned, auto rotate is locked. If **false** is returned, auto rotate is unlocked.|
**Example**
```js
screen.isScreenRotationLocked((err, isLocked) => {
if (err.code) {
console.error('Failed to get screen rotation lock status. Cause:' + JSON.stringify(err));
return;
}
console.info('Succeeded in getting screen rotation lock status. isLocked:' + JSON.stringify(isLocked));
});
```
## screen.setScreenRotationLocked
setScreenRotationLocked(isLocked: boolean): Promise&lt;void&gt;
Sets whether to lock auto rotate. This API uses a promise to return the result.
**System capability**: SystemCapability.WindowManager.WindowManager.Core
**Parameters**
| Name | Type | Mandatory| Description |
| --------- | ------ | ---- | ------------- |
| isLocked | boolean | Yes | Whether to lock auto rotate. The value **true** means to lock auto rotate, and **false** means the opposite.|
**Return value**
| Type | Description |
| ------------------- | ------------------------- |
| Promise&lt;void&gt; | Promise that returns no value.|
**Example**
```js
var isLocked = false;
screen.setScreenRotationLocked(isLocked).then((data) => {
console.info('Succeeded in setting whether to lock screen rotation');
}).catch((err) => {
console.error('Failed to set whether to lock screen rotation. Cause:' + JSON.stringify(err));
});
```
## screen.setScreenRotationLocked
setScreenRotationLocked(isLocked: boolean, callback: AsyncCallback&lt;void&gt;): void
Sets whether to lock auto rotate. This API uses an asynchronous callback to return the result.
**System capability**: SystemCapability.WindowManager.WindowManager.Core
**Parameters**
| Name | Type | Mandatory| Description |
| --------- | ------------------------- | ---- | ------------------------------------------------------------ |
| isLocked | boolean | Yes | Whether to lock auto rotate. The value **true** means to lock auto rotate, and **false** means the opposite. |
| callback | AsyncCallback&lt;void&gt; | Yes | Callback used to return the result. If the operation is successful, **err** is **undefined**; otherwise, **err** is an error object.|
**Example**
```js
var isLocked = false;
screen.setScreenRotationLocked(isLocked, (err, data) => {
if (err.code) {
console.error('Failed to set whether to lock screen rotation. Cause:' + JSON.stringify(err));
return;
}
console.info('Succeeded in setting whether to lock screen rotation.');
});
```
## ExpandOption
Defines the parameters for expanding a screen.
**System capability**: SystemCapability.WindowManager.WindowManager.Core
| Name | Type| Readable| Writable| Description |
| -------- | -------- | ---- | ---- | ------------------- |
| screenId | number | Yes | Yes | Screen ID. |
| startX | number | Yes | Yes | Start X coordinate of the screen.|
| startY | number | Yes | Yes | Start Y coordinate of the screen.|
## VirtualScreenOption
Defines virtual screen parameters.
**System capability**: SystemCapability.WindowManager.WindowManager.Core
| Name | Type| Readable| Writable| Description |
| --------- | -------- | ---- | ---- | ------------------------- |
| name | string | Yes | Yes | Name of a virtual screen. |
| width | number | Yes | Yes | Width of the virtual screen. |
| height | number | Yes | Yes | Height of the virtual screen. |
| density | number | Yes | Yes | Density of the virtual screen. |
| surfaceId | string | Yes | Yes | Surface ID of the virtual screen.|
## Screen
Implements a **Screen** instance.
Before calling any API in **Screen**, you must use **[getAllScreens()](#screengetallscreens)** or **[createVirtualScreen()](#screencreatevirtualscreen)** to obtain a **Screen** instance.
**System capability**: SystemCapability.WindowManager.WindowManager.Core
| Name | Type | Readable| Writable| Description |
| ----------------- | ---------------------------------------------- | ---- | ---- | ---------------------- |
| id | number | Yes | No | Screen ID. |
| parent | number | Yes | No | ID of the group to which a screen belongs. |
| supportedModeInfo | Array&lt;[ScreenModeInfo](#screenmodeinfo)&gt; | Yes | No | Mode set supported by the screen. |
| activeModeIndex | number | Yes | No | Index of the active screen mode.|
| orientation | [Orientation](#orientation) | Yes | No | Screen orientation. |
### setOrientation
setOrientation(orientation: Orientation, callback: AsyncCallback&lt;void&gt;): void
Sets the screen orientation. This API uses an asynchronous callback to return the result.
**System capability**: SystemCapability.WindowManager.WindowManager.Core
| Name | Type | Mandatory| Description |
| ----------- | --------------------------- | ---- | ------------------------------------------------------------ |
| orientation | [Orientation](#orientation) | Yes | Screen orientation. |
| callback | AsyncCallback&lt;void&gt; | Yes | Callback used to return the result. If the screen orientation is successfully set, **err** is **undefined**; otherwise, **err** is an error object.|
**Example**
```js
screenClass.setOrientation(screen.Orientation.VERTICAL, (err, data) => {
if (err.code) {
console.error('Failed to setOrientation VERTICAL. Cause: ' + JSON.stringify(err));
return;
}
console.info('Succeeded in setting Orientation VERTICAL. data: ' + JSON.stringify(data));
})
```
### setOrientation
setOrientation(orientation: Orientation): Promise&lt;void&gt;
Sets the screen orientation. This API uses a promise to return the result.
**System capability**: SystemCapability.WindowManager.WindowManager.Core
| Name | Type | Mandatory| Description |
| ----------- | --------------------------- | ---- | ---------- |
| orientation | [Orientation](#orientation) | Yes | Screen orientation.|
**Return value**
| Type | Description |
| ------------------- | ------------------------- |
| Promise&lt;void&gt; | Promise that returns no value.|
**Example**
```js
let promise = screenClass.setOrientation(screen.Orientation.VERTICAL);
promise.then((data) => {
console.info('Succeeded in setting Orientation VERTICAL. Data: ' + JSON.stringify(data));
}).catch((err) => {
console.error('Failed to set Orientation VERTICAL. Cause: ' + JSON.stringify(err));
})
```
### setScreenActiveMode
setScreenActiveMode(modeIndex: number, callback: AsyncCallback&lt;void&gt;): void
Sets the active mode of the screen. This API uses an asynchronous callback to return the result.
**System capability**: SystemCapability.WindowManager.WindowManager.Core
| Name | Type | Mandatory| Description |
| --------- | ------------------------- | ---- | ------------------------------------------------------------ |
| modeIndex | number | Yes | Index of the mode to set. |
| callback | AsyncCallback&lt;void&gt; | Yes | Callback used to return the result. If the active mode is successfully set, **err** is **undefined**; otherwise, **err** is an error object.|
**Example**
```js
var modeIndex = 0;
screenClass.setScreenActiveMode(modeIndex, (err, data) => {
if (err.code) {
console.error('Failed to set ScreenActiveMode 0. Cause: ' + JSON.stringify(err));
return;
}
console.info('Succeeded in setting ScreenActiveMode 0. data: ' + JSON.stringify(data));
})
```
### setScreenActiveMode
setScreenActiveMode(modeIndex: number): Promise&lt;void&gt;
Sets the active mode of the screen. This API uses a promise to return the result.
**System capability**: SystemCapability.WindowManager.WindowManager.Core
| Name | Type | Mandatory| Description |
| --------- | ------ | ---- | ---------- |
| modeIndex | number | Yes | Index of the mode to set.|
**Return value**
| Type | Description |
| ------------------- | ------------------------- |
| Promise&lt;void&gt; | Promise that returns no value.|
**Example**
```js
var modeIndex = 0;
let promise = screenClass.setScreenActiveMode(modeIndex);
promise.then((data) => {
console.info('Succeeded in setting ScreenActiveMode 0. Data: ' + JSON.stringify(data));
}).catch((err) => {
console.error('Failed to set ScreenActiveMode 0. Cause: ' + JSON.stringify(err));
})
```
### setDensityDpi
setDensityDpi(densityDpi: number, callback: AsyncCallback&lt;void&gt;): void;
Sets the pixel density of the screen. This API uses an asynchronous callback to return the result.
**System capability**: SystemCapability.WindowManager.WindowManager.Core
| Name | Type | Mandatory| Description |
| ---------- | ------------------------- | ---- | ------------------------------------------------------------ |
| densityDpi | number | Yes | Pixel density. The value ranges from 80 to 640. |
| callback | AsyncCallback&lt;void&gt; | Yes | Callback used to return the result. If the pixel density is successfully set, **err** is **undefined**; otherwise, **err** is an error object.|
**Example**
```js
var densityDpi = 320;
screenClass.setDensityDpi(densityDpi, (err, data) => {
if (err.code) {
console.error('Failed to set DensityDpi 320. Cause: ' + JSON.stringify(err));
return;
}
console.info('Succeed in setting DensityDpi 320. data: ' + JSON.stringify(data));
})
```
### setDensityDpi
setDensityDpi(densityDpi: number): Promise&lt;void&gt;
Sets the pixel density of the screen. This API uses a promise to return the result.
**System capability**: SystemCapability.WindowManager.WindowManager.Core
| Name | Type | Mandatory| Description |
| ---------- | ------ | ---- | ---------------------------------- |
| densityDpi | number | Yes | Pixel density. The value ranges from 80 to 640.|
**Return value**
| Type | Description |
| ------------------- | ------------------------- |
| Promise&lt;void&gt; | Promise that returns no value.|
**Example**
```js
var densityDpi = 320;
var promise = screenClass.setDensityDpi(densityDpi);
promise.then((data) => {
console.info('Succeeded in setting DensityDpi 320. Data: ' + JSON.stringify(data));
}).catch((err) => {
console.error('Failed to set DensityDpi 320. Cause: ' + JSON.stringify(err));
})
```
## Orientation
Enumerates the screen orientations.
**System capability**: SystemCapability.WindowManager.WindowManager.Core
| Name | Value | Description |
| ------------------ | ---- | -------------------------------- |
| UNSPECIFIED | 0 | Unspecified. The screen orientation is determined by the system.|
| VERTICAL | 1 | Vertical. |
| HORIZONTAL | 2 | Horizontal. |
| REVERSE_VERTICAL | 3 | Reverse vertical. |
| REVERSE_HORIZONTAL | 4 | Reverse horizontal. |
| SENSOR | 5 | The screen orientation follows the sensor direction. |
| SENSOR_VERTICAL | 6 | The screen orientation follows the sensor direction vertically.|
| SENSOR_HORIZONTAL | 7 | The screen orientation follows the sensor direction horizontally.|
## ScreenModeInfo
Defines the screen mode information.
**System capability**: SystemCapability.WindowManager.WindowManager.Core
| Name | Type| Readable| Writable| Description |
| ----------- | -------- | ---- | ---- | -------------------------------------------------- |
| id | number | Yes | Yes | Mode ID. The supported mode is determined by the device resolution and refresh rate.|
| width | number | Yes | Yes | Screen width. |
| height | number | Yes | Yes | Screen height. |
| refreshRate | number | Yes | Yes | Screen refresh rate. |
# UI Appearance
The **uiAppearance** module provides basic capabilities for managing the system appearance. It allows for color mode configuration currently, and will introduce more features over time.
> **NOTE**
>
> The APIs of this module are supported since API version 9. Updates will be marked with a superscript to indicate their earliest API version.
> The APIs provided by this module are system APIs.
## Modules to Import
```ts
import uiAppearance from '@ohos.uiAppearance'
```
## DarkMode
Enumerates the color modes.
| Name| Value| Description|
| -- | -- | -- |
| ALWAYS_DARK | 0 | The system is always in dark mode. |
| ALWAYS_LIGHT | 1 | The system is always in light mode.|
## uiAppearance.setDarkMode
setDarkMode(mode: DarkMode, callback: AsyncCallback\<void>): void
Sets the system color mode. This API uses an asynchronous callback to return the result.
**Required permissions**: ohos.permission.UPDATE_CONFIGRATION
**System capability**: SystemCapability.ArkUI.ArkUI.Full
**Parameters**
| Name| Type| Mandatory| Description|
| -- | -- | -- | -- |
| mode | [DarkMode](#darkmode) | Yes| Color mode to set.|
| callback | AsyncCallback\<void>| Yes| Callback used to return the result.|
**Example**
```ts
uiAppearance.setDarkMode(uiAppearance.DarkMode.ALWAYS_DARK, (err) => {
console.info(`${err}`);
})
```
## uiAppearance.setDarkMode
setDarkMode(mode: DarkMode): Promise\<void>;
Sets the system color mode. This API uses a promise to return the result.
**Required permissions**: ohos.permission.UPDATE_CONFIGRATION
**System capability**: SystemCapability.ArkUI.ArkUI.Full
**Parameters**
| Name| Type| Mandatory| Description|
| -- | -- | -- | -- |
| mode | [DarkMode](#darkmode) | Yes| Color mode to set.|
**Example**
```ts
uiAppearance.setDarkMode(uiAppearance.DarkMode.ALWAYS_DARK).then(() => {
console.log('Set dark-mode successfully.');
}).catch((err) => {
console.log(`Set dark-mode failed, ${err}`);
});
```
## uiAppearance.getDarkMode
getDarkMode(): DarkMode;
Obtains the system color mode.
**Required permissions**: ohos.permission.UPDATE_CONFIGRATION
**System capability**: SystemCapability.ArkUI.ArkUI.Full
**Return value**
| Type| Description|
| -- | -- |
|[DarkMode](#darkmode) | Color mode obtained.|
**Example**
```ts
let darkMode = uiAppearance.getDarkMode();
console.log(`Get dark-mode ${darkMode}`);
```
# JS API Changes of the Distributed Scheduler Subsystem
The table below lists the APIs changes of the distributed scheduler subsystem in OpenHarmony 3.2 Beta1 over OpenHarmony 3.1 Release.
## API Changes
| Module| Class| Method/Attribute/Enumeration/Constant| Change Type|
|---|---|---|---|
| ohos.continuation.continuationManager | continuationManager | on(type: "deviceConnect", token: number, callback: Callback\<Array\<ContinuationResult>>): void; | Added|
| ohos.continuation.continuationManager | continuationManager | off(type: "deviceConnect", token: number): void; | Added|
| ohos.continuation.continuationManager | continuationManager | on(type: "deviceDisconnect", token: number, callback: Callback\<Array\<string>>): void; | Added|
| ohos.continuation.continuationManager | continuationManager | off(type: "deviceDisconnect", token: number): void; | Added|
| ohos.continuation.continuationManager | continuationManager | on(type: "deviceConnect", callback: Callback\<ContinuationResult>): void; | Deprecated|
| ohos.continuation.continuationManager | continuationManager | off(type: "deviceConnect", callback?: Callback\<ContinuationResult>): void; | Deprecated|
| ohos.continuation.continuationManager | continuationManager | on(type: "deviceDisconnect", callback: Callback\<string>): void; | Deprecated|
| ohos.continuation.continuationManager | continuationManager | off(type: "deviceDisconnect", callback?: Callback\<string>): void; | Deprecated|
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册