@@ -44,7 +44,7 @@ Enumerates the action constants of the **Want** object. **action** specifies the
...
@@ -44,7 +44,7 @@ Enumerates the action constants of the **Want** object. **action** specifies the
| INTENT_PARAMS_INTENT | ability.want.params.INTENT | Action of displaying selection options with an action selector. |
| INTENT_PARAMS_INTENT | ability.want.params.INTENT | Action of displaying selection options with an action selector. |
| INTENT_PARAMS_TITLE | ability.want.params.TITLE | Title of the character sequence dialog box used with the action selector. |
| INTENT_PARAMS_TITLE | ability.want.params.TITLE | Title of the character sequence dialog box used with the action selector. |
| ACTION_FILE_SELECT<sup>7+</sup> | ohos.action.fileSelect | Action of selecting a file. |
| ACTION_FILE_SELECT<sup>7+</sup> | ohos.action.fileSelect | Action of selecting a file. |
| PARAMS_STREAM<sup>7+</sup> | ability.params.stream | URI of the data stream associated with the target when the data is sent. |
| PARAMS_STREAM<sup>7+</sup> | ability.params.stream | URI of the data stream associated with the target when the data is sent. The value must be an array of the string type. |
| ACTION_APP_ACCOUNT_OAUTH <sup>8+</sup> | ohos.account.appAccount.action.oauth | Action of providing the OAuth service. |
| ACTION_APP_ACCOUNT_OAUTH <sup>8+</sup> | ohos.account.appAccount.action.oauth | Action of providing the OAuth service. |
| ACTION_APP_ACCOUNT_AUTH <sup>9+</sup> | account.appAccount.action.auth | Action of providing the authentication service. |
| ACTION_APP_ACCOUNT_AUTH <sup>9+</sup> | account.appAccount.action.auth | Action of providing the authentication service. |
| ACTION_MARKET_DOWNLOAD <sup>9+</sup> | ohos.want.action.marketDownload | Action of downloading an application from the application market.<br>**System API**: This is a system API and cannot be called by third-party applications. |
| ACTION_MARKET_DOWNLOAD <sup>9+</sup> | ohos.want.action.marketDownload | Action of downloading an application from the application market.<br>**System API**: This is a system API and cannot be called by third-party applications. |
| callback | AsyncCallback\<Array\<[AbilityRunningInfo](js-apis-inner-application-abilityRunningInfo.md)>> | Yes | Callback used to return the API call result and the UIAbility running information. You can perform error handling or custom processing in this callback. |
| callback | AsyncCallback\<Array\<[AbilityRunningInfo](js-apis-inner-application-abilityRunningInfo.md)>> | Yes | Callback used to return the API call result and the UIAbility running information. You can perform error handling or custom processing in this callback. |
The **Configuration** module defines environment change information.
The **Configuration** module defines environment change information.**Configuration** is an interface definition and is used only for field declaration.
> **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 9. Newly added APIs will be marked with a superscript to indicate their earliest API version.
| language | string | Yes| Yes| Language of the application, for example, **zh**.|
| language | string | Yes| Yes| Language of the application, for example, **zh**.|
| colorMode | [ColorMode](js-apis-app-ability-configurationConstant.md#configurationconstantcolormode) | Yes| Yes| Color mode, which can be **COLOR_MODE_LIGHT** or **COLOR_MODE_DARK**. The default value is **COLOR_MODE_LIGHT**.|
| colorMode | [ColorMode](js-apis-app-ability-configurationConstant.md#configurationconstantcolormode) | Yes| Yes| Color mode. The default value is **COLOR_MODE_LIGHT**. The options are as follows:<br>- **COLOR_MODE_NOT_SET**: The color mode is not set.<br>- **COLOR_MODE_LIGHT**: light mode.<br>- **COLOR_MODE_DARK**: dark mode.|
| direction | [Direction](js-apis-app-ability-configurationConstant.md#configurationconstantdirection) | Yes| No| Screen orientation, which can be **DIRECTION_HORIZONTAL** or **DIRECTION_VERTICAL**.|
| direction | [Direction](js-apis-app-ability-configurationConstant.md#configurationconstantdirection) | Yes| No| Screen orientation. The options are as follows:<br>- **DIRECTION_NOT_SET**: The screen orientation is not set.<br>- **DIRECTION_HORIZONTAL**: horizontal direction.<br>- **DIRECTION_VERTICAL**: vertical direction.|
| screenDensity | [ScreenDensity](js-apis-app-ability-configurationConstant.md#configurationconstantscreendensity) | Yes| No| Screen resolution, which can be **SCREEN_DENSITY_SDPI** (120), **SCREEN_DENSITY_MDPI** (160), **SCREEN_DENSITY_LDPI** (240), **SCREEN_DENSITY_XLDPI** (320), **SCREEN_DENSITY_XXLDPI** (480), or **SCREEN_DENSITY_XXXLDPI** (640).|
| screenDensity | [ScreenDensity](js-apis-app-ability-configurationConstant.md#configurationconstantscreendensity) | Yes| No| Pixel density of the screen. The options are as follows:<br>- **SCREEN_DENSITY_NOT_SET**: The pixel density is not set.<br>- **SCREEN_DENSITY_SDPI**: 120.<br>- **SCREEN_DENSITY_MDPI**: 160.<br>- **SCREEN_DENSITY_LDPI**: 240.<br>- **SCREEN_DENSITY_XLDPI**: 320.<br>- **SCREEN_DENSITY_XXLDPI**: 480.<br>- **SCREEN_DENSITY_XXXLDPI**: 640.|
| displayId | number | Yes| No| ID of the display where the application is located.|
| displayId | number | Yes| No| ID of the display where the application is located.|
| hasPointerDevice | boolean | Yes| No| Whether a pointer device, such as a keyboard, mouse, or touchpad, is connected.|
| hasPointerDevice | boolean | Yes| No| Whether a pointer device, such as a keyboard, mouse, or touchpad, is connected.|
...
@@ -34,7 +28,7 @@ For details about the fields, see the **ohos.app.ability.Configuration.d.ts** fi
...
@@ -34,7 +28,7 @@ For details about the fields, see the **ohos.app.ability.Configuration.d.ts** fi
| level | [AbilityConstant.MemoryLevel](js-apis-app-ability-abilityConstant.md#abilityconstantmemorylevel) | Yes| Memory level that indicates the memory usage status. When the specified memory level is reached, a callback will be invoked and the system will start adjustment.|
The **ErrorManager** module provides APIs for registering and deregistering error observers. For example, you can use the APIs to register an observer when your application wants to capture JS crashes.
The **ErrorManager** module provides APIs for registering and deregistering error observers.
> **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 9. Newly added APIs will be marked with a superscript to indicate their earliest API version.
## Modules to Import
## Modules to Import
```ts
```
import errorManager from '@ohos.app.ability.errorManager'
import errorManager from '@ohos.app.ability.errorManager'
@@ -468,22 +331,27 @@ Obtains the snapshot of a given mission. This API uses an asynchronous callback
...
@@ -468,22 +331,27 @@ Obtains the snapshot of a given mission. This API uses an asynchronous callback
| callback | AsyncCallback<[MissionSnapshot](js-apis-inner-application-missionSnapshot.md)> | Yes| Callback used to return the snapshot information obtained.|
| callback | AsyncCallback<[MissionSnapshot](js-apis-inner-application-missionSnapshot.md)> | Yes| Callback used to return the snapshot information obtained.|
@@ -547,22 +421,27 @@ Obtains the low-resolution snapshot of a given mission. This API uses an asynchr
...
@@ -547,22 +421,27 @@ Obtains the low-resolution snapshot of a given mission. This API uses an asynchr
| callback | AsyncCallback<[MissionSnapshot](js-apis-inner-application-missionSnapshot.md)> | Yes| Callback used to return the snapshot information obtained.|
| callback | AsyncCallback<[MissionSnapshot](js-apis-inner-application-missionSnapshot.md)> | Yes| Callback used to return the snapshot information obtained.|
The **quickFixManager** module provides APIs for quick fix. With quick fix, you can fix bugs in your application by applying patches, which is more efficient than by updating the entire application.
The **quickFixManager** module provides APIs for quick fix. With quick fix, you can fix bugs in your application by applying patches, which is more efficient than by updating the entire application.
> **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 9. Newly added APIs will be marked with a superscript to indicate their earliest API version.
## Modules to Import
## Modules to Import
...
@@ -24,7 +24,7 @@ Defines the quick fix information at the HAP file level.
...
@@ -24,7 +24,7 @@ Defines the quick fix information at the HAP file level.
| moduleName | string | Yes | Name of the HAP file. |
| moduleName | string | Yes | Name of the HAP file. |
| originHapHash | string | Yes | Hash value of the HAP file. |
| originHapHash | string | Yes | Hash value of the HAP file. |
| quickFixFilePath | string | Yes | Installation path of the quick fix file. |
| quickFixFilePath | string | Yes | Installation path of the quick fix patch file. |
## ApplicationQuickFixInfo
## ApplicationQuickFixInfo
...
@@ -57,25 +57,31 @@ Applies a quick fix patch. This API uses an asynchronous callback to return the
...
@@ -57,25 +57,31 @@ Applies a quick fix patch. This API uses an asynchronous callback to return the
**Parameters**
**Parameters**
| Parameter| Type| Mandatory| Description|
| Parameter| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| -------- | -------- | -------- | -------- |
| hapModuleQuickFixFiles | Array\<string> | Yes| Quick fix files, each of which must contain a valid file path.|
| hapModuleQuickFixFiles | Array\<string> | Yes| Quick fix patch files, each of which must contain a valid file path.|
| callback | AsyncCallback\<void> | Yes| Callback used to return the result.|
| callback | AsyncCallback\<void> | Yes| Callback used to return the result.|
> **NOTE**
>
> The file path passed in the API must be an application sandbox path. For details about how to obtain the sandbox path, see [Obtaining the Sandbox Path](js-apis-bundle-BundleInstaller.md#obtaining-the-sandbox-path). The path mapped to the device is **/proc/<*applicationProcessId*>/root/*sandboxPath***.
The **ServiceExtensionAbility** module provides lifecycle callbacks when a ServiceExtensionAbility (background service) is created, destroyed, connected, or disconnected.
The **ServiceExtensionAbility** module provides APIs for ServiceExtensionAbilities.
> **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 APIs of this module are supported since API version 9 and are deprecated in versions later than API version 9. You are advised to use [@ohos.app.ability.ServiceExtensionAbility](js-apis-app-ability-serviceExtensionAbility.md) instead. 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.
> The APIs of this module can be used only in the stage model.
## Modules to Import
## Modules to Import
...
@@ -80,7 +80,7 @@ Called when this ServiceExtensionAbility is destroyed to clear resources.
...
@@ -80,7 +80,7 @@ Called when this ServiceExtensionAbility is destroyed to clear resources.
onRequest(want: Want, startId: number): void;
onRequest(want: Want, startId: number): void;
Called following **onCreate()** when a ServiceExtensionAbility is started by calling **startAbility()**. The value of **startId** is incremented for each ability that is started.
Called following **onCreate()** when a ServiceExtensionAbility is started by calling **startAbility()** or **startServiceExtensionAbility()**. The value of **startId** is incremented for each ability that is started.
UIAbility is an application component that has the UI. The **UIAbility** module provides lifecycle callback such as component creation, destruction, and foreground/background switching. It also provides the following capabilities related to component collaboration:
The **Ability** module manages the ability lifecycle and context, such as creating and destroying an ability, and dumping client information.
-[Caller](#caller): an object returned by [startAbilityByCall](js-apis-inner-application-uiAbilityContext.md#uiabilitycontextstartabilitybycall). The CallerAbility (caller) uses this object to communicate with the CalleeAbility (callee).
This module provides the following common ability-related functions:
-[Callee](#callee): an internal object of UIAbility. The CalleeAbility (callee) uses this object to communicate with the CallerAbility (caller).
-[Caller](#caller): implements sending of sequenceable data to the target ability when an ability (caller ability) invokes the target ability (callee ability).
-[Callee](#callee): implements callbacks for registration and deregistration of caller notifications.
> **NOTE**
> **NOTE**
>
>
...
@@ -13,7 +14,7 @@ UIAbility is an application component that has the UI. The **UIAbility** module
...
@@ -13,7 +14,7 @@ UIAbility is an application component that has the UI. The **UIAbility** module
## Modules to Import
## Modules to Import
```ts
```ts
importUIAbilityfrom'@ohos.app.ability.UIAbility';
importAbilityfrom'@ohos.app.ability.UIAbility';
```
```
## Attributes
## Attributes
...
@@ -22,16 +23,16 @@ import UIAbility from '@ohos.app.ability.UIAbility';
...
@@ -22,16 +23,16 @@ import UIAbility from '@ohos.app.ability.UIAbility';
@@ -39,13 +40,13 @@ Called to initialize the service logic when a UIAbility is created.
...
@@ -39,13 +40,13 @@ Called to initialize the service logic when a UIAbility is created.
| Name| Type| Mandatory| Description|
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| -------- | -------- | -------- | -------- |
| want | [Want](js-apis-app-ability-want.md) | Yes| Information related to this UIAbility, including the ability name and bundle name.|
| want | [Want](js-apis-app-ability-want.md) | Yes| Information related to this ability, including the ability name and bundle name.|
| param | [AbilityConstant.LaunchParam](js-apis-app-ability-abilityConstant.md#abilityconstantlaunchparam) | Yes| Parameters for starting the UIAbility, and the reason for the last abnormal exit.|
| param | [AbilityConstant.LaunchParam](js-apis-app-ability-abilityConstant.md#abilityconstantlaunchparam) | Yes| Parameters for starting the ability, and the reason for the last abnormal exit.|
**Example**
**Example**
```ts
```ts
classMyUIAbilityextendsUIAbility{
classmyAbilityextendsAbility{
onCreate(want,param){
onCreate(want,param){
console.log('onCreate, want:'+want.abilityName);
console.log('onCreate, want:'+want.abilityName);
}
}
...
@@ -53,11 +54,11 @@ Called to initialize the service logic when a UIAbility is created.
...
@@ -53,11 +54,11 @@ Called to initialize the service logic when a UIAbility is created.
@@ -226,20 +227,20 @@ Called when a new Want is passed in and this UIAbility is started again.
...
@@ -226,20 +227,20 @@ Called when a new Want is passed in and this UIAbility is started again.
| Name| Type| Mandatory| Description|
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| -------- | -------- | -------- | -------- |
| want | [Want](js-apis-app-ability-want.md) | Yes| Want information, such as the ability name and bundle name.|
| want | [Want](js-apis-app-ability-want.md) | Yes| Want information, such as the ability name and bundle name.|
| launchParams | [AbilityConstant.LaunchParam](js-apis-app-ability-abilityConstant.md#abilityconstantlaunchparam) | Yes| Reason for the UIAbility startup and the last abnormal exit.|
| launchParams | [AbilityConstant.LaunchParam](js-apis-app-ability-abilityConstant.md#abilityconstantlaunchparam) | Yes| Reason for the ability startup and the last abnormal exit.|
Called when the framework automatically saves the UIAbility state in the case of an application fault. This API is used together with [appRecovery](js-apis-app-ability-appRecovery.md). If automatic state saving is enabled, **onSaveState** is called to save the state of this UIAbility.
Called when the framework automatically saves the ability state in the case of an application fault. This API is used together with [appRecovery](js-apis-app-ability-appRecovery.md). If automatic state saving is enabled, **onSaveState** is called to save the state of this ability.
@@ -277,24 +278,24 @@ Called when the framework automatically saves the UIAbility state in the case of
...
@@ -277,24 +278,24 @@ Called when the framework automatically saves the UIAbility state in the case of
| Name| Type| Mandatory| Description|
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| -------- | -------- | -------- | -------- |
| reason | [AbilityConstant.StateType](js-apis-app-ability-abilityConstant.md#abilityconstantstatetype) | Yes| Reason for triggering the callback to save the UIAbility state.|
| reason | [AbilityConstant.StateType](js-apis-application-abilityConstant.md#abilityconstantstatetype) | Yes| Reason for triggering the callback to save the ability state.|
@@ -624,7 +733,7 @@ Registers a caller notification callback, which is invoked when the target abili
...
@@ -624,7 +733,7 @@ Registers a caller notification callback, which is invoked when the target abili
| Name| Type| Mandatory| Description|
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| -------- | -------- | -------- | -------- |
| method | string | Yes| Notification message string negotiated between the two abilities.|
| method | string | Yes| Notification message string negotiated between the two abilities.|
| callback | [CalleeCallback](#calleecallback) | Yes| JS notification synchronization callback of the [rpc.MessageParcel](js-apis-rpc.md#messageparceldeprecated) type. The callback must return at least one empty [rpc.Sequenceable](js-apis-rpc.md#sequenceabledeprecated) object. Otherwise, the function execution fails.|
| callback | [CalleeCallback](#calleecallback) | Yes| JS notification synchronization callback of the [rpc.MessageParcel](js-apis-rpc.md#sequenceabledeprecated) type. The callback must return at least one empty [rpc.Sequenceable](js-apis-rpc.md#sequenceabledeprecated) object. Otherwise, the function execution fails.|
**Error codes**
**Error codes**
...
@@ -637,9 +746,10 @@ For details about the error codes, see [Ability Error Codes](../errorcodes/error
...
@@ -637,9 +746,10 @@ For details about the error codes, see [Ability Error Codes](../errorcodes/error
**Example**
**Example**
```ts
```ts
importAbilityfrom'@ohos.app.ability.UIAbility';
classMyMessageAble{
classMyMessageAble{
name:""
name:''
str:""
str:''
num:1
num:1
constructor(name,str){
constructor(name,str){
this.name=name;
this.name=name;
...
@@ -658,14 +768,14 @@ For details about the error codes, see [Ability Error Codes](../errorcodes/error
...
@@ -658,14 +768,14 @@ For details about the error codes, see [Ability Error Codes](../errorcodes/error
returntrue;
returntrue;
}
}
};
};
varmethod='call_Function';
letmethod='call_Function';
functionfuncCallBack(pdata){
functionfuncCallBack(pdata){
console.log('Callee funcCallBack is called '+pdata);
console.log('Callee funcCallBack is called '+pdata);
letmsg=newMyMessageAble("test","");
letmsg=newMyMessageAble('test','');
pdata.readSequenceable(msg);
pdata.readSequenceable(msg);
returnnewMyMessageAble("test1","Callee test");
returnnewMyMessageAble('test1','Callee test');
}
}
exportdefaultclassMainUIAbilityextendsUIAbility{
exportdefaultclassMainAbilityextendsAbility{
onCreate(want,launchParam){
onCreate(want,launchParam){
console.log('Callee onCreate is called');
console.log('Callee onCreate is called');
try{
try{
...
@@ -704,8 +814,9 @@ For details about the error codes, see [Ability Error Codes](../errorcodes/error
...
@@ -704,8 +814,9 @@ For details about the error codes, see [Ability Error Codes](../errorcodes/error
**Example**
**Example**
```ts
```ts
varmethod='call_Function';
importAbilityfrom'@ohos.app.ability.UIAbility';
exportdefaultclassMainUIAbilityextendsUIAbility{
letmethod='call_Function';
exportdefaultclassMainAbilityextendsAbility{
onCreate(want,launchParam){
onCreate(want,launchParam){
console.log('Callee onCreate is called');
console.log('Callee onCreate is called');
try{
try{
...
@@ -736,4 +847,4 @@ For details about the error codes, see [Ability Error Codes](../errorcodes/error
...
@@ -736,4 +847,4 @@ For details about the error codes, see [Ability Error Codes](../errorcodes/error
| (indata: [rpc.MessageParcel](js-apis-rpc.md#messageparceldeprecated)) | Yes| No| [rpc.Sequenceable](js-apis-rpc.md#sequenceabledeprecated) | Prototype of the listener function registered by the callee.|
| (indata: [rpc.MessageParcel](js-apis-rpc.md#sequenceabledeprecated)) | Yes| No| [rpc.Sequenceable](js-apis-rpc.md#sequenceabledeprecated) | Prototype of the listener function registered by the callee.|
| deviceId | string | No | ID of the device running the ability. If this field is unspecified, the local device is used. |
| deviceId | string | No | ID of the device running the ability. |
| bundleName | string | No | Bundle name of the ability.|
| bundleName | string | No | Bundle name of the ability. If both **bundleName** and **abilityName** are specified in a **Want** object, the **Want** object can match a specific ability. |
| moduleName | string | No| Name of the module to which the ability belongs.|
| abilityName | string | No | Name of the ability. If both **bundleName** and **abilityName** are specified in a **Want** object, the **Want** object can match a specific ability. The value of **abilityName** must be unique in an application.|
| abilityName | string | No | Name of the ability. If both **bundleName** and **abilityName** are specified in a **Want** object, the **Want** object can match a specific ability. The value of **abilityName** must be unique in an application.|
| [action](js-apis-app-ability-wantConstant.md#wantconstantaction) | string | No | Action to take, such as viewing and sharing application details. In implicit Want, you can define this field and use it together with **uri** or **parameters** to specify the operation to be performed on the data. For details about the definition and matching rules of implicit Want, see [Matching Rules of Explicit Want and Implicit Want](../../application-models/explicit-implicit-want-mappings.md). |
| uri | string | No| If **uri** is specified in a **Want**, the **Want** will match the specified URI information, including **scheme**, **schemeSpecificPart**, **authority**, and **path** components.|
| [entities](js-apis-app-ability-wantConstant.md#wantconstantentity) | Array\<string> | No| Additional category information (such as browser and video player) of the ability. It is a supplement to the **action** field for implicit Want. and is used to filter ability types.|
| type | string | No| MIME type, that is, the type of the file to open, for example, **'text/xml'** and **'image/*'**. For details about the MIME type definition, see https://www.iana.org/assignments/media-types/media-types.xhtml?utm_source=ld246.com.|
| uri | string | No| Data carried. This field is used together with **type** to specify the data type. If **uri** is specified in a Want, the Want will match the specified URI information, including **scheme**, **schemeSpecificPart**, **authority**, and **path**.|
| flags | number | No| How the **Want** object will be handled. By default, a number is passed in. For details, see [flags](js-apis-ability-wantConstant.md#wantConstant.Flags). |
| type | string | No| MIME type, that is, the type of the file to open, for example, **text/xml** and **image/***. For details about the MIME type definition, see https://www.iana.org/assignments/media-types/media-types.xhtml?utm_source=ld246.com.|
| action | string | No | Action to take, such as viewing and sharing application details. In implicit Want, you can define this field and use it together with **uri** or **parameters** to specify the operation to be performed on the data. |
| parameters | {[key: string]: any} | No | Want parameters in the form of custom key-value (KV) pairs. By default, the following keys are carried:<br>- **ohos.aafwk.callerPid**: PID of the caller.<br>- **ohos.aafwk.param.callerToken**: token of the caller.<br>- **ohos.aafwk.param.callerUid**: UID in [BundleInfo](js-apis-bundleManager-bundleInfo.md#bundleinfo-1), that is, the application UID in the bundle information. |
| parameters | {[key: string]: any} | No | Want parameters in the form of custom key-value (KV) pairs. By default, the following keys are carried:<br>- **ohos.aafwk.callerPid**: PID of the caller.<br>- **ohos.aafwk.param.callerToken**: token of the caller.<br>- **ohos.aafwk.param.callerUid**: UID in [BundleInfo](js-apis-bundleManager-bundleInfo.md#bundleinfo-1), that is, the application UID in the bundle information.<br>- **component.startup.newRules**: whether to enable the new control rule.<br/>- **moduleName**: module name of the caller. No matter what this field is set to, the correct module name will be sent to the peer.<br/>- **ohos.dlp.params.sandbox**: available only for DLP files. |
| [flags](js-apis-ability-wantConstant.md#wantconstantflags) | number | No| How the **Want** object will be handled. By default, a number is passed in.<br>For example, **wantConstant.Flags.FLAG_ABILITY_CONTINUATION** specifies whether to start the ability in cross-device migration scenarios.|
| entities | Array\<string> | No| Additional category information (such as browser and video player) of the ability. It is a supplement to the **action** field for implicit Want. and is used to filter ability types.|
| moduleName | string | ·ñ | Module to which the ability belongs. |
**Example**
**Example**
- Basic usage (called in a UIAbility object, where context in the example is the context object of the UIAbility).
- Basic usage
```ts
```ts
letwant={
letwant={
"deviceId":"",// An empty deviceId indicates the local device.
'deviceId':'',// An empty deviceId indicates the local device.
"bundleName":"com.example.myapplication",
'bundleName':'com.extreme.test',
"abilityName":"FuncAbility",
'abilityName':'MainAbility',
"moduleName":"entry"// moduleName is optional.
'moduleName':'entry'// moduleName is optional
};
};
this.context.startAbility(want,(error)=>{
this.context.startAbility(want,(error)=>{
// Start an ability explicitly. The bundleName, abilityName, and moduleName parameters work together to uniquely identify an ability.
// Start an ability explicitly. The bundleName, abilityName, and moduleName parameters work together to uniquely identify an ability.
console.log("error.code = "+error.code)
console.log('error.code = '+error.code);
})
})
```
```
- Data is transferred through user-defined fields. The following data types are supported (called in a UIAbility object, where context in the example is the context object of the UIAbility):
- Data is transferred through user-defined fields. The following data types are supported:
The **app.ability.WantAgent** module provides APIs for creating and comparing **WantAgent** objects, and obtaining the user ID and bundle name of a **WantAgent** object. You are advised to use this module, since it will replace the [@ohos.wantAgent](js-apis-wantAgent.md) module in the near future.
The **WantAgent** module provides APIs for creating and comparing **WantAgent** objects, and obtaining the user ID and bundle name of a **WantAgent** object. You are advised to use this module, since it will replace the [@ohos.wantAgent](js-apis-wantAgent.md) module in the near future.
> **NOTE**
> **NOTE**
>
>
...
@@ -8,7 +8,7 @@ The **app.ability.WantAgent** module provides APIs for creating and comparing **
...
@@ -8,7 +8,7 @@ The **app.ability.WantAgent** module provides APIs for creating and comparing **
## Modules to Import
## Modules to Import
```ts
```js
importWantAgentfrom'@ohos.app.ability.wantAgent';
importWantAgentfrom'@ohos.app.ability.wantAgent';
```
```
...
@@ -16,7 +16,7 @@ import WantAgent from '@ohos.app.ability.wantAgent';
...
@@ -16,7 +16,7 @@ import WantAgent from '@ohos.app.ability.wantAgent';
Obtains a **WantAgent** object. This API uses an asynchronous callback to return the result.
Obtains a **WantAgent** object. This API uses an asynchronous callback to return the result. If the creation fails, a null **WantAgent** object is returned.
| obj | Object\|string | No | Data to be displayed on the JS widget. The value can be an object containing multiple key-value pairs or a string in JSON format. The image data is identified by "formImages", and the content is multiple key-value pairs, each of which consists of an image identifier and image file descriptor. The final format is {"formImages": {"key1": fd1, "key2": fd2}}.|
| obj | Object\|string | No | Data to be displayed on the JS widget. The value can be an object containing multiple key-value pairs or a string in JSON format. The image data is identified by **'formImages'**, and the content is multiple key-value pairs, each of which consists of an image identifier and image file descriptor. The final format is {'formImages': {'key1': fd1, 'key2': fd2}}.|
**Return value**
**Return value**
...
@@ -48,17 +48,20 @@ Creates a **FormBindingData** object.
...
@@ -48,17 +48,20 @@ Creates a **FormBindingData** object.
The **formHost** module provides APIs related to the widget host, which is an application that displays the widget content and controls the position where the widget is displayed. You can use the APIs to delete, release, and update widgets installed by the same user, and obtain widget information and status.
The **FormHost** module provides APIs related to the widget host, which is an application that displays the widget content and controls the position where the widget is displayed. You can use the APIs to delete, release, and update widgets installed by the same user, and obtain widget information and status.
> **NOTE**
> **NOTE**
>
>
...
@@ -34,26 +34,25 @@ Deletes a widget. After this API is called, the application can no longer use th
...
@@ -34,26 +34,25 @@ Deletes a widget. After this API is called, the application can no longer use th
| Error Code ID| Error Message|
| Error Code ID| Error Message|
| -------- | -------- |
| -------- | -------- |
| 401 | Incorrect input parameter.|
| 401 | If the input parameter is not valid parameter. |
|For details about the error codes, see [Form Error Codes](../errorcodes/errorcode-form.md).|
|For details about the error codes, see [Form Error Codes](../errorcodes/errorcode-form.md).|
@@ -830,23 +795,21 @@ Obtains the widget information provided by all applications on the device. This
...
@@ -830,23 +795,21 @@ Obtains the widget information provided by all applications on the device. This
| Name| Type | Mandatory| Description |
| Name| Type | Mandatory| Description |
| ------ | ------ | ---- | ------- |
| ------ | ------ | ---- | ------- |
| callback | AsyncCallback<Array<[formInfo.FormInfo](js-apis-app-form-formInfo.md)>> | Yes| Callback used to return the result. If the widget information is obtained, **error** is undefined and **data** is the information obtained; otherwise, **error** is an error object.|
| callback | AsyncCallback<Array<[FormInfo](js-apis-app-form-formInfo.md)>> | Yes| Callback used to return the result. If the widget information is obtained, **error** is undefined and **data** is the information obtained; otherwise, **error** is an error object.|
@@ -1103,40 +1054,38 @@ Obtains the widget state. This API uses an asynchronous callback to return the r
...
@@ -1103,40 +1054,38 @@ Obtains the widget state. This API uses an asynchronous callback to return the r
| Name| Type | Mandatory| Description |
| Name| Type | Mandatory| Description |
| ------ | ------ | ---- | ------- |
| ------ | ------ | ---- | ------- |
| want | [Want](js-apis-application-want.md) | Yes | **Want** information carried to query the widget state. The information must contain the bundle name, ability name, module name, widget name, and widget dimensions.|
| want | [Want](js-apis-application-want.md) | Yes | **Want** information carried to query the widget state. The information must contain the bundle name, ability name, module name, widget name, and widget dimensions.|
| callback | AsyncCallback<[formInfo.FormStateInfo](js-apis-app-form-formInfo.md#formstateinfo)> | Yes| Callback used to return the result. If the widget state is obtained, **error** is undefined and **data** is the widget state obtained; otherwise, **error** is an error object.|
| callback | AsyncCallback<[FormInfo](js-apis-app-form-formInfo.md#formstateinfo)> | Yes| Callback used to return the result. If the widget state is obtained, **error** is undefined and **data** is the widget state obtained; otherwise, **error** is an error object.|
**Error codes**
**Error codes**
| Error Code ID| Error Message|
| Error Code ID| Error Message|
| -------- | -------- |
| -------- | -------- |
| 401 | Incorrect input parameter.|
| 401 | If the input parameter is not valid parameter. |
|For details about the error codes, see [Form Error Codes](../errorcodes/errorcode-form.md).|
|For details about the error codes, see [Form Error Codes](../errorcodes/errorcode-form.md).|
Unsubscribes from widget uninstall events. This API uses an asynchronous callback to return the result.
Unsubscribes from widget uninstall events. This API uses an asynchronous callback to return the result.
...
@@ -1233,18 +1178,16 @@ Unsubscribes from widget uninstall events. This API uses an asynchronous callbac
...
@@ -1233,18 +1178,16 @@ Unsubscribes from widget uninstall events. This API uses an asynchronous callbac
| Name| Type | Mandatory| Description |
| Name| Type | Mandatory| Description |
| ------ | ------ | ---- | ------- |
| ------ | ------ | ---- | ------- |
| type | string | Yes | Event type. The value **formUninstall** indicates a widget uninstallation event.|
| type | string | Yes | Event type. The value **'formUninstall'** indicates a widget uninstallation event.|
| callback | Callback<string> | No| Callback used to return the widget ID. If it is left unspecified, it indicates the callback for all the events that have been subscribed.<br> The value must be the same as that in **on("formUninstall")**.|
| callback | Callback<string> | No| Callback used to return the widget ID. If it is left unspecified, it indicates the callback for all the events that have been subscribed.<br> The value must be the same as that in **on('formUninstall')**.|
**Example**
**Example**
```ts
```ts
importformHostfrom'@ohos.app.form.formHost';
letcallback=function(formId){
letcallback=function(formId){
console.log('formHost on formUninstall, formId:'+formId);
console.log('formHost on formUninstall, formId:'+formId);
}
}
formHost.off("formUninstall",callback);
formHost.off('formUninstall',callback);
```
```
## notifyFormsVisible
## notifyFormsVisible
...
@@ -1269,23 +1212,21 @@ Instructs the widgets to make themselves visible. This API uses an asynchronous
...
@@ -1269,23 +1212,21 @@ Instructs the widgets to make themselves visible. This API uses an asynchronous
| Error Code ID| Error Message|
| Error Code ID| Error Message|
| -------- | -------- |
| -------- | -------- |
| 401 | Incorrect input parameter.|
| 401 | If the input parameter is not valid parameter. |
|For details about the error codes, see [Form Error Codes](../errorcodes/errorcode-form.md).|
|For details about the error codes, see [Form Error Codes](../errorcodes/errorcode-form.md).|
| callback | AsyncCallback\<void> | Yes| Callback used to return the result. If privacy protection is set successfully, **error** is undefined; otherwise, **error** is an error object.|
The **FormProvider** module provides APIs related to the widget provider. You can use the APIs to update a widget, set the next refresh time for a widget, obtain widget information, and request a widget release.
The **FormProvider** module provides APIs related to the widget provider. You can use the APIs to update a widget, set the next refresh time for a widget, obtain widget information, and request a widget release.
...
@@ -31,25 +31,23 @@ Sets the next refresh time for a widget. This API uses an asynchronous callback
...
@@ -31,25 +31,23 @@ Sets the next refresh time for a widget. This API uses an asynchronous callback
| Error Code ID| Error Message|
| Error Code ID| Error Message|
| -------- | -------- |
| -------- | -------- |
| 401 | Incorrect input parameter.|
| 401 | If the input parameter is not valid parameter. |
|For details about the error codes, see [Form Error Codes](../errorcodes/errorcode-form.md).|
|For details about the error codes, see [Form Error Codes](../errorcodes/errorcode-form.md).|
@@ -201,31 +193,29 @@ Obtains the application's widget information on the device. This API uses an asy
...
@@ -201,31 +193,29 @@ Obtains the application's widget information on the device. This API uses an asy
| Name| Type | Mandatory| Description |
| Name| Type | Mandatory| Description |
| ------ | ------ | ---- | ------- |
| ------ | ------ | ---- | ------- |
| callback | AsyncCallback<Array<[formInfo.FormInfo](js-apis-app-form-formInfo.md)>> | Yes| Callback used to return the information obtained.|
| callback | AsyncCallback<Array<[FormInfo](js-apis-app-form-formInfo.md)>> | Yes| Callback used to return the information obtained.|
**Error codes**
**Error codes**
| Error Code ID| Error Message|
| Error Code ID| Error Message|
| -------- | -------- |
| -------- | -------- |
| 401 | Incorrect input parameter.|
| 401 | If the input parameter is not valid parameter. |
|For details about the error codes, see [Form Error Codes](../errorcodes/errorcode-form.md).|
|For details about the error codes, see [Form Error Codes](../errorcodes/errorcode-form.md).|
| callback | AsyncCallback<Array<[formInfo.FormInfo](js-apis-app-form-formInfo.md)>> | Yes| Callback used to return the information obtained.|
| callback | AsyncCallback<Array<[FormInfo](js-apis-app-form-formInfo.md)>> | Yes| Callback used to return the information obtained.|
**Error codes**
**Error codes**
| Error Code ID| Error Message|
| Error Code ID| Error Message|
| -------- | -------- |
| -------- | -------- |
| 401 | Incorrect input parameter.|
| 401 | If the input parameter is not valid parameter. |
|For details about the error codes, see [Form Error Codes](../errorcodes/errorcode-form.md).|
|For details about the error codes, see [Form Error Codes](../errorcodes/errorcode-form.md).|
| want | [Want](js-apis-application-want.md) | Yes | Request used for publishing. The following fields must be included:<br>Information about the target widget.<br>**abilityName**: ability of the target widget.<br>**parameters**:<br>"ohos.extra.param.key.form_dimension"<br>"ohos.extra.param.key.form_name"<br>"ohos.extra.param.key.module_name" |
| want | [Want](js-apis-application-want.md) | Yes | Request used for publishing. The following fields must be included:<br>Information about the target widget.<br>**abilityName**: ability of the target widget.<br>**parameters**:<br>'ohos.extra.param.key.form_dimension'<br>'ohos.extra.param.key.form_name'<br>'ohos.extra.param.key.module_name' |
| formBindingData | [formBindingData.FormBindingData](js-apis-app-form-formBindingData.md#formbindingdata) | Yes | Data used for creating the widget.|
| formBindingData.FormBindingData | [FormBindingData](js-apis-app-form-formBindingData.md#formbindingdata) | Yes | Data used for creating the widget.|
| callback | AsyncCallback<string> | Yes| Callback used to return the widget ID.|
| callback | AsyncCallback<string> | Yes| Callback used to return the widget ID.|
**Error codes**
**Error codes**
| Error Code ID| Error Message|
| Error Code ID| Error Message|
| -------- | -------- |
| -------- | -------- |
| 401 | Incorrect input parameter.|
| 401 | If the input parameter is not valid parameter. |
|For details about the error codes, see [Form Error Codes](../errorcodes/errorcode-form.md).|
|For details about the error codes, see [Form Error Codes](../errorcodes/errorcode-form.md).|
| want | [Want](js-apis-application-want.md) | Yes | Request used for publishing. The following fields must be included:<br>Information about the target widget.<br>**abilityName**: ability of the target widget.<br>**parameters**:<br>"ohos.extra.param.key.form_dimension"<br>"ohos.extra.param.key.form_name"<br>"ohos.extra.param.key.module_name" |
| want | [Want](js-apis-application-want.md) | Yes | Request used for publishing. The following fields must be included:<br>Information about the target widget.<br>**abilityName**: ability of the target widget.<br>**parameters**:<br>'ohos.extra.param.key.form_dimension'<br>'ohos.extra.param.key.form_name'<br>'ohos.extra.param.key.module_name' |
| callback | AsyncCallback<string> | Yes | Callback used to return the widget ID.|
| callback | AsyncCallback<string> | Yes | Callback used to return the widget ID.|
**Error codes**
**Error codes**
| Error Code ID| Error Message|
| Error Code ID| Error Message|
| -------- | -------- |
| -------- | -------- |
| 401 | Incorrect input parameter.|
| 401 | If the input parameter is not valid parameter. |
|For details about the error codes, see [Form Error Codes](../errorcodes/errorcode-form.md).|
|For details about the error codes, see [Form Error Codes](../errorcodes/errorcode-form.md).|
| want | [Want](js-apis-application-want.md) | Yes | Request used for publishing. The following fields must be included:<br>Information about the target widget.<br>**abilityName**: ability of the target widget.<br>**parameters**:<br>"ohos.extra.param.key.form_dimension"<br>"ohos.extra.param.key.form_name"<br>"ohos.extra.param.key.module_name" |
| want | [Want](js-apis-application-want.md) | Yes | Request used for publishing. The following fields must be included:<br>Information about the target widget.<br>**abilityName**: ability of the target widget.<br>**parameters**:<br>'ohos.extra.param.key.form_dimension'<br>'ohos.extra.param.key.form_name'<br>'ohos.extra.param.key.module_name' |
| formBindingData | [formBindingData.FormBindingData](js-apis-app-form-formBindingData.md#formbindingdata) | No | Data used for creating the widget. |
| formBindingData.FormBindingData | [FormBindingData](js-apis-app-form-formBindingData.md#formbindingdata) | No | Data used for creating the widget. |
**Return value**
**Return value**
...
@@ -451,30 +434,28 @@ Requests to publish a widget to the widget host. This API uses a promise to retu
...
@@ -451,30 +434,28 @@ Requests to publish a widget to the widget host. This API uses a promise to retu
| Error Code ID| Error Message|
| Error Code ID| Error Message|
| -------- | -------- |
| -------- | -------- |
| 401 | Incorrect input parameter.|
| 401 | If the input parameter is not valid parameter. |
|For details about the error codes, see [Form Error Codes](../errorcodes/errorcode-form.md).|
|For details about the error codes, see [Form Error Codes](../errorcodes/errorcode-form.md).|
The **AbilityDelegatorRegistry** module provides APIs for storing the global registers of the registered **AbilityDelegator** and **AbilityDelegatorArgs** objects. You can use the APIs to obtain the **AbilityDelegator** and **AbilityDelegatorArgs** objects of an application.
The **AbilityDelegatorRegistry** module provides APIs for storing the global registers of the registered **AbilityDelegator** and **AbilityDelegatorArgs** objects. You can use the APIs to obtain the **AbilityDelegator** and **AbilityDelegatorArgs** objects of an application. The APIs can be used only in the test framework.
> **NOTE**
> **NOTE**
>
>
> The APIs of this module are supported since API version 8 and deprecated since API version 9. You are advised to use [@ohos.app.ability.abilityDelegatorRegistry](js-apis-app-ability-abilityDelegatorRegistry.md) instead. Newly added APIs will be marked with a superscript to indicate their earliest API version.
> The 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
## Modules to Import
...
@@ -43,7 +43,7 @@ Obtains the **AbilityDelegator** object of the application.
...
@@ -43,7 +43,7 @@ Obtains the **AbilityDelegator** object of the application.
@@ -4,13 +4,13 @@ The **AbilityManager** module provides APIs for obtaining, adding, and modifying
...
@@ -4,13 +4,13 @@ The **AbilityManager** module provides APIs for obtaining, adding, and modifying
> **NOTE**
> **NOTE**
>
>
> The APIs of this module are supported since API version 8 and deprecated since API version 9. You are advised to use [@ohos.app.ability.abilityManager](js-apis-app-ability-abilityManager.md) instead. Newly added APIs will be marked with a superscript to indicate their earliest API version.
> The 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.
> The APIs of this module are system APIs and cannot be called by third-party applications.
| upperLimit | number | Yes| Maximum number of messages that can be obtained.|
| callback | AsyncCallback\<Array\<[ExtensionRunningInfo](js-apis-inner-application-extensionRunningInfo.md)>> | Yes | Callback used to return the result. |
@@ -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**
| Name| Type| Mandatory| Description|
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| -------- | -------- | -------- | -------- |
| callback | AsyncCallback<boolean> | Yes| Callback used to return the result. If the application is undergoing a stability test, **true** will be returned; otherwise, **false** will be returned.|
| callback | AsyncCallback<boolean> | Yes| Callback used to return the result. If the application is undergoing a stability test, **true** will be returned; otherwise, **false** will be returned.|
**Example**
**Example**
...
@@ -46,9 +46,9 @@ Checks whether this application is undergoing a stability test. This API uses a
...
@@ -46,9 +46,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 result. If the application is undergoing a stability test, **true** will be returned; otherwise, **false** will be returned.|
| Promise<boolean> | Promise used to return the result. If the application is undergoing a stability test, **true** will be returned; otherwise, **false** will be returned.|
**Example**
**Example**
...
@@ -72,9 +72,9 @@ Checks whether this application is running on a RAM constrained device. This API
...
@@ -72,9 +72,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 whether the application is running on a RAM constrained device. If the application is running on a RAM constrained device, **true** will be returned; otherwise, **false** will be returned.|
| Promise<boolean> | Promise used to return whether the application is running on a RAM constrained device. If the application is running on a RAM constrained device, **true** will be returned; otherwise, **false** will be returned.|
**Example**
**Example**
...
@@ -96,9 +96,9 @@ Checks whether this application is running on a RAM constrained device. This API
...
@@ -96,9 +96,9 @@ Checks whether this application is running on a RAM constrained device. This API
**Parameters**
**Parameters**
| Name| Type| Mandatory| Description|
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| -------- | -------- | -------- | -------- |
| callback | AsyncCallback<boolean> | Yes| Callback used to return whether the application is running on a RAM constrained device. If the application is running on a RAM constrained device, **true** will be returned; otherwise, **false** will be returned.|
| callback | AsyncCallback<boolean> | Yes| Callback used to return whether the application is running on a RAM constrained device. If the application is running on a RAM constrained device, **true** will be returned; otherwise, **false** will be returned.|
**Example**
**Example**
...
@@ -119,9 +119,9 @@ Obtains the memory size of this application. This API uses a promise to return t
...
@@ -119,9 +119,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 memory size, in MB.|
| Promise<number> | Promise used to return the memory size, in MB.|
**Example**
**Example**
...
@@ -143,9 +143,9 @@ Obtains the memory size of this application. This API uses an asynchronous callb
...
@@ -143,9 +143,9 @@ Obtains the memory size of this application. This API uses an asynchronous callb
**Parameters**
**Parameters**
| Name| Type| Mandatory| Description|
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| -------- | -------- | -------- | -------- |
| callback | AsyncCallback<number> | Yes| Callback used to return the memory size, in MB.|
| callback | AsyncCallback<number> | Yes| Callback used to return the memory size, in MB.|
**Example**
**Example**
...
@@ -199,7 +199,7 @@ Obtains information about the running processes. This API uses an asynchronous c
...
@@ -199,7 +199,7 @@ Obtains information about the running processes. This API uses an asynchronous c
| Name| Type| Mandatory| Description|
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| -------- | -------- | -------- | -------- |
| callback | AsyncCallback\<Array\<[ProcessRunningInfo](js-apis-inner-application-processRunningInfo.md)>> | Yes| Obtains information about the running processes. This API uses a promise to return the result.|
| callback | AsyncCallback\<Array\<[ProcessRunningInfo](js-apis-inner-application-processRunningInfo.md)>> | Yes| Callback used to return the running processes. |
The **Configuration** module defines environment change information.
The **Configuration** module defines environment change information.**Configuration** is an interface definition and is used only for field declaration.
> **NOTE**
> **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 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.
> This module is deprecated since API version 9. You are advised to use [@ohos.app.ability.Configuration](js-apis-app-ability-configuration.md) instead.
> This module is deprecated since API version 9. You are advised to use [@ohos.app.ability.Configuration](js-apis-app-ability-configuration.md) instead.
| language<sup>8+</sup> | string | Yes| Yes| Language of the application, for example, **zh**.|
| language<sup>8+</sup> | string | Yes| Yes| Language of the application.|
| colorMode<sup>8+</sup> | [ColorMode](js-apis-application-configurationConstant.md#configurationconstantcolormode) | Yes| Yes| Color mode, which can be **COLOR_MODE_LIGHT** or **COLOR_MODE_DARK**. The default value is **COLOR_MODE_LIGHT**.|
| colorMode<sup>8+</sup> | [ColorMode](js-apis-application-configurationConstant.md#configurationconstantcolormode) | Yes| Yes| Color mode, which can be **COLOR_MODE_LIGHT** or **COLOR_MODE_DARK**. The default value is **COLOR_MODE_LIGHT**.|
| direction<sup>9+</sup> | [Direction](js-apis-application-configurationConstant.md#configurationconstantdirection9) | Yes| No| Screen orientation, which can be **DIRECTION_HORIZONTAL** or **DIRECTION_VERTICAL**.|
| screenDensity<sup>9+</sup> | [ScreenDensity](js-apis-application-configurationConstant.md#configurationconstantscreendensity9) | Yes| No| Screen resolution, which can be **SCREEN_DENSITY_SDPI** (120), **SCREEN_DENSITY_MDPI** (160), **SCREEN_DENSITY_LDPI** (240), **SCREEN_DENSITY_XLDPI** (320), **SCREEN_DENSITY_XXLDPI** (480), or **SCREEN_DENSITY_XXXLDPI** (640).|
| displayId<sup>9+</sup> | number | Yes| No| ID of the display where the application is located.|
| hasPointerDevice<sup>9+</sup> | boolean | Yes| No| Whether a pointer device, such as a keyboard, mouse, or touchpad, is connected.|
For details about the fields, see the **ohos.application.Configuration.d.ts** file.
For details about the fields, see the **ohos.application.Configuration.d.ts** file.
The **EnvironmentCallback** module provides APIs, such as **onConfigurationUpdated** and **onMemoryLevel**, for the application context to listen for system environment changes.
The **EnvironmentCallback** module provides APIs, such as **onConfigurationUpdated**, for the application context to listen for system environment changes.
> **NOTE**
> **NOTE**
>
>
> The APIs of this module are supported since API version 9 and are deprecated in versions later than API version 9. You are advised to use [@ohos.app.ability.EnvironmentCallback](js-apis-app-ability-environmentCallback.md) instead. Newly added APIs will be marked with a superscript to indicate their earliest API version.
> The APIs of this module are supported and deprecated in API version 9. You are advised to use [@ohos.app.ability.EnvironmentCallback](js-apis-app-ability-environmentCallback.md) instead. 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.
> The APIs of this module can be used only in the stage model.
| obj | Object\|string | No | Data to be displayed on the JS widget. The value can be an object containing multiple key-value pairs or a string in JSON format. The image data is identified by "formImages", and the content is multiple key-value pairs, each of which consists of an image identifier and image file descriptor. The final format is {"formImages": {"key1": fd1, "key2": fd2}}.|
| obj | Object\|string | No | Data to be displayed on the JS widget. The value can be an object containing multiple key-value pairs or a string in JSON format. The image data is identified by **'formImages'**, and the content is multiple key-value pairs, each of which consists of an image identifier and image file descriptor. The final format is {'formImages': {'key1': fd1, 'key2': fd2}}.|
**Return value**
**Return value**
...
@@ -48,17 +48,16 @@ Creates a **FormBindingData** object.
...
@@ -48,17 +48,16 @@ Creates a **FormBindingData** object.
The **formHost** module provides APIs related to the widget host, which is an application that displays the widget content and controls the position where the widget is displayed. You can use the APIs to delete, release, and update widgets installed by the same user, and obtain widget information and status.
The **FormHost** module provides APIs related to the widget host, which is an application that displays the widget content and controls the position where the widget is displayed. You can use the APIs to delete, release, and update widgets installed by the same user, and obtain widget information and status.
> **NOTE**
> **NOTE**
>
>
...
@@ -34,12 +34,10 @@ Deletes a widget. After this API is called, the application can no longer use th
...
@@ -34,12 +34,10 @@ Deletes a widget. After this API is called, the application can no longer use th
@@ -638,16 +596,14 @@ Obtains the widget information provided by all applications on the device. This
...
@@ -638,16 +596,14 @@ Obtains the widget information provided by all applications on the device. This
| Name| Type | Mandatory| Description |
| Name| Type | Mandatory| Description |
| ------ | ------ | ---- | ------- |
| ------ | ------ | ---- | ------- |
| callback | AsyncCallback<Array<[formInfo.FormInfo](js-apis-application-formInfo.md)>> | Yes| Callback used to return the result. If the widget information is obtained, **error** is undefined and **data** is the information obtained; otherwise, **error** is an error object.|
| callback | AsyncCallback<Array<[FormInfo](js-apis-application-formInfo.md)>> | Yes| Callback used to return the result. If the widget information is obtained, **error** is undefined and **data** is the information obtained; otherwise, **error** is an error object.|
@@ -697,16 +651,14 @@ Obtains the widget information provided by a given application on the device. Th
...
@@ -697,16 +651,14 @@ Obtains the widget information provided by a given application on the device. Th
| Name| Type | Mandatory| Description |
| Name| Type | Mandatory| Description |
| ------ | ------ | ---- | ------- |
| ------ | ------ | ---- | ------- |
| bundleName | string | Yes| Bundle name of the application.|
| bundleName | string | Yes| Bundle name of the application.|
| callback | AsyncCallback<Array<[formInfo.FormInfo](js-apis-application-formInfo.md)>> | Yes| Callback used to return the result. If the widget information is obtained, **error** is undefined and **data** is the information obtained; otherwise, **error** is an error object.|
| callback | AsyncCallback<Array<[FormInfo](js-apis-application-formInfo.md)>> | Yes| Callback used to return the result. If the widget information is obtained, **error** is undefined and **data** is the information obtained; otherwise, **error** is an error object.|
@@ -729,18 +681,16 @@ Obtains the widget information provided by a given application on the device. Th
...
@@ -729,18 +681,16 @@ Obtains the widget information provided by a given application on the device. Th
| ------ | ------ | ---- | ------- |
| ------ | ------ | ---- | ------- |
| bundleName | string | Yes| Bundle name of the application.|
| bundleName | string | Yes| Bundle name of the application.|
| moduleName | string | Yes| Module name.|
| moduleName | string | Yes| Module name.|
| callback | AsyncCallback<Array<[formInfo.FormInfo](js-apis-application-formInfo.md)>> | Yes| Callback used to return the result. If the widget information is obtained, **error** is undefined and **data** is the information obtained; otherwise, **error** is an error object.|
| callback | AsyncCallback<Array<[FormInfo](js-apis-application-formInfo.md)>> | Yes| Callback used to return the result. If the widget information is obtained, **error** is undefined and **data** is the information obtained; otherwise, **error** is an error object.|
@@ -862,26 +806,24 @@ Obtains the widget state. This API uses an asynchronous callback to return the r
...
@@ -862,26 +806,24 @@ Obtains the widget state. This API uses an asynchronous callback to return the r
| Name| Type | Mandatory| Description |
| Name| Type | Mandatory| Description |
| ------ | ------ | ---- | ------- |
| ------ | ------ | ---- | ------- |
| want | [Want](js-apis-application-want.md) | Yes | **Want** information carried to query the widget state. The information must contain the bundle name, ability name, module name, widget name, and widget dimensions.|
| want | [Want](js-apis-application-want.md) | Yes | **Want** information carried to query the widget state. The information must contain the bundle name, ability name, module name, widget name, and widget dimensions.|
| callback | AsyncCallback<[formInfo.FormStateInfo](js-apis-application-formInfo.md#formstateinfo)> | Yes| Callback used to return the result. If the widget state is obtained, **error** is undefined and **data** is the widget state obtained; otherwise, **error** is an error object.|
| callback | AsyncCallback<[FormStateInfo](js-apis-application-formInfo.md#formstateinfo)> | Yes| Callback used to return the result. If the widget state is obtained, **error** is undefined and **data** is the widget state obtained; otherwise, **error** is an error object.|
Unsubscribes from widget uninstall events. This API uses an asynchronous callback to return the result.
Unsubscribes from widget uninstall events. This API uses an asynchronous callback to return the result.
...
@@ -970,18 +908,16 @@ Unsubscribes from widget uninstall events. This API uses an asynchronous callbac
...
@@ -970,18 +908,16 @@ Unsubscribes from widget uninstall events. This API uses an asynchronous callbac
| Name| Type | Mandatory| Description |
| Name| Type | Mandatory| Description |
| ------ | ------ | ---- | ------- |
| ------ | ------ | ---- | ------- |
| type | string | Yes | Event type. The value **formUninstall** indicates a widget uninstallation event.|
| type | string | Yes | Event type. The value **'formUninstall'** indicates a widget uninstallation event.|
| callback | Callback<string> | No| Callback used to return the widget ID. If it is left unspecified, it indicates the callback for all the events that have been subscribed.<br> The value must be the same as that in **on("formUninstall")**.|
| callback | Callback<string> | No| Callback used to return the widget ID. If it is left unspecified, it indicates the callback for all the events that have been subscribed.<br> The value must be the same as that in **on('formUninstall')**.|
**Example**
**Example**
```ts
```ts
importformHostfrom'@ohos.application.formHost';
letcallback=function(formId){
letcallback=function(formId){
console.log('formHost on formUninstall, formId:'+formId);
console.log('formHost on formUninstall, formId:'+formId);
}
}
formHost.off("formUninstall",callback);
formHost.off('formUninstall',callback);
```
```
## notifyFormsVisible
## notifyFormsVisible
...
@@ -1005,12 +941,10 @@ Instructs the widgets to make themselves visible. This API uses an asynchronous
...
@@ -1005,12 +941,10 @@ Instructs the widgets to make themselves visible. This API uses an asynchronous
The **FormProvider** module provides APIs related to the widget provider. You can use the APIs to update a widget, set the next refresh time for a widget, obtain widget information, and request a widget release.
The **FormProvider** module provides APIs related to the widget provider. You can use the APIs to update a widget, set the next refresh time for a widget, obtain widget information, and request a widget release.
> **NOTE**
> **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 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.
> This module is deprecated since API version 9. You are advised to use [formProvider](js-apis-app-form-formProvider.md) instead.
> This module is deprecated since API version 9. You are advised to use [FormProvider](js-apis-app-form-formProvider.md) instead.
## Modules to Import
## Modules to Import
...
@@ -31,13 +31,11 @@ Sets the next refresh time for a widget. This API uses an asynchronous callback
...
@@ -31,13 +31,11 @@ Sets the next refresh time for a widget. This API uses an asynchronous callback
| formId | string | Yes | ID of the widget to update.|
| formId | string | Yes | ID of the widget to update.|
| formBindingData | [formBindingData.FormBindingData](js-apis-application-formBindingData.md#formbindingdata) | Yes | Data to be used for the update. |
| formBindingData.FormBindingData | [FormBindingData](js-apis-application-formBindingData.md#formbindingdata) | Yes | Data to be used for the update. |
| callback | AsyncCallback<void> | Yes| Callback used to return the result.|
| callback | AsyncCallback<void> | Yes| Callback used to return the result.|
| formId | string | Yes | ID of the widget to update.|
| formId | string | Yes | ID of the widget to update.|
| formBindingData | [formBindingData.FormBindingData](js-apis-application-formBindingData.md#formbindingdata) | Yes | Data to be used for the update. |
| formBindingData.FormBindingData | [FormBindingData](js-apis-application-formBindingData.md#formbindingdat) | Yes | Data to be used for the update. |
**Return value**
**Return value**
...
@@ -131,14 +125,12 @@ Updates a widget. This API uses a promise to return the result.
...
@@ -131,14 +125,12 @@ Updates a widget. This API uses a promise to return the result.
@@ -154,19 +146,17 @@ Obtains the application's widget information on the device. This API uses an asy
...
@@ -154,19 +146,17 @@ Obtains the application's widget information on the device. This API uses an asy
| Name| Type | Mandatory| Description |
| Name| Type | Mandatory| Description |
| ------ | ------ | ---- | ------- |
| ------ | ------ | ---- | ------- |
| callback | AsyncCallback<Array<[formInfo.FormInfo](./js-apis-application-formInfo.md#forminfo-1)>> | Yes| Callback used to return the information obtained.|
| callback | AsyncCallback<Array<[FormInfo](./js-apis-application-formInfo.md#forminfo-1)>> | Yes| Callback used to return the information obtained.|
| callback | AsyncCallback<Array<[formInfo.FormInfo](./js-apis-application-formInfo.md#forminfo-1)>> | Yes| Callback used to return the information obtained.|
| callback | AsyncCallback<Array<[FormInfo](./js-apis-application-formInfo.md#forminfo-1)>> | Yes| Callback used to return the information obtained.|
| want | [Want](js-apis-application-want.md) | Yes | Request used for publishing. The following fields must be included:<br>Information about the target widget.<br>**abilityName**: ability of the target widget.<br>**parameters**:<br>"ohos.extra.param.key.form_dimension"<br>"ohos.extra.param.key.form_name"<br>"ohos.extra.param.key.module_name" |
| want | [Want](js-apis-application-want.md) | Yes | Request used for publishing. The following fields must be included:<br>Information about the target widget.<br>**abilityName**: ability of the target widget.<br>**parameters**:<br>"ohos.extra.param.key.form_dimension"<br>"ohos.extra.param.key.form_name"<br>"ohos.extra.param.key.module_name" |
| formBindingData | [formBindingData.FormBindingData](js-apis-application-formBindingData.md#formbindingdata) | Yes | Data used for creating the widget.|
| formBindingData.FormBindingData | [FormBindingData](js-apis-application-formBindingData.md#formbindingdata) | Yes | Data used for creating the widget.|
| callback | AsyncCallback<string> | Yes| Callback used to return the widget ID.|
| callback | AsyncCallback<string> | Yes| Callback used to return the widget ID.|
| want | [Want](js-apis-application-want.md) | Yes | Request used for publishing. The following fields must be included:<br>Information about the target widget.<br>**abilityName**: ability of the target widget.<br>**parameters**:<br>"ohos.extra.param.key.form_dimension"<br>"ohos.extra.param.key.form_name"<br>"ohos.extra.param.key.module_name" |
| want | [Want](js-apis-application-want.md) | Yes | Request used for publishing. The following fields must be included:<br>Information about the target widget.<br>**abilityName**: ability of the target widget.<br>**parameters**:<br>"ohos.extra.param.key.form_dimension"<br>"ohos.extra.param.key.form_name"<br>"ohos.extra.param.key.module_name" |
| formBindingData | [formBindingData.FormBindingData](js-apis-application-formBindingData.md#formbindingdata) | Yes | Data used for creating the widget.|
| formBindingData.FormBindingData | [FormBindingData](js-apis-application-formBindingData.md#formbindingdata) | Yes | Data used for creating the widget.|
**Return value**
**Return value**
...
@@ -346,20 +329,18 @@ Requests to publish a widget to the widget host. This API uses a promise to retu
...
@@ -346,20 +329,18 @@ Requests to publish a widget to the widget host. This API uses a promise to retu
@@ -4,12 +4,12 @@ The **missionManager** module provides APIs to lock, unlock, and clear missions,
...
@@ -4,12 +4,12 @@ The **missionManager** module provides APIs to lock, unlock, and clear missions,
> **NOTE**
> **NOTE**
>
>
> The APIs of this module are supported since API version 8 and deprecated since API version 9. You are advised to use [@ohos.app.ability.missionManager](js-apis-app-ability-missionManager.md) instead. Newly added APIs will be marked with a superscript to indicate their earliest API version.
> The 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.
@@ -838,26 +797,22 @@ Switches a given mission to the foreground, with the startup parameters for the
...
@@ -838,26 +797,22 @@ Switches a given mission to the foreground, with the startup parameters for the
| Name| Type| Mandatory| Description|
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| -------- | -------- | -------- | -------- |
| missionId | number | Yes| Mission ID.|
| missionId | number | Yes| Mission ID.|
| options | [StartOptions](js-apis-application-startOptions.md) | Yes| Startup parameters, which are used to specify the window mode and device ID for switching the mission to the foreground.|
| options | [StartOptions](js-apis-app-ability-startOptions.md) | Yes| Startup parameters, which are used to specify the window mode and device ID for switching the mission to the foreground.|
| callback | AsyncCallback<void> | Yes| Callback used to return the result.|
| callback | AsyncCallback<void> | Yes| Callback used to return the result.|
@@ -880,7 +835,7 @@ Switches a given mission to the foreground, with the startup parameters for the
...
@@ -880,7 +835,7 @@ Switches a given mission to the foreground, with the startup parameters for the
| Name| Type| Mandatory| Description|
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| -------- | -------- | -------- | -------- |
| missionId | number | Yes| Mission ID.|
| missionId | number | Yes| Mission ID.|
| options | [StartOptions](js-apis-application-startOptions.md) | No| Startup parameters, which are used to specify the window mode and device ID for switching the mission to the foreground.|
| options | [StartOptions](js-apis-app-ability-startOptions.md) | No| Startup parameters, which are used to specify the window mode and device ID for switching the mission to the foreground.|
**Return value**
**Return value**
...
@@ -891,15 +846,15 @@ Switches a given mission to the foreground, with the startup parameters for the
...
@@ -891,15 +846,15 @@ Switches a given mission to the foreground, with the startup parameters for the
@@ -4,7 +4,7 @@ Want is a carrier for information transfer between objects (application componen
...
@@ -4,7 +4,7 @@ Want is a carrier for information transfer between objects (application componen
> **NOTE**
> **NOTE**
>
>
> The APIs of this module are supported since API version 8 and deprecated since API version 9. You are advised to use [Want](js-apis-app-ability-want.md) instead. Newly added APIs will be marked with a superscript to indicate their earliest API version.
> The APIs of this module are supported since API version 8 and deprecated since API version 9. You are advised to use [@ohos.app.ability.Want](js-apis-app-ability-want.md) instead. Newly added APIs will be marked with a superscript to indicate their earliest API version.
## Modules to Import
## Modules to Import
...
@@ -18,119 +18,117 @@ import Want from '@ohos.application.Want';
...
@@ -18,119 +18,117 @@ import Want from '@ohos.application.Want';
| deviceId | string | No | ID of the device running the ability. If this field is unspecified, the local device is used. |
| deviceId | string | No | ID of the device running the ability. |
| bundleName | string | No | Bundle name.|
| bundleName | string | No | Bundle name. If both **bundleName** and **abilityName** are specified in a bWantb, the **Want** can directly match the specified ability.|
| abilityName | string | No | Name of the ability. If both **bundleName** and **abilityName** are specified in a **Want** object, the **Want** object can match a specific ability. The value of **abilityName** must be unique in an application.|
| abilityName | string | No | Name of the ability. If both **bundleName** and **abilityName** are specified in a **Want** object, the **Want** object can match a specific ability. The value of **abilityName** must be unique in an application.|
| uri | string | No | URI information to match. If **uri** is specified in a **Want** object, the **Want** object will match the specified URI information, including **scheme**, **schemeSpecificPart**, **authority**, and **path**.|
| uri | string | No | URI information to match. If **uri** is specified in a **Want** object, the **Want** object will match the specified URI information, including **scheme**, **schemeSpecificPart**, **authority**, and **path**.|
| type | string | No | MIME type, that is, the type of the file to open, for example, **text/xml** and **image/***. For details about the MIME type definition, see https://www.iana.org/assignments/media-types/media-types.xhtml?utm_source=ld246.com. |
| type | string | No | MIME type, that is, the type of the file to open, for example, **'text/xml'** and **'image/*'**. For details about the MIME type definition, see https://www.iana.org/assignments/media-types/media-types.xhtml?utm_source=ld246.com. |
| flags | number | No | How the **Want** object will be handled. By default, numbers are passed in. For details, see [flags](js-apis-ability-wantConstant.md#wantConstant.Flags).|
| flags | number | No | How the **Want** object will be handled. By default, numbers are passed in. For details, see [flags](js-apis-ability-wantConstant.md#wantConstant.Flags).|
| action | string | No | Action to take, such as viewing and sharing application details. In implicit **Want**, you can define this attribute and use it together with **uri** or **parameters** to specify the operation to be performed on the data. For details, see [action](js-apis-app-ability-wantConstant.md#wantConstant.Action). For details about the definition and matching rules of implicit Want, see [Matching Rules of Explicit Want and Implicit Want](application-models/explicit-implicit-want-mappings.md). |
| action | string | No | Action to take, such as viewing and sharing application details. In implicit **Want**, you can define this attribute and use it together with **uri** or **parameters** to specify the operation to be performed on the data. |
| parameters | {[key: string]: any} | No | Want parameters in the form of custom key-value (KV) pairs. By default, the following keys are carried:<br>**ohos.aafwk.callerPid**: PID of the caller.<br>**ohos.aafwk.param.callerToken**: token of the caller.<br>**ohos.aafwk.param.callerUid**: UID in [bundleInfo](js-apis-bundle-BundleInfo.md#bundleinfo-1), that is, the application UID in the bundle information. |
| parameters | {[key: string]: any} | No | Want parameters in the form of custom key-value (KV) pairs. By default, the following keys are carried:<br>- **ohos.aafwk.callerPid**: PID of the caller.<br>- **ohos.aafwk.param.callerToken**: token of the caller.<br>- **ohos.aafwk.param.callerUid**: UID in [bundleInfo](js-apis-bundle-BundleInfo.md#bundleinfo-1), that is, the application UID in the bundle information.<br>- **component.startup.newRules**: whether to enable the new control rule.<br>- **moduleName**: module name of the caller. No matter what this field is set to, the correct module name will be sent to the peer.<br>- **ohos.dlp.params.sandbox**: available only for DLP files. |
| entities | Array\<string> | No | Additional category information (such as browser and video player) of the ability. It is a supplement to the **action** field for implicit Want. and is used to filter ability types. For details, see [entity](js-apis-app-ability-wantConstant.md#wantConstant.Entity). |
| entities | Array\<string> | No | Additional category information (such as browser and video player) of the ability. It is a supplement to the **action** field for implicit Want. and is used to filter ability types. |
| moduleName<sup>9+</sup> | string | No | Module to which the ability belongs.|
| moduleName<sup>9+</sup> | string | No | Module to which the ability belongs.|
**Example**
**Example**
- Basic usage (called in a UIAbility object, where context in the example is the context object of the UIAbility).
- Basic usage
```ts
```ts
letwant={
letwant={
"deviceId":"",// An empty deviceId indicates the local device.
'deviceId':'',// An empty deviceId indicates the local device.
"bundleName":"com.example.myapplication",
'bundleName':'com.extreme.test',
"abilityName":"EntryAbility",
'abilityName':'MainAbility',
"moduleName":"entry"// moduleName is optional.
'moduleName':'entry'// moduleName is optional.
};
};
this.context.startAbility(want,(error)=>{
this.context.startAbility(want,(error)=>{
// Start an ability explicitly. The bundleName, abilityName, and moduleName parameters work together to uniquely identify an ability.
// Start an ability explicitly. The bundleName, abilityName, and moduleName parameters work together to uniquely identify an ability.
console.log("error.code = "+error.code)
console.log('error.code = '+error.code)
})
});
```
```
- Data is transferred through user-defined fields. The following data types are supported (called in a UIAbility object, where context in the example is the context object of the UIAbility):
- Data is transferred through user-defined fields. The following data types are supported:
> 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 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.
> The APIs provided by this module are system APIs.
>
>
> The APIs of this module can be used only in the stage model.
> The APIs of this module can be used only in the stage model.
...
@@ -22,7 +22,7 @@ import WindowExtensionAbility from '@ohos.application.WindowExtensionAbility';
...
@@ -22,7 +22,7 @@ import WindowExtensionAbility from '@ohos.application.WindowExtensionAbility';
**ConnectOptions** can be used as an input parameter to receive status changes during the connection to a background service. For example, it is used as an input parameter of [connectServiceExtensionAbility](js-apis-inner-application-uiAbilityContext.md#uiabilitycontextconnectserviceextensionability) to connect to a ServiceExtensionAbility.
**ConnectOptions** can be used as an input parameter to receive status changes during the connection to a background service. For example, it is used as an input parameter of [connectServiceExtensionAbility](js-apis-inner-application-serviceExtensionContext.md#serviceextensioncontextconnectserviceextensionability) to connect to a ServiceExtensionAbility.
| uri | string | Yes | URI of the DataAbility. Example: "dataability:///com.example.xxx.xxxx".|
| uri | string | Yes | URI of the DataAbility. Example: 'dataability:///com.example.xxx.xxxx'.|
| operations | Array\<[DataAbilityOperation](js-apis-inner-ability-dataAbilityOperation.md)> | Yes | An array holding the data operations on the database. |
| operations | Array\<[DataAbilityOperation](js-apis-inner-ability-dataAbilityOperation.md)> | Yes | An array holding the data operations on the database. |
| callback | AsyncCallback\<Array\<[DataAbilityResult](js-apis-inner-ability-dataAbilityResult.md)>> | Yes | Callback used to return the result of each operation in the **DataAbilityResult** array. |
| callback | AsyncCallback\<Array\<[DataAbilityResult](js-apis-inner-ability-dataAbilityResult.md)>> | Yes | Callback used to return the result of each operation in the **DataAbilityResult** array. |
...
@@ -899,9 +906,9 @@ import featureAbility from '@ohos.ability.featureAbility';
...
@@ -899,9 +906,9 @@ import featureAbility from '@ohos.ability.featureAbility';
// Select the operations to be performed on the database according to the DataAbilityOperation array.
// Select the operations to be performed on the database according to the DataAbilityOperation array.
| uri | string | Yes | URI of the DataAbility. Example: "dataability:///com.example.xxx.xxxx".|
| uri | string | Yes | URI of the DataAbility. Example: 'dataability:///com.example.xxx.xxxx'.|
| operations | Array\<[DataAbilityOperation](js-apis-inner-ability-dataAbilityOperation.md)> | Yes | An array holding the data operations on the database. |
| operations | Array\<[DataAbilityOperation](js-apis-inner-ability-dataAbilityOperation.md)> | Yes | An array holding the data operations on the database. |
**Return value**
**Return value**
...
@@ -939,9 +946,9 @@ import featureAbility from '@ohos.ability.featureAbility';
...
@@ -939,9 +946,9 @@ import featureAbility from '@ohos.ability.featureAbility';
// Select the operations to be performed on the database according to the DataAbilityOperation array.
// Select the operations to be performed on the database according to the DataAbilityOperation array.
@@ -4,21 +4,21 @@ Want is a carrier for information transfer between objects (application componen
...
@@ -4,21 +4,21 @@ Want is a carrier for information transfer between objects (application componen
> **NOTE**
> **NOTE**
>
>
> The initial APIs of this module are supported since API version 6. Newly added APIs will be marked with a superscript to indicate their earliest API version.
> The APIs of this module are supported since API version 6 and deprecated since API version 9. You are advised to use [@ohos.app.ability.Want](js-apis-app-ability-want.md) instead. Newly added APIs will be marked with a superscript to indicate their earliest API version.
| deviceId | string | No | ID of the device running the ability. If this field is unspecified, the local device is used. |
| deviceId | string | No | ID of the device running the ability. |
| bundleName | string | No | Bundle name.|
| bundleName | string | No | Bundle name. If both **bundleName** and **abilityName** are specified in a **Want**, the **Want** can directly match the specified ability.|
| abilityName | string | No | Name of the ability. If both **bundleName** and **abilityName** are specified in a **Want** object, the **Want** object can match a specific ability. The value of **abilityName** must be unique in an application.|
| abilityName | string | No | Name of the ability. If both **bundleName** and **abilityName** are specified in a **Want** object, the **Want** object can match a specific ability. The value of **abilityName** must be unique in an application.|
| uri | string | No | URI. If **uri** is specified in a **Want** object, the **Want** object will match the specified URI information, including **scheme**, **schemeSpecificPart**, **authority**, and **path**.|
| uri | string | No | URI. If **uri** is specified in a **Want** object, the **Want** object will match the specified URI information, including **scheme**, **schemeSpecificPart**, **authority**, and **path**.|
| type | string | No | MIME type, that is, the type of the file to open, for example, **text/xml** and **image/***. For details about the MIME type definition, see https://www.iana.org/assignments/media-types/media-types.xhtml?utm_source=ld246.com. |
| type | string | No | MIME type, that is, the type of the file to open, for example, **'text/xml'** and **'image/*'**. For details about the MIME type definition, see https://www.iana.org/assignments/media-types/media-types.xhtml?utm_source=ld246.com. |
| flags | number | No | How the **Want** object will be handled. By default, numbers are passed in. For details, see [flags](js-apis-ability-wantConstant.md#wantconstantflags). |
| flags | number | No | How the **Want** object will be handled. By default, numbers are passed in. For details, see [flags](js-apis-ability-wantConstant.md#wantconstantflags). |
| action | string | No | Action to take, such as viewing and sharing application details. In implicit Want, you can define this field and use it together with **uri** or **parameters** to specify the operation to be performed on the data. For details, see [action](js-apis-app-ability-wantConstant.md#wantconstantaction). For details about the definition and matching rules of implicit Want, see [Matching Rules of Explicit Want and Implicit Want](../../application-models/explicit-implicit-want-mappings.md). |
| action | string | No | Action to take, such as viewing and sharing application details. In implicit Want, you can define this field and use it together with **uri** or **parameters** to specify the operation to be performed on the data. |
| parameters | {[key: string]: any} | No | Want parameters in the form of custom key-value (KV) pairs. By default, the following keys are carried:<br>**ohos.aafwk.callerPid**: PID of the caller.<br>**ohos.aafwk.param.callerToken**: token of the caller.<br>**ohos.aafwk.param.callerUid**: UID in [bundleInfo](js-apis-bundle-BundleInfo.md#bundleinfo-1), that is, the application UID in the bundle information. |
| parameters | {[key: string]: any} | No | Want parameters in the form of custom key-value (KV) pairs. By default, the following keys are carried:<br>**ohos.aafwk.callerPid**: PID of the caller.<br>**ohos.aafwk.param.callerToken**: token of the caller.<br>**ohos.aafwk.param.callerUid**: UID in [bundleInfo](js-apis-bundle-BundleInfo.md#bundleinfo-1), that is, the application UID in the bundle information.<br>- **component.startup.newRules**: whether to enable the new control rule.<br>- **moduleName**: module name of the caller. No matter what this field is set to, the correct module name will be sent to the peer.<br>- **ohos.dlp.params.sandbox**: available only for DLP files. |
| entities | Array\<string> | No | Additional category information (such as browser and video player) of the target ability. It is a supplement to **action** in implicit Want and is used to filter ability types. For details, see [entity](js-apis-app-ability-wantConstant.md#wantconstantentity). |
| entities | Array\<string> | No | Additional category information (such as browser and video player) of the target ability. It is a supplement to **action** in implicit Want and is used to filter ability types. |
| moduleName<sup>9+</sup> | string | No | Module to which the ability belongs.|
| moduleName<sup>9+</sup> | string | No | Module to which the ability belongs.|
**Example**
**Example**
...
@@ -27,42 +27,42 @@ Want is a carrier for information transfer between objects (application componen
...
@@ -27,42 +27,42 @@ Want is a carrier for information transfer between objects (application componen
```ts
```ts
letwant={
letwant={
"deviceId":"",// An empty deviceId indicates the local device.
'deviceId':'',// An empty deviceId indicates the local device.
"bundleName":"com.example.myapplication",
'bundleName':'com.extreme.test',
"abilityName":"EntryAbility",
'abilityName':'MainAbility',
"moduleName":"entry"// moduleName is optional.
'moduleName':'entry'// moduleName is optional.
};
};
this.context.startAbility(want,(error)=>{
this.context.startAbility(want,(error)=>{
// Start an ability explicitly. The bundleName, abilityName, and moduleName parameters work together to uniquely identify an ability.
// Start an ability explicitly. The bundleName, abilityName, and moduleName parameters work together to uniquely identify an ability.
console.log("error.code = "+error.code)
console.log('error.code = '+error.code)
})
});
```
```
- Passing a file descriptor (FD) (called in the UIAbility object, where context in the example is the context object of the UIAbility):
- Passing a file descriptor (FD) (called in the UIAbility object, where context in the example is the context object of the UIAbility):
| callback | AsyncCallback\<[bundle.DisplayOrientation](js-apis-bundleManager.md#displayorientation)> | Yes | Callback used to return the display orientation.|
| callback | AsyncCallback\<[bundle.DisplayOrientation](js-apis-Bundle.md#displayorientation)> | Yes | Callback used to return the display orientation.|
| callback | AsyncCallback\<[ElementName](js-apis-bundleManager-elementName.md)> | Yes | Callback used to return the **ohos.bundle.ElementName** object.|
| callback | AsyncCallback\<[ElementName](js-apis-bundle-ElementName.md)> | Yes | Callback used to return the **ohos.bundle.ElementName** object.|
The **ProcessInfo** module defines process information. You can use [getProcessInfo](js-apis-inner-app-context.md#contextgetprocessinfo7) to obtain information about the processes running on the current ability.
The **ProcessInfo** module defines process information. You can use [getProcessInfo](js-apis-inner-app-context.md#contextgetprocessinfo7) to obtain information about the processes running on the current ability.
> **NOTE**
> **NOTE**
>
>
> The initial APIs of this module are supported since API version 7. 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 7. 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 FA model.
The **AbilityDelegatorArgs** module provides APIs to obtain an **AbilityDelegatorArgs** object during the execution of test cases.
The **AbilityDelegatorArgs** module provides a global register to store the registered **AbilityDelegator** and **AbilityDelegatorArgs** instances during application startup.
> **NOTE**
> **NOTE**
>
>
...
@@ -28,5 +28,5 @@ Describes the ability delegator arguments.
...
@@ -28,5 +28,5 @@ Describes the ability delegator arguments.
| abilityName | string | Yes | Yes | Name of the ability bound to the ability monitor.|
| abilityName | string | Yes | Yes | Name of the ability bound to the ability monitor.|
| moduleName? | string | Yes | Yes | Name of the module bound to the ability monitor.|
| onAbilityCreate?:(data: [UIAbility](js-apis-app-ability-uiAbility.md)) | function | Yes | Yes | Called when the ability is created.<br>If this attribute is not set, the corresponding lifecycle callback cannot be received.|
| onAbilityCreate?:(data: [UIAbility](js-apis-app-ability-uiAbility.md)) | function | Yes | Yes | Called when the ability is created.<br>If this attribute is not set, the corresponding lifecycle callback cannot be received.|
| onAbilityForeground?:(data: [UIAbility](js-apis-app-ability-uiAbility.md)) | function | Yes | Yes | Called when the ability starts to run in the foreground.<br>If this attribute is not set, the corresponding lifecycle callback cannot be received.|
| onAbilityForeground?:(data: [UIAbility](js-apis-app-ability-uiAbility.md)) | function | Yes | Yes | Called when the ability starts to run in the foreground.<br>If this attribute is not set, the corresponding lifecycle callback cannot be received.|
| onAbilityBackground?:(data: [UIAbility](js-apis-app-ability-uiAbility.md)) | function | Yes | Yes | Called when the ability starts to run in the background.<br>If this attribute is not set, the corresponding lifecycle callback cannot be received.|
| onAbilityBackground?:(data: [UIAbility](js-apis-app-ability-uiAbility.md)) | function | Yes | Yes | Called when the ability starts to run in the background.<br>If this attribute is not set, the corresponding lifecycle callback cannot be received.|
The **AbilityStageContext** module, inherited from [Context](js-apis-application-context.md), implements the context of an ability stage.
The **AbilityStageContext** module, inherited from [Context](js-apis-inner-application-context.md), implements the context of an ability stage.
This module provides APIs for accessing a specific ability stage. You can use the APIs to obtain the **ModuleInfo** object and environment configuration of an ability stage.
This module provides APIs for accessing a specific ability stage. You can use the APIs to obtain the **ModuleInfo** object and environment configuration of an ability stage.
...
@@ -28,5 +28,5 @@ class MyAbilityStage extends AbilityStage {
...
@@ -28,5 +28,5 @@ class MyAbilityStage extends AbilityStage {
| bundleName<sup>8+</sup> | string | No | Bundle name.|
| bundleName<sup>8+</sup> | string | No | Bundle name.|
| uid<sup>8+</sup> | number | No | UID of the application. |
| uid<sup>8+</sup> | number | No | UID of the application. |
| state<sup>8+</sup> | number | No | Application state.<br>**0**: The application is being initialized.<br>**1**: The application has been initialized and is ready.<br>**2**: The application is running in the foreground.<br>**3**: The application is having the focus. (This state is reserved.)<br>**4**: The application is running in the background.<br>**5**: The application has exited.|
| state<sup>8+</sup> | number | No | Application state.|
| callback | [AbilityLifecycleCallback](js-apis-app-ability-abilityLifecycleCallback.md) | Yes | Callback used to return the ID of the registered listener.|
| callback | [AbilityLifecycleCallback](js-apis-app-ability-abilityLifecycleCallback.md) | Yes | Callback used to return the ID of the registered listener.|
**Return value**
**Return value**
...
@@ -40,56 +41,56 @@ Registers a listener to monitor the ability lifecycle of the application.
...
@@ -40,56 +41,56 @@ Registers a listener to monitor the ability lifecycle of the application.
**System API**: This is a system API and cannot be called by third-party applications.
**Return value**
| Type| Description|
| -------- | -------- |
| Promise\<Array\<[ProcessInformation](js-apis-inner-application-processInformation.md)>> | Promise used to return the API call result and the process running information. You can perform error handling or custom processing in this callback.|
**System API**: This is a system API and cannot be called by third-party applications.
**Return value**
| Type| Description|
| -------- | -------- |
|AsyncCallback\<Array\<[ProcessInformation](js-apis-inner-application-processInformation.md)>> | Callback used to return the API call result and the process running information. You can perform error handling or custom processing in this callback.|
The **ContinueCallback** module defines the callback function that indicates the result of mission continuation. For details about mission continuation, see [continueMission](js-apis-distributedMissionManager.md#distributedmissionmanagercontinuemission).
The **ContinueCallback** module defines the callback function that indicates the result of mission continuation. For details about mission continuation, see [continueMission](js-apis-distributedMissionManager.md#distributedmissionmanagercontinuemission).
The **ErrorObserver** module defines an observer to listen for application errors. It can be used as an input parameter in [ErrorManager.on](js-apis-app-ability-errorManager.md#errormanageron) to listen for errors that occur in the current application.
The **ErrorObserver** module defines an observer to listen for application errors. It can be used as an input parameter in [registerErrorObserver](js-apis-application-errorManager.md#errormanagerregistererrorobserver) to listen for errors that occur in the current application.
## ErrorObserver.onUnhandledException
## onUnhandledException
onUnhandledException(errMsg: string): void;
onUnhandledException(errMsg: string): void;
...
@@ -19,18 +19,12 @@ Called when an unhandled exception occurs in the JS runtime.
...
@@ -19,18 +19,12 @@ Called when an unhandled exception occurs in the JS runtime.
@@ -9,18 +9,16 @@ The **EventHub** module provides APIs to subscribe to, unsubscribe from, and tri
...
@@ -9,18 +9,16 @@ The **EventHub** module provides APIs to subscribe to, unsubscribe from, and tri
## Usage
## Usage
Before using any APIs in the **EventHub**, you must obtain an **EventHub** instance through the member variable **context** of the **UIAbility** instance.
Before using any APIs in the **EventHub**, you must obtain an **EventHub** instance through the member variable **context** of the **Ability** instance.
> - 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 9. Newly added APIs will be marked with a superscript to indicate their earliest API version.
> - This module is marked as @systemapi and not visible to third-party applications.
> - The APIs of this module are system APIs and cannot be called by third-party applications.
## Usage
## Usage
...
@@ -17,37 +17,29 @@ Import the **abilityManager** module and obtain the ExtensionAbility running inf
...
@@ -17,37 +17,29 @@ Import the **abilityManager** module and obtain the ExtensionAbility running inf
The **MissionListener** module defines the listeners used to observe the mission status. The listeners can be registered by using [on](js-apis-app-ability-missionManager.md#missionmanageron).
The **MissionListener** module defines the listeners used to observe the mission status. The listeners can be registered by using [registerMissionListener](js-apis-application-missionManager.md#missionmanagerregistermissionlistener).
context=this.context;// Obtain a ServiceExtensionContext instance.
context=this.context;// Obtain a ServiceExtensionContext instance.
}
}
...
@@ -68,9 +68,9 @@ Starts an ability. This API uses an asynchronous callback to return the result.
...
@@ -68,9 +68,9 @@ Starts an ability. This API uses an asynchronous callback to return the result.
**Example**
**Example**
```ts
```ts
varwant={
letwant={
bundleName:"com.example.myapp",
bundleName:'com.example.myapp',
abilityName:"MyAbility"
abilityName:'MyAbility'
};
};
try{
try{
...
@@ -141,11 +141,11 @@ Starts an ability. This API uses a promise to return the result.
...
@@ -141,11 +141,11 @@ Starts an ability. This API uses a promise to return the result.
**Example**
**Example**
```ts
```ts
varwant={
letwant={
bundleName:"com.example.myapp",
bundleName:'com.example.myapp',
abilityName:"MyAbility"
abilityName:'MyAbility'
};
};
varoptions={
letoptions={
windowMode:0,
windowMode:0,
};
};
...
@@ -212,12 +212,12 @@ Starts an ability with the start options specified. This API uses an asynchronou
...
@@ -212,12 +212,12 @@ Starts an ability with the start options specified. This API uses an asynchronou
**Example**
**Example**
```ts
```ts
varwant={
letwant={
deviceId:"",
deviceId:'',
bundleName:"com.example.myapplication",
bundleName:'com.extreme.test',
abilityName:"EntryAbility"
abilityName:'MainAbility'
};
};
varoptions={
letoptions={
windowMode:0
windowMode:0
};
};
...
@@ -247,7 +247,7 @@ Starts an ability with the account ID specified. This API uses an asynchronous c
...
@@ -247,7 +247,7 @@ Starts an ability with the account ID specified. This API uses an asynchronous c
Observe the following when using this API:
Observe the following when using this API:
- If an application running in the background needs to call this API to start an ability, it must have the **ohos.permission.START_ABILITIES_FROM_BACKGROUND** permission.
- If an application running in the background needs to call this API to start an ability, it must have the **ohos.permission.START_ABILITIES_FROM_BACKGROUND** permission.
- If **visible** of the target ability is **false** in cross-application scenarios, the caller must have the **ohos.permission.START_INVISIBLE_ABILITY** permission.
- If **visible** of the target ability is **false**, the caller must have the **ohos.permission.START_INVISIBLE_ABILITY** permission.
- For details about the startup rules for the components in the stage model, see [Component Startup Rules (Stage Model)](../../application-models/component-startup-rules.md).
- For details about the startup rules for the components in the stage model, see [Component Startup Rules (Stage Model)](../../application-models/component-startup-rules.md).
@@ -323,7 +323,7 @@ Starts an ability with the account ID and start options specified. This API uses
...
@@ -323,7 +323,7 @@ Starts an ability with the account ID and start options specified. This API uses
Observe the following when using this API:
Observe the following when using this API:
- If an application running in the background needs to call this API to start an ability, it must have the **ohos.permission.START_ABILITIES_FROM_BACKGROUND** permission.
- If an application running in the background needs to call this API to start an ability, it must have the **ohos.permission.START_ABILITIES_FROM_BACKGROUND** permission.
- If **visible** of the target ability is **false** in cross-application scenarios, the caller must have the **ohos.permission.START_INVISIBLE_ABILITY** permission.
- If **visible** of the target ability is **false**, the caller must have the **ohos.permission.START_INVISIBLE_ABILITY** permission.
- For details about the startup rules for the components in the stage model, see [Component Startup Rules (Stage Model)](../../application-models/component-startup-rules.md).
- For details about the startup rules for the components in the stage model, see [Component Startup Rules (Stage Model)](../../application-models/component-startup-rules.md).
@@ -367,13 +367,13 @@ Observe the following when using this API:
...
@@ -367,13 +367,13 @@ Observe the following when using this API:
**Example**
**Example**
```ts
```ts
varwant={
letwant={
deviceId:"",
deviceId:'',
bundleName:"com.example.myapplication",
bundleName:'com.extreme.test',
abilityName:"EntryAbility"
abilityName:'MainAbility'
};
};
varaccountId=100;
letaccountId=100;
varoptions={
letoptions={
windowMode:0
windowMode:0
};
};
...
@@ -404,7 +404,7 @@ Starts an ability with the account ID specified. This API uses a promise to retu
...
@@ -404,7 +404,7 @@ Starts an ability with the account ID specified. This API uses a promise to retu
Observe the following when using this API:
Observe the following when using this API:
- If an application running in the background needs to call this API to start an ability, it must have the **ohos.permission.START_ABILITIES_FROM_BACKGROUND** permission.
- If an application running in the background needs to call this API to start an ability, it must have the **ohos.permission.START_ABILITIES_FROM_BACKGROUND** permission.
- If **visible** of the target ability is **false** in cross-application scenarios, the caller must have the **ohos.permission.START_INVISIBLE_ABILITY** permission.
- If **visible** of the target ability is **false**, the caller must have the **ohos.permission.START_INVISIBLE_ABILITY** permission.
- For details about the startup rules for the components in the stage model, see [Component Startup Rules (Stage Model)](../../application-models/component-startup-rules.md).
- For details about the startup rules for the components in the stage model, see [Component Startup Rules (Stage Model)](../../application-models/component-startup-rules.md).
@@ -1317,8 +1317,8 @@ Starts an ability in the foreground or background and obtains the caller object
...
@@ -1317,8 +1317,8 @@ Starts an ability in the foreground or background and obtains the caller object
Observe the following when using this API:
Observe the following when using this API:
- If an application running in the background needs to call this API to start an ability, it must have the **ohos.permission.START_ABILITIES_FROM_BACKGROUND** permission.
- If an application running in the background needs to call this API to start an ability, it must have the **ohos.permission.START_ABILITIES_FROM_BACKGROUND** permission.
- If **visible** of the target ability is **false** in cross-application scenarios, the caller must have the **ohos.permission.START_INVISIBLE_ABILITY** permission.
- If **visible** of the target ability is **false**, the caller must have the **ohos.permission.START_INVISIBLE_ABILITY** permission.
-The rules for using this API in the same-device and cross-device scenarios are different. For details, see [Component Startup Rules (Stage Model)](../../application-models/component-startup-rules.md).
-For details about the startup rules for the components in the stage model, see [Component Startup Rules (Stage Model)](../../application-models/component-startup-rules.md).
The **WindowExtensionContext** module, inherited from [ExtensionContext](js-apis-inner-application-extensionContext.md), is the context environment of the WindowExtensionAbility.
The **WindowExtensionContext** module provides the capabilities of the [WindowExtensionAbility](js-apis-application-windowExtensionAbility.md), including starting the ability.
> **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.
>
> - The APIs of this module can be used only in the stage model.
## Usage
Before using the **WindowExtensionContext** module, you must define a child class that inherits from **WindowExtensionAbility**.
| requestCode | number | Yes | Request code defined by the user.|
| requestCode | number | Yes | Request code defined by the user.|
| wantAgentFlags | Array<[wantAgent.WantAgentFlags](js-apis-app-ability-wantAgent.md#wantagentflags)> | No | Array of flags for using the **WantAgent** object. |
| wantAgentFlags | Array<[wantAgent.WantAgentFlags](js-apis-app-ability-wantAgent.md#wantagentflags)> | No | Array of flags for using the **WantAgent** object. |
| extraInfo | {[key: string]: any} | No | Extra information. |
| extraInfo | {[key: string]: any} | No | Extra information. |
The **WantAgent** module provides APIs for creating and comparing **WantAgent** objects, and obtaining the user ID and bundle name of a **WantAgent** object.
The **WantAgent** module provides APIs for creating and comparing **WantAgent** objects, and obtaining the user ID and bundle name of a **WantAgent** object.
...
@@ -16,7 +16,7 @@ import WantAgent from '@ohos.wantAgent';
...
@@ -16,7 +16,7 @@ import WantAgent from '@ohos.wantAgent';
Obtains a **WantAgent** object. This API uses an asynchronous callback to return the result.
Obtains a **WantAgent** object. This API uses an asynchronous callback to return the result. If the creation fails, a null **WantAgent** object is returned.