未验证 提交 47dc3ed3 编写于 作者: O openharmony_ci 提交者: Gitee

!15339 翻译完成:14771+14165等 元能力API资料示例代码规范修改

Merge pull request !15339 from wusongqing/TR14771
......@@ -10,7 +10,7 @@ The **Ability** module provides all level-2 module APIs for developers to export
## Modules to Import
```ts
import ability from '@ohos.ability.ability'
import ability from '@ohos.ability.ability';
```
**System capability**: SystemCapability.Ability.AbilityBase
......
# @ohos.ability.dataUriUtils (dataUriUtils)
# @ohos.ability.dataUriUtils (DataUriUtils)
The **DataUriUtils** module provides APIs to process URI objects. You can use the APIs to attach an ID to the end of a given URI and obtain, delete, or update the ID attached to the end of a given URI. This module will be replaced by the **app.ability.dataUriUtils** module in the near future. You are advised to use the **[@ohos.app.ability.dataUriUtils](js-apis-app-ability-dataUriUtils.md)** module.
......@@ -35,7 +35,7 @@ Obtains the ID attached to the end of a given URI.
**Example**
```ts
let id = dataUriUtils.getId("com.example.dataUriUtils/1221");
let id = dataUriUtils.getId('com.example.dataUriUtils/1221');
```
......@@ -66,9 +66,9 @@ Attaches an ID to the end of a given URI.
```ts
let id = 1122;
let uri = dataUriUtils.attachId(
"com.example.dataUriUtils",
'com.example.dataUriUtils',
id,
)
);
```
......@@ -96,7 +96,7 @@ Deletes the ID from the end of a given URI.
**Example**
```ts
let uri = dataUriUtils.deleteId("com.example.dataUriUtils/1221")
let uri = dataUriUtils.deleteId('com.example.dataUriUtils/1221');
```
......@@ -127,7 +127,7 @@ Updates the ID in a given URI.
```ts
let id = 1122;
let uri = dataUriUtils.updateId(
"com.example.dataUriUtils/1221",
'com.example.dataUriUtils/1221',
id
)
);
```
......@@ -9,7 +9,7 @@ The **ErrorCode** module defines the error codes that may be returned when an ab
## Modules to Import
```ts
import errorCode from '@ohos.ability.errorCode'
import errorCode from '@ohos.ability.errorCode';
```
## ErrorCode
......
......@@ -14,7 +14,7 @@ The ParticleAbility module is used to perform operations on abilities of the Dat
## Modules to Import
```ts
import particleAbility from '@ohos.ability.particleAbility'
import particleAbility from '@ohos.ability.particleAbility';
```
## particleAbility.startAbility
......@@ -40,27 +40,27 @@ Observe the following when using this API:
**Example**
```ts
import particleAbility from '@ohos.ability.particleAbility'
import wantConstant from '@ohos.ability.wantConstant'
import particleAbility from '@ohos.ability.particleAbility';
import wantConstant from '@ohos.ability.wantConstant';
particleAbility.startAbility(
{
want:
{
action: "action.system.home",
entities: ["entity.system.home"],
type: "MIMETYPE",
action: 'action.system.home',
entities: ['entity.system.home'],
type: 'MIMETYPE',
flags: wantConstant.Flags.FLAG_AUTH_READ_URI_PERMISSION,
deviceId: "",
bundleName: "com.example.Data",
abilityName: "EntryAbility",
uri: ""
deviceId: '',
bundleName: 'com.example.Data',
abilityName: 'EntryAbility',
uri: ''
},
},
(error, result) => {
console.log('particleAbility startAbility errCode:' + error + 'result:' + result)
console.error('particleAbility startAbility errCode: ${JSON.stringify(error)}, result: ${JSON.stringify(result)}');
},
)
);
```
## particleAbility.startAbility
......@@ -91,25 +91,25 @@ Observe the following when using this API:
**Example**
```ts
import particleAbility from '@ohos.ability.particleAbility'
import wantConstant from '@ohos.ability.wantConstant'
import particleAbility from '@ohos.ability.particleAbility';
import wantConstant from '@ohos.ability.wantConstant';
particleAbility.startAbility(
{
want:
{
action: "action.system.home",
entities: ["entity.system.home"],
type: "MIMETYPE",
action: 'action.system.home',
entities: ['entity.system.home'],
type: 'MIMETYPE',
flags: wantConstant.Flags.FLAG_AUTH_READ_URI_PERMISSION,
deviceId: "",
bundleName: "com.example.Data",
abilityName: "EntryAbility",
uri: ""
deviceId: '',
bundleName: 'com.example.Data',
abilityName: 'EntryAbility',
uri: ''
},
},
).then((data) => {
console.info("particleAbility startAbility");
console.info('particleAbility startAbility');
});
```
......@@ -130,13 +130,13 @@ Terminates this ParticleAbility. This API uses an asynchronous callback to retur
**Example**
```ts
import particleAbility from '@ohos.ability.particleAbility'
import particleAbility from '@ohos.ability.particleAbility';
particleAbility.terminateSelf(
(error, result) => {
console.log('particleAbility terminateSelf errCode:' + error + 'result:' + result)
console.log('particleAbility terminateSelf errCode: ${JSON.stringify(error)}, result: ${JSON.stringify(result)}');
}
)
);
```
## particleAbility.terminateSelf
......@@ -156,10 +156,10 @@ Terminates this ParticleAbility. This API uses a promise to return the result.
**Example**
```ts
import particleAbility from '@ohos.ability.particleAbility'
import particleAbility from '@ohos.ability.particleAbility';
particleAbility.terminateSelf().then((data) => {
console.info("particleAbility terminateSelf");
console.info('particleAbility terminateSelf');
});
```
......@@ -194,10 +194,10 @@ Observe the following when using this API:
**Example**
```ts
import particleAbility from '@ohos.ability.particleAbility'
import particleAbility from '@ohos.ability.particleAbility';
var uri = "";
particleAbility.acquireDataAbilityHelper(uri)
let uri = '';
particleAbility.acquireDataAbilityHelper(uri);
```
......@@ -228,17 +228,17 @@ import wantAgent from '@ohos.app.ability.wantAgent';
function callback(err, data) {
if (err) {
console.error("Operation failed cause: " + JSON.stringify(err));
console.error('Operation failed cause: ${JSON.stringify(err)}');
} else {
console.info("Operation succeeded");
console.info('Operation succeeded');
}
}
let wantAgentInfo = {
wants: [
{
bundleName: "com.example.myapplication",
abilityName: "EntryAbility"
bundleName: 'com.example.myapplication',
abilityName: 'EntryAbility'
}
],
operationType: wantAgent.OperationType.START_ABILITY,
......@@ -248,8 +248,8 @@ let wantAgentInfo = {
wantAgent.getWantAgent(wantAgentInfo).then((wantAgentObj) => {
let basicContent = {
title: "title",
text: "text"
title: 'title',
text: 'text'
};
let notificationContent = {
contentType: notification.ContentType.NOTIFICATION_CONTENT_BASIC_TEXT,
......@@ -298,8 +298,8 @@ import wantAgent from '@ohos.app.ability.wantAgent';
let wantAgentInfo = {
wants: [
{
bundleName: "com.example.myapplication",
abilityName: "EntryAbility"
bundleName: 'com.example.myapplication',
abilityName: 'EntryAbility'
}
],
operationType: wantAgent.OperationType.START_ABILITY,
......@@ -309,8 +309,8 @@ let wantAgentInfo = {
wantAgent.getWantAgent(wantAgentInfo).then((wantAgentObj) => {
let basicContent = {
title: "title",
text: "text"
title: 'title',
text: 'text'
};
let notificationContent = {
contentType: notification.ContentType.NOTIFICATION_CONTENT_BASIC_TEXT,
......@@ -322,9 +322,9 @@ wantAgent.getWantAgent(wantAgentInfo).then((wantAgentObj) => {
};
let id = 1;
particleAbility.startBackgroundRunning(id, request).then(() => {
console.info("Operation succeeded");
console.info('Operation succeeded');
}).catch((err) => {
console.error("Operation failed cause: " + JSON.stringify(err));
console.error('Operation failed cause: ${JSON.stringify(err)}');
});
});
......@@ -351,9 +351,9 @@ import particleAbility from '@ohos.ability.particleAbility';
function callback(err, data) {
if (err) {
console.error("Operation failed cause: " + JSON.stringify(err));
console.error('Operation failed cause: ${JSON.stringify(err)}');
} else {
console.info("Operation succeeded");
console.info('Operation succeeded');
}
}
......@@ -381,9 +381,9 @@ Requests to cancel a continuous task from the system. This API uses a promise to
import particleAbility from '@ohos.ability.particleAbility';
particleAbility.cancelBackgroundRunning().then(() => {
console.info("Operation succeeded");
console.info('Operation succeeded');
}).catch((err) => {
console.error("Operation failed cause: " + JSON.stringify(err));
console.error('Operation failed cause: ${JSON.stringify(err)}');
});
```
......@@ -413,25 +413,25 @@ Observe the following when using this API:
**Example**
```ts
import particleAbility from '@ohos.ability.particleAbility'
import rpc from '@ohos.rpc'
import particleAbility from '@ohos.ability.particleAbility';
import rpc from '@ohos.rpc';
function onConnectCallback(element, remote) {
console.log('ConnectAbility onConnect remote is proxy:' + (remote instanceof rpc.RemoteProxy));
console.log('ConnectAbility onConnect remote is proxy: ${(remote instanceof rpc.RemoteProxy)}');
}
function onDisconnectCallback(element) {
console.log('ConnectAbility onDisconnect element.deviceId : ' + element.deviceId)
console.log('ConnectAbility onDisconnect element.deviceId : ${element.deviceId}');
}
function onFailedCallback(code) {
console.log('particleAbilityTest ConnectAbility onFailed errCode : ' + code)
console.log('particleAbilityTest ConnectAbility onFailed errCode : ${code}');
}
var connId = particleAbility.connectAbility(
let connId = particleAbility.connectAbility(
{
bundleName: "com.ix.ServiceAbility",
abilityName: "ServiceAbilityA",
bundleName: 'com.ix.ServiceAbility',
abilityName: 'ServiceAbilityA',
},
{
onConnect: onConnectCallback,
......@@ -441,9 +441,9 @@ var connId = particleAbility.connectAbility(
);
particleAbility.disconnectAbility(connId).then((data) => {
console.log(" data: " + data);
console.log(' data: ${data}');
}).catch((error) => {
console.log('particleAbilityTest result errCode : ' + error.code)
console.log('particleAbilityTest result errCode : ${error.code}');
});
```
......@@ -468,21 +468,21 @@ import particleAbility from '@ohos.ability.particleAbility';
import rpc from '@ohos.rpc';
function onConnectCallback(element, remote) {
console.log('ConnectAbility onConnect remote is proxy:' + (remote instanceof rpc.RemoteProxy));
console.log('ConnectAbility onConnect remote is proxy: ${(remote instanceof rpc.RemoteProxy)}');
}
function onDisconnectCallback(element) {
console.log('ConnectAbility onDisconnect element.deviceId : ' + element.deviceId)
console.log('ConnectAbility onDisconnect element.deviceId : ${element.deviceId}');
}
function onFailedCallback(code) {
console.log('particleAbilityTest ConnectAbility onFailed errCode : ' + code)
console.log('particleAbilityTest ConnectAbility onFailed errCode : ${code}');
}
var connId = particleAbility.connectAbility(
let connId = particleAbility.connectAbility(
{
bundleName: "com.ix.ServiceAbility",
abilityName: "ServiceAbilityA",
bundleName: 'com.ix.ServiceAbility',
abilityName: 'ServiceAbilityA',
},
{
onConnect: onConnectCallback,
......@@ -492,8 +492,7 @@ var connId = particleAbility.connectAbility(
);
particleAbility.disconnectAbility(connId, (err) => {
console.log("particleAbilityTest disconnectAbility err====>"
+ ("json err=") + JSON.stringify(err));
console.log('particleAbilityTest disconnectAbility err: ${JSON.stringify(err)}');
});
```
......@@ -519,21 +518,21 @@ import particleAbility from '@ohos.ability.particleAbility';
import rpc from '@ohos.rpc';
function onConnectCallback(element, remote) {
console.log('ConnectAbility onConnect remote is proxy:' + (remote instanceof rpc.RemoteProxy));
console.log('ConnectAbility onConnect remote is proxy: ${(remote instanceof rpc.RemoteProxy)}');
}
function onDisconnectCallback(element) {
console.log('ConnectAbility onDisconnect element.deviceId : ' + element.deviceId)
console.log('ConnectAbility onDisconnect element.deviceId : ${element.deviceId}');
}
function onFailedCallback(code) {
console.log('particleAbilityTest ConnectAbility onFailed errCode : ' + code)
console.log('particleAbilityTest ConnectAbility onFailed errCode : ${code}');
}
var connId = particleAbility.connectAbility(
let connId = particleAbility.connectAbility(
{
bundleName: "com.ix.ServiceAbility",
abilityName: "ServiceAbilityA",
bundleName: 'com.ix.ServiceAbility',
abilityName: 'ServiceAbilityA',
},
{
onConnect: onConnectCallback,
......@@ -543,9 +542,9 @@ var connId = particleAbility.connectAbility(
);
particleAbility.disconnectAbility(connId).then((data) => {
console.log(" data: " + data);
console.log(' data: ${data}');
}).catch((error) => {
console.log('particleAbilityTest result errCode : ' + error.code)
console.log('particleAbilityTest result errCode : ${error.code}');
});
```
......
......@@ -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_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. |
| 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_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. |
......
......@@ -28,7 +28,7 @@ import UIAbility from '@ohos.app.ability.UIAbility';
class MyUIAbility extends UIAbility {
onConfigurationUpdate(config) {
console.log('onConfigurationUpdate, config:' + JSON.stringify(config));
console.log('onConfigurationUpdate, config: ${JSON.stringify(config)}');
}
}
```
......@@ -55,7 +55,7 @@ import UIAbility from '@ohos.app.ability.UIAbility';
class MyUIAbility extends UIAbility {
onMemoryLevel(level) {
console.log('onMemoryLevel, level:' + JSON.stringify(level));
console.log('onMemoryLevel, level: ${JSON.stringify(level)}');
}
}
```
......@@ -64,7 +64,7 @@ const config = {
language: 'Zh-Hans', // Simplified Chinese.
colorMode: COLOR_MODE_LIGHT, // Light theme.
direction: DIRECTION_VERTICAL, // Vertical direction.
screenDensity: SCREEN_DENSITY_SDPI, // The screen resolution is SDPI.
screenDensity: SCREEN_DENSITY_SDPI, // The screen pixel density is 'sdpi'.
displayId: 1, // The application is displayed on the display with ID 1.
hasPointerDevice: true, // A pointer device is connected.
};
......@@ -76,7 +76,7 @@ try {
} else {
console.log('updateConfiguration success.');
}
})
});
} catch (paramError) {
console.log('error.code: ${JSON.stringify(paramError.code)}, error.message: ${JSON.stringify(paramError.message)}');
}
......@@ -121,7 +121,7 @@ const config = {
language: 'Zh-Hans', // Simplified Chinese.
colorMode: COLOR_MODE_LIGHT, // Light theme.
direction: DIRECTION_VERTICAL, // Vertical direction.
screenDensity: SCREEN_DENSITY_SDPI, // The screen resolution is SDPI.
screenDensity: SCREEN_DENSITY_SDPI, // The screen pixel density is 'sdpi'.
displayId: 1, // The application is displayed on the display with ID 1.
hasPointerDevice: true, // A pointer device is connected.
};
......@@ -131,7 +131,7 @@ try {
console.log('updateConfiguration success.');
}).catch((err) => {
console.log('updateConfiguration fail, err: ${JSON.stringify(err)}');
})
});
} catch (paramError) {
console.log('error.code: ${JSON.stringify(paramError.code)}, error.message: ${JSON.stringify(paramError.message)}');
}
......@@ -306,7 +306,7 @@ try {
console.log('getExtensionRunningInfos success, data: ${JSON.stringify(data)}');
}).catch((err) => {
console.log('getExtensionRunningInfos fail, err: ${JSON.stringify(err)}');
})
});
} catch (paramError) {
console.log('error.code: ${JSON.stringify(paramError.code)}, error.message: ${JSON.stringify(paramError.message)}');
}
......@@ -379,5 +379,5 @@ abilityManager.getTopAbility().then((data) => {
console.log('getTopAbility success, data: ${JSON.stringify(data)}');
}).catch((err) => {
console.log('getTopAbility fail, err: ${JSON.stringify(err)}');
})
});
```
......@@ -45,7 +45,7 @@ appManager.isRunningInStabilityTest((err, flag) => {
} else {
console.log('The result of isRunningInStabilityTest is: ${JSON.stringify(flag)}');
}
})
});
```
......@@ -151,7 +151,7 @@ appManager.isRamConstrainedDevice((err, data) => {
} else {
console.log('The result of isRamConstrainedDevice is: ${JSON.stringify(data)}');
}
})
});
```
## appManager.getAppMemorySize
......@@ -221,7 +221,7 @@ appManager.getAppMemorySize((err, data) => {
} else {
console.log('The size of app memory is: ${JSON.stringify(data)}');
}
})
});
```
## appManager.getRunningProcessInformation
......@@ -295,7 +295,7 @@ appManager.getRunningProcessInformation((err, data) => {
} else {
console.log('The process running information is: ${JSON.stringify(data)}');
}
})
});
```
## appManager.on
......@@ -352,7 +352,7 @@ let applicationStateObserver = {
onProcessStateChanged(processData) {
console.log(`[appManager] onProcessStateChanged: ${JSON.stringify(processData)}`);
}
}
};
try {
const observerId = appManager.on('applicationState', applicationStateObserver);
console.log(`[appManager] observerCode: ${observerId}`);
......@@ -416,7 +416,7 @@ let applicationStateObserver = {
onProcessStateChanged(processData) {
console.log(`[appManager] onProcessStateChanged: ${JSON.stringify(processData)}`);
}
}
};
let bundleNameList = ['bundleName1', 'bundleName2'];
try {
const observerId = appManager.on('applicationState', applicationStateObserver, bundleNameList);
......@@ -478,7 +478,7 @@ let applicationStateObserver = {
onProcessStateChanged(processData) {
console.log(`[appManager] onProcessStateChanged: ${JSON.stringify(processData)}`);
}
}
};
let bundleNameList = ['bundleName1', 'bundleName2'];
try {
observerId = appManager.on('applicationState', applicationStateObserver, bundleNameList);
......@@ -559,7 +559,7 @@ let applicationStateObserver = {
onProcessStateChanged(processData) {
console.log(`[appManager] onProcessStateChanged: ${JSON.stringify(processData)}`);
}
}
};
let bundleNameList = ['bundleName1', 'bundleName2'];
try {
observerId = appManager.on('applicationState', applicationStateObserver, bundleNameList);
......@@ -574,7 +574,7 @@ try {
console.log('unregisterApplicationStateObserver success, data: ${JSON.stringify(data)}');
}).catch((err) => {
console.log('unregisterApplicationStateObserver fail, err: ${JSON.stringify(err)}');
})
});
} catch (paramError) {
console.log('error: ${paramError.code}, ${paramError.message}');
}
......@@ -660,7 +660,7 @@ appManager.getForegroundApplications().then((data) => {
console.log('getForegroundApplications success, data: ${JSON.stringify(data)}');
}).catch((err) => {
console.log('getForegroundApplications fail, err: ${JSON.stringify(err)}');
})
});
```
## appManager.killProcessWithAccount
......@@ -702,7 +702,7 @@ try {
console.log('killProcessWithAccount success');
}).catch((err) => {
console.error('killProcessWithAccount fail, err: ${JSON.stringify(err)}');
})
});
} catch (paramError) {
console.error('error: ${paramError.code}, ${paramError.message}');
}
......@@ -844,7 +844,7 @@ try {
console.log('killProcessesByBundleName success.');
}).catch((err) => {
console.log('killProcessesByBundleName fail, err: ${JSON.stringify(err)}');
})
});
} catch (paramError) {
console.log('error: ${paramError.code}, ${paramError.message}');
}
......@@ -940,7 +940,7 @@ try {
console.log('clearUpApplicationData success.');
}).catch((err) => {
console.log('clearUpApplicationData fail, err: ${JSON.stringify(err)}');
})
});
} catch (paramError) {
console.log('error: ${paramError.code}, ${paramError.message}');
}
......
......@@ -10,7 +10,7 @@ The **Common** module provides all level-2 module APIs for developers to export.
## Modules to Import
```ts
import common from '@ohos.app.ability.common'
import common from '@ohos.app.ability.common';
```
**System capability**: SystemCapability.Ability.AbilityBase
......@@ -24,16 +24,15 @@ import common from '@ohos.app.ability.common'
| Context | [Context](js-apis-inner-application-context.md) | Level-2 module **Context**.|
| ExtensionContext | [ExtensionContext](js-apis-inner-application-extensionContext.md) | Level-2 module **ExtensionContext**.|
| FormExtensionContext | [FormExtensionContext](js-apis-inner-application-formExtensionContext.md) | Level-2 module **FormExtensionContext**.|
| AreaMode | [AreaMode](#areamode) | Enumerated values of **AreaMode**.|
| ServiceExtensionContext | [ServiceExtensionContext](js-apis-inner-application-serviceExtensionContext.md) | Level-2 module **ServiceExtensionContext**.|
| EventHub | [EventHub](js-apis-inner-application-eventHub.md) | Level-2 module **EventHub**.|
| PermissionRequestResult | [PermissionRequestResult](js-apis-inner-application-permissionRequestResult.md) | Level-2 module **PermissionRequestResult**.|
| PacMap | [PacMap](js-apis-inner-ability-dataAbilityHelper.md#PacMap) | Level-2 module **PacMap**.|
| AbilityResult | [AbilityResult](js-apis-inner-ability-abilityResult.md) | Level-2 module **AbilityResult**.|
| ConnectOptions | [ConnectOptions](js-apis-inner-ability-connectOptions.md) | Level-2 module **ConnectOptions**.|
**Example**
```ts
import common from '@ohos.app.ability.common'
import common from '@ohos.app.ability.common';
let uiAbilityContext: common.UIAbilityContext;
let abilityStageContext: common.AbilityStageContext;
......@@ -42,21 +41,8 @@ let baseContext: common.BaseContext;
let context: common.Context;
let extensionContext: common.ExtensionContext;
let formExtensionContext: common.FormExtensionContext;
let areaMode: common.AreaMode;
let eventHub: common.EventHub;
let permissionRequestResult: common.PermissionRequestResult;
let pacMap: common.PacMap;
let abilityResult: common.AbilityResult;
let connectOptions: common.ConnectOptions;
```
## AreaMode
Enumerates the data encryption levels.
**System capability**: SystemCapability.Ability.AbilityRuntime.Core
| Name | Value | Description |
| --------------- | ---- | --------------- |
| EL1 | 0 | Device-level encryption area, which is accessible after the device is powered on. |
| EL2 | 1 | User-level encryption area, which is accessible only after the device is powered on and the password is entered (for the first time).|
# @ohos.app.ability.Configuration (Configuration)
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**
>
> 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
```ts
import Configuration from '@ohos.app.ability.Configuration';
```
**System capability**: SystemCapability.Ability.AbilityBase
| Name| Type| Readable| Writable| Description|
| Name| Type| Readable| Writable| Description|
| -------- | -------- | -------- | -------- | -------- |
| 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**.|
| direction | [Direction](js-apis-app-ability-configurationConstant.md#configurationconstantdirection) | Yes| No| Screen orientation, which can be **DIRECTION_HORIZONTAL** or **DIRECTION_VERTICAL**.|
| 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).|
| 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. 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| 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.|
| hasPointerDevice | boolean | Yes| No| Whether a pointer device, such as a keyboard, mouse, or touchpad, is connected.|
......@@ -34,7 +28,7 @@ export default class EntryAbility extends UIAbility {
onCreate(want, launchParam) {
let envCallback = {
onConfigurationUpdated(config) {
console.info(`envCallback onConfigurationUpdated success: ${JSON.stringify(config)}`)
console.info(`envCallback onConfigurationUpdated success: ${JSON.stringify(config)}`);
let language = config.language;
let colorMode = config.colorMode;
let direction = config.direction;
......@@ -45,10 +39,10 @@ export default class EntryAbility extends UIAbility {
};
try {
let applicationContext = this.context.getApplicationContext();
let callbackId = applicationContext.on("environment", envCallback);
console.log("callbackId: " + callbackId);
let callbackId = applicationContext.on('environment', envCallback);
console.log('callbackId: ${callbackId}');
} catch (paramError) {
console.log("error: " + paramError.code + ", " + paramError.message);
console.log('error: ${paramError.code}, ${paramError.message}');
}
}
}
......
......@@ -46,10 +46,10 @@ You can obtain the value of this constant by calling the **ConfigurationConstant
| Name| Value| Description|
| -------- | -------- | -------- |
| SCREEN_DENSITY_NOT_SET | 0 | Unspecified screen resolution.|
| SCREEN_DENSITY_SDPI | 120 | The screen resolution is sdpi.|
| SCREEN_DENSITY_MDPI | 160 | The screen resolution is mdpi.|
| SCREEN_DENSITY_LDPI | 240 | The screen resolution is ldpi.|
| SCREEN_DENSITY_XLDPI | 320 | The screen resolution is xldpi.|
| SCREEN_DENSITY_XXLDPI | 480 | The screen resolution is xxldpi.|
| SCREEN_DENSITY_XXXLDPI | 640 | The screen resolution is xxxldpi.|
| SCREEN_DENSITY_NOT_SET | 0 | The screen pixel density is not set.|
| SCREEN_DENSITY_SDPI | 120 | The pixel density of the screen is 'sdpi'.|
| SCREEN_DENSITY_MDPI | 160 | The pixel density of the screen is 'mdpi'.|
| SCREEN_DENSITY_LDPI | 240 | The pixel density of the screen is 'ldpi'.|
| SCREEN_DENSITY_XLDPI | 320 | The pixel density of the screen is 'xldpi'.|
| SCREEN_DENSITY_XXLDPI | 480 | The pixel density of the screen is 'xxldpi'.|
| SCREEN_DENSITY_XXXLDPI | 640 | The pixel density of the screen is 'xxxldpi'.|
......@@ -36,10 +36,10 @@ Obtains the ID attached to the end of a given URI.
```ts
try {
var id = dataUriUtils.getId("com.example.dataUriUtils/1221")
console.info('get id: ' + id)
let id = dataUriUtils.getId('com.example.dataUriUtils/1221');
console.info('get id: ${id}');
} catch(err) {
console.error('get id err ,check the uri' + err)
console.error('get id err ,check the uri ${err}');
}
```
......@@ -69,15 +69,15 @@ Attaches an ID to the end of a given URI.
**Example**
```ts
var id = 1122;
let id = 1122;
try {
var uri = dataUriUtils.attachId(
"com.example.dataUriUtils",
let uri = dataUriUtils.attachId(
'com.example.dataUriUtils',
id,
)
console.info('attachId the uri is: ' + uri)
);
console.info('attachId the uri is: ${uri}');
} catch (err) {
console.error('get id err ,check the uri' + err)
console.error('get id err ,check the uri ${err}');
}
```
......@@ -108,10 +108,10 @@ Deletes the ID from the end of a given URI.
```ts
try {
var uri = dataUriUtils.deleteId("com.example.dataUriUtils/1221")
console.info('delete id with the uri is: ' + uri)
let uri = dataUriUtils.deleteId('com.example.dataUriUtils/1221');
console.info('delete id with the uri is: ${uri}');
} catch(err) {
console.error('delete uri err, check the input uri' + err)
console.error('delete uri err, check the input uri ${err}');
}
```
......@@ -144,12 +144,12 @@ Updates the ID in a given URI.
```ts
try {
var id = 1122;
var uri = dataUriUtils.updateId(
"com.example.dataUriUtils/1221",
let id = 1122;
let uri = dataUriUtils.updateId(
'com.example.dataUriUtils/1221',
id
)
);
} catch (err) {
console.error('delete uri err, check the input uri' + err)
console.error('delete uri err, check the input uri ${err}');
}
```
......@@ -11,7 +11,7 @@ The **EnvironmentCallback** module provides the **onConfigurationUpdated** API f
## Modules to Import
```ts
import EnvironmentCallback from "@ohos.app.ability.EnvironmentCallback";
import EnvironmentCallback from '@ohos.app.ability.EnvironmentCallback';
```
......@@ -29,33 +29,51 @@ Called when the system environment changes.
| -------- | -------- | -------- | -------- |
| config | [Configuration](js-apis-app-ability-configuration.md) | Yes| **Configuration** object after the change.|
## EnvironmentCallback.onMemoryLevel
onMemoryLevel(level: AbilityConstant.MemoryLevel): void;
Called when the system memory level changes.
**System capability**: SystemCapability.Ability.AbilityRuntime.Core
**Parameters**
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| 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.|
**Example**
```ts
import UIAbility from "@ohos.app.ability.Ability";
import UIAbility from '@ohos.app.ability.Ability';
var callbackId;
let callbackId;
export default class MyAbility extends UIAbility {
onCreate() {
console.log("MyAbility onCreate")
console.log('MyAbility onCreate');
globalThis.applicationContext = this.context.getApplicationContext();
let EnvironmentCallback = {
onConfigurationUpdated(config){
console.log("onConfigurationUpdated config:" + JSON.stringify(config));
console.log('onConfigurationUpdated config: ${JSON.stringify(config)}');
}
onMemoryLevel(level){
console.log('onMemoryLevel level: ${JSON.stringify(level)}');
}
}
};
// 1. Obtain an applicationContext object.
let applicationContext = globalThis.applicationContext;
// 2. Register a listener for the environment changes through the applicationContext object.
callbackId = applicationContext.registerEnvironmentCallback(EnvironmentCallback);
console.log("registerEnvironmentCallback number: " + JSON.stringify(callbackId));
console.log('registerEnvironmentCallback number: ${JSON.stringify(callbackId)}');
}
onDestroy() {
let applicationContext = globalThis.applicationContext;
applicationContext.unregisterEnvironmentCallback(callbackId, (error, data) => {
console.log("unregisterEnvironmentCallback success, err: " + JSON.stringify(error));
console.log('unregisterEnvironmentCallback success, err: ${JSON.stringify(error)}');
});
}
}
......
......@@ -8,12 +8,12 @@ The **ErrorManager** module provides APIs for registering and deregistering erro
## Modules to Import
```ts
import errorManager from '@ohos.app.ability.errorManager'
import errorManager from '@ohos.app.ability.errorManager';
```
## ErrorManager.on
on(type: "error", observer: ErrorObserver): number;
on(type: 'error', observer: ErrorObserver): number;
Registers an error observer.
......@@ -35,22 +35,22 @@ Registers an error observer.
**Example**
```ts
var observer = {
let observer = {
onUnhandledException(errorMsg) {
console.log('onUnhandledException, errorMsg: ', errorMsg)
console.log('onUnhandledException, errorMsg: ', errorMsg);
}
}
var observerId = -1;
};
let observerId = -1;
try {
observerId = errorManager.on("error", observer);
observerId = errorManager.on('error', observer);
} catch (paramError) {
console.log("error: " + paramError.code + ", " + paramError.message);
console.log('error: ${paramError.code}, ${paramError.message}');
}
```
## ErrorManager.off
off(type: "error", observerId: number, callback: AsyncCallback\<void>): void;
off(type: 'error', observerId: number, callback: AsyncCallback\<void>): void;
Deregisters an error observer. This API uses an asynchronous callback to return the result.
......@@ -67,7 +67,7 @@ Deregisters an error observer. This API uses an asynchronous callback to return
**Example**
```ts
var observerId = 100;
let observerId = 100;
function unregisterErrorObserverCallback(err) {
if (err) {
......@@ -75,15 +75,15 @@ function unregisterErrorObserverCallback(err) {
}
}
try {
errorManager.off("error", observerId, unregisterErrorObserverCallback);
errorManager.off('error', observerId, unregisterErrorObserverCallback);
} catch (paramError) {
console.log("error: " + paramError.code + ", " + paramError.message);
console.log('error: ${paramError.code}, ${paramError.message}');
}
```
## ErrorManager.off
off(type: "error", observerId: number): Promise\<void>;
off(type: 'error', observerId: number): Promise\<void>;
Deregisters an error observer. This API uses a promise to return the result.
......@@ -105,17 +105,17 @@ Deregisters an error observer. This API uses a promise to return the result.
**Example**
```ts
var observerId = 100;
let observerId = 100;
try {
errorManager.off("error", observerId)
errorManager.off('error', observerId)
.then((data) => {
console.log('----------- unregisterErrorObserver success ----------', data);
})
.catch((err) => {
console.log('----------- unregisterErrorObserver fail ----------', err);
})
});
} catch (paramError) {
console.log("error: " + paramError.code + ", " + paramError.message);
console.log('error: ${paramError.code}, ${paramError.message}');
}
```
......@@ -3,7 +3,7 @@
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**
>
>
> 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
......@@ -24,7 +24,7 @@ Defines the quick fix information at the HAP file level.
| ----------- | -------------------- | ---- | ------------------------------------------------------------ |
| moduleName | string | Yes | Name 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
......@@ -57,25 +57,29 @@ Applies a quick fix patch. This API uses an asynchronous callback to return the
**Parameters**
| Parameter| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| hapModuleQuickFixFiles | Array\<string> | Yes| Quick fix files, each of which must contain a valid file path.|
| callback | AsyncCallback\<void> | Yes| Callback used to return the result.|
| Parameter| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| 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.|
> **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***.
**Example**
```ts
try {
let hapModuleQuickFixFiles = ["/data/storage/el2/base/entry.hqf"]
let hapModuleQuickFixFiles = ['/data/storage/el2/base/entry.hqf'];
quickFixManager.applyQuickFix(hapModuleQuickFixFiles, (error) => {
if (error) {
console.info( `applyQuickFix failed with error + ${error}`)
console.info( `applyQuickFix failed with error: ${error}`);
} else {
console.info( 'applyQuickFix success')
console.info( 'applyQuickFix success');
}
})
});
} catch (paramError) {
console.log("error: " + paramError.code + ", " + paramError.message);
console.log('error.code: ${paramError.code}, error.message: ${paramError.message}');
}
```
......@@ -93,28 +97,28 @@ Applies a quick fix patch. This API uses a promise to return the result.
**Parameters**
| Parameter| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| hapModuleQuickFixFiles | Array\<string> | Yes| Quick fix files, each of which must contain a valid file path.|
| Parameter| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| hapModuleQuickFixFiles | Array\<string> | Yes| Quick fix patch files, each of which must contain a valid file path.|
**Return value**
| Type| Description|
| -------- | -------- |
| Promise\<void> | Promise used to return the result.|
| Type| Description|
| -------- | -------- |
| Promise\<void> | Promise used to return the result.|
**Example**
```ts
let hapModuleQuickFixFiles = ["/data/storage/el2/base/entry.hqf"]
let hapModuleQuickFixFiles = ['/data/storage/el2/base/entry.hqf'];
try {
quickFixManager.applyQuickFix(hapModuleQuickFixFiles).then(() => {
console.info('applyQuickFix success')
console.info('applyQuickFix success');
}).catch((error) => {
console.info(`applyQuickFix err: + ${error}`)
})
console.info(`applyQuickFix err: ${error}`);
});
} catch (paramError) {
console.log("error: " + paramError.code + ", " + paramError.message);
console.log('error: ${paramError.code}, ${paramError.message}');
}
```
......@@ -138,20 +142,20 @@ Obtains the quick fix information of the application. This API uses an asynchron
| callback | AsyncCallback\<[ApplicationQuickFixInfo](#applicationquickfixinfo)> | Yes| Callback used to return the quick fix information.|
**Example**
```ts
try {
let bundleName = "bundleName"
let bundleName = 'bundleName';
quickFixManager.getApplicationQuickFixInfo(bundleName, (error, data) => {
if (error) {
console.info(`getApplicationQuickFixInfo error: + ${error}`)
console.info(`getApplicationQuickFixInfo error: ${error}`);
} else {
console.info(`getApplicationQuickFixInfo success: + ${data}`)
console.info(`getApplicationQuickFixInfo success: ${data}`);
}
})
});
} catch (paramError) {
console.log("error: " + paramError.code + ", " + paramError.message);
}
console.log('error: ${paramError.code}, ${paramError.message}');
}
```
## quickFixManager.getApplicationQuickFixInfo
......@@ -174,21 +178,21 @@ Obtains the quick fix information of the application. This API uses a promise to
**Return value**
| Type| Description|
| -------- | -------- |
| Promise\<[ApplicationQuickFixInfo](#applicationquickfixinfo)> | Promise used to return the quick fix information.|
| Type| Description|
| -------- | -------- |
| Promise\<[ApplicationQuickFixInfo](#applicationquickfixinfo)> | Promise used to return the quick fix information.|
**Example**
```ts
```ts
try {
let bundleName = "bundleName"
let bundleName = 'bundleName';
quickFixManager.getApplicationQuickFixInfo(bundleName).then((data) => {
console.info(`getApplicationQuickFixInfo success: + ${data}`)
console.info(`getApplicationQuickFixInfo success: ${data}`);
}).catch((error) => {
console.info(`getApplicationQuickFixInfo err: + ${error}`)
})
console.info(`getApplicationQuickFixInfo err: ${error}`);
});
} catch (paramError) {
console.log("error: " + paramError.code + ", " + paramError.message);
console.log('error: ${paramError.code}, ${paramError.message}');
}
```
......@@ -49,7 +49,7 @@ Called when a ServiceExtensionAbility is created to initialize the service logic
```ts
class ServiceExt extends ServiceExtension {
onCreate(want) {
console.log('onCreate, want:' + want.abilityName);
console.log('onCreate, want: ${want.abilityName}');
}
}
```
......@@ -80,7 +80,7 @@ Called when this ServiceExtensionAbility is destroyed to clear resources.
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.
**System capability**: SystemCapability.Ability.AbilityRuntime.Core
......@@ -98,7 +98,7 @@ Called following **onCreate()** when a ServiceExtensionAbility is started by cal
```ts
class ServiceExt extends ServiceExtension {
onRequest(want, startId) {
console.log('onRequest, want:' + want.abilityName);
console.log('onRequest, want: ${want.abilityName}');
}
}
```
......@@ -129,7 +129,7 @@ Called following **onCreate()** when a ServiceExtensionAbility is started by cal
**Example**
```ts
import rpc from '@ohos.rpc'
import rpc from '@ohos.rpc';
class StubTest extends rpc.RemoteObject{
constructor(des) {
super(des);
......@@ -139,8 +139,8 @@ Called following **onCreate()** when a ServiceExtensionAbility is started by cal
}
class ServiceExt extends ServiceExtension {
onConnect(want) {
console.log('onConnect , want:' + want.abilityName);
return new StubTest("test");
console.log('onConnect , want: ${want.abilityName}');
return new StubTest('test');
}
}
```
......@@ -167,7 +167,7 @@ Called when a client is disconnected from this ServiceExtensionAbility.
```ts
class ServiceExt extends ServiceExtension {
onDisconnect(want) {
console.log('onDisconnect, want:' + want.abilityName);
console.log('onDisconnect, want: ${want.abilityName}');
}
}
```
......@@ -193,7 +193,7 @@ Called when a new client attempts to connect to this ServiceExtensionAbility aft
```ts
class ServiceExt extends ServiceExtension {
onReconnect(want) {
console.log('onReconnect, want:' + want.abilityName);
console.log('onReconnect, want: ${want.abilityName}');
}
}
```
......@@ -219,7 +219,7 @@ Called when the configuration of this ServiceExtensionAbility is updated.
```ts
class ServiceExt extends ServiceExtension {
onConfigurationUpdate(config) {
console.log('onConfigurationUpdate, config:' + JSON.stringify(config));
console.log('onConfigurationUpdate, config: ${JSON.stringify(config)}');
}
}
```
......@@ -245,8 +245,8 @@ Dumps the client information.
```ts
class ServiceExt extends ServiceExtension {
onDump(params) {
console.log('dump, params:' + JSON.stringify(params));
return ["params"]
console.log('dump, params: ${JSON.stringify(params)}');
return ['params'];
}
}
```
......@@ -47,7 +47,7 @@ Called to initialize the service logic when a UIAbility is created.
```ts
class MyUIAbility extends UIAbility {
onCreate(want, param) {
console.log('onCreate, want:' + want.abilityName);
console.log('onCreate, want: ${want.abilityName}');
}
}
```
......@@ -202,11 +202,11 @@ Called to save data during the ability migration preparation process.
**Example**
```ts
import AbilityConstant from "@ohos.app.ability.AbilityConstant"
import AbilityConstant from '@ohos.app.ability.AbilityConstant';
class MyUIAbility extends UIAbility {
onContinue(wantParams) {
console.log('onContinue');
wantParams["myData"] = "my1234567";
wantParams['myData'] = 'my1234567';
return AbilityConstant.OnContinueResult.AGREE;
}
}
......@@ -233,8 +233,8 @@ Called when a new Want is passed in and this UIAbility is started again.
```ts
class MyUIAbility extends UIAbility {
onNewWant(want, launchParams) {
console.log('onNewWant, want:' + want.abilityName);
console.log('onNewWant, launchParams:' + JSON.stringify(launchParams));
console.log('onNewWant, want: ${want.abilityName}');
console.log('onNewWant, launchParams: ${JSON.stringify(launchParams)}');
}
}
```
......@@ -258,8 +258,8 @@ Dumps client information.
```ts
class MyUIAbility extends UIAbility {
onDump(params) {
console.log('dump, params:' + JSON.stringify(params));
return ["params"]
console.log('dump, params: ${JSON.stringify(params)}');
return ['params'];
}
}
```
......@@ -289,12 +289,12 @@ Called when the framework automatically saves the UIAbility state in the case of
**Example**
```ts
import AbilityConstant from '@ohos.app.ability.AbilityConstant'
import AbilityConstant from '@ohos.app.ability.AbilityConstant';
class MyUIAbility extends UIAbility {
onSaveState(reason, wantParam) {
console.log('onSaveState');
wantParam["myData"] = "my1234567";
wantParam['myData'] = 'my1234567';
return AbilityConstant.OnSaveResult.RECOVERY_AGREE;
}
}
......@@ -339,8 +339,8 @@ For details about the error codes, see [Ability Error Codes](../errorcodes/error
```ts
class MyMessageAble{ // Custom sequenceable data structure.
name:""
str:""
name:''
str:''
num: 1
constructor(name, str) {
this.name = name;
......@@ -349,38 +349,36 @@ For details about the error codes, see [Ability Error Codes](../errorcodes/error
marshalling(messageParcel) {
messageParcel.writeInt(this.num);
messageParcel.writeString(this.str);
console.log('MyMessageAble marshalling num[' + this.num + '] str[' + this.str + ']');
console.log('MyMessageAble marshalling num[${this.num}] str[${this.str}]');
return true;
}
unmarshalling(messageParcel) {
this.num = messageParcel.readInt();
this.str = messageParcel.readString();
console.log('MyMessageAble unmarshalling num[' + this.num + '] str[' + this.str + ']');
console.log('MyMessageAble unmarshalling num[${this.num}] str[${this.str}]');
return true;
}
};
var method = 'call_Function'; // Notification message string negotiated by the two abilities.
var caller;
let method = 'call_Function'; // Notification message string negotiated by the two abilities.
let caller;
export default class MainUIAbility extends UIAbility {
onWindowStageCreate(windowStage) {
this.context.startUIAbilityByCall({
bundleName: "com.example.myservice",
abilityName: "MainUIAbility",
deviceId: ""
this.context.startAbilityByCall({
bundleName: 'com.example.myservice',
abilityName: 'MainUIAbility',
deviceId: ''
}).then((obj) => {
caller = obj;
let msg = new MyMessageAble("msg", "world"); // See the definition of Sequenceable.
let msg = new MyMessageAble('msg', 'world'); // See the definition of Sequenceable.
caller.call(method, msg)
.then(() => {
console.log('Caller call() called');
})
.catch((callErr) => {
console.log('Caller.call catch error, error.code: ' + JSON.stringify(callErr.code) +
' error.message: ' + JSON.stringify(callErr.message));
console.log('Caller.call catch error, error.code: ${JSON.stringify(callErr.code)}, error.message: ${JSON.stringify(callErr.message)}');
});
}).catch((err) => {
console.log('Caller GetCaller error, error.code: ' + JSON.stringify(err.code) +
' error.message: ' + JSON.stringify(err.message));
console.log('Caller GetCaller error, error.code: ${JSON.stringify(err.code)}, error.message: ${JSON.stringify(err.message)}');
});
}
}
......@@ -420,8 +418,8 @@ For details about the error codes, see [Ability Error Codes](../errorcodes/error
```ts
class MyMessageAble{
name:""
str:""
name:''
str:''
num: 1
constructor(name, str) {
this.name = name;
......@@ -430,40 +428,38 @@ For details about the error codes, see [Ability Error Codes](../errorcodes/error
marshalling(messageParcel) {
messageParcel.writeInt(this.num);
messageParcel.writeString(this.str);
console.log('MyMessageAble marshalling num[' + this.num + '] str[' + this.str + ']');
console.log('MyMessageAble marshalling num[${this.num}] str[${this.str}]');
return true;
}
unmarshalling(messageParcel) {
this.num = messageParcel.readInt();
this.str = messageParcel.readString();
console.log('MyMessageAble unmarshalling num[' + this.num + '] str[' + this.str + ']');
console.log('MyMessageAble unmarshalling num[${this.num] str[${this.str}]');
return true;
}
};
var method = 'call_Function';
var caller;
let method = 'call_Function';
let caller;
export default class MainUIAbility extends UIAbility {
onWindowStageCreate(windowStage) {
this.context.startUIAbilityByCall({
bundleName: "com.example.myservice",
abilityName: "MainUIAbility",
deviceId: ""
this.context.startAbilityByCall({
bundleName: 'com.example.myservice',
abilityName: 'MainUIAbility',
deviceId: ''
}).then((obj) => {
caller = obj;
let msg = new MyMessageAble(1, "world");
let msg = new MyMessageAble(1, 'world');
caller.callWithResult(method, msg)
.then((data) => {
console.log('Caller callWithResult() called');
let retmsg = new MyMessageAble(0, "");
let retmsg = new MyMessageAble(0, '');
data.readSequenceable(retmsg);
})
.catch((callErr) => {
console.log('Caller.callWithResult catch error, error.code: ' + JSON.stringify(callErr.code) +
' error.message: ' + JSON.stringify(callErr.message));
console.log('Caller.callWithResult catch error, error.code: ${JSON.stringify(callErr.code)}, error.message: ${JSON.stringify(callErr.message)}');
});
}).catch((err) => {
console.log('Caller GetCaller error, error.code: ' + JSON.stringify(err.code) +
' error.message: ' + JSON.stringify(err.message));
console.log('Caller GetCaller error, error.code: ${JSON.stringify(err.code)}, error.message: ${JSON.stringify(err.message)}');
});
}
}
......@@ -490,24 +486,22 @@ Releases the caller interface of the target ability.
**Example**
```ts
var caller;
let caller;
export default class MainUIAbility extends UIAbility {
onWindowStageCreate(windowStage) {
this.context.startUIAbilityByCall({
bundleName: "com.example.myservice",
abilityName: "MainUIAbility",
deviceId: ""
this.context.startAbilityByCall({
bundleName: 'com.example.myservice',
abilityName: 'MainUIAbility',
deviceId: ''
}).then((obj) => {
caller = obj;
try {
caller.release();
} catch (releaseErr) {
console.log('Caller.release catch error, error.code: ' + JSON.stringify(releaseErr.code) +
' error.message: ' + JSON.stringify(releaseErr.message));
console.log('Caller.release catch error, error.code: ${JSON.stringify(releaseErr.code)}, error.message: ${JSON.stringify(releaseErr.message)}');
}
}).catch((err) => {
console.log('Caller GetCaller error, error.code: ' + JSON.stringify(err.code) +
' error.message: ' + JSON.stringify(err.message));
console.log('Caller GetCaller error, error.code: ${JSON.stringify(err.code)}, error.message: ${JSON.stringify(err.message)}');
});
}
}
......@@ -525,31 +519,29 @@ Registers a callback that is invoked when the stub on the target ability is disc
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| callback | [OnReleaseCallBack](#onreleasecallback) | Yes| Callback used for the **onRelease** API.|
| callback | [OnReleaseCallBack](#onreleasecallback) | Yes| Callback used to return the result.|
**Example**
```ts
var caller;
let caller;
export default class MainUIAbility extends UIAbility {
onWindowStageCreate(windowStage) {
this.context.startUIAbilityByCall({
bundleName: "com.example.myservice",
abilityName: "MainUIAbility",
deviceId: ""
this.context.startAbilityByCall({
bundleName: 'com.example.myservice',
abilityName: 'MainUIAbility',
deviceId: ''
}).then((obj) => {
caller = obj;
try {
caller.onRelease((str) => {
console.log(' Caller OnRelease CallBack is called ' + str);
console.log(' Caller OnRelease CallBack is called ${str}');
});
} catch (error) {
console.log('Caller.on catch error, error.code: ' + JSON.stringify(error.code) +
' error.message: ' + JSON.stringify(error.message));
console.log('Caller.onRelease catch error, error.code: ${JSON.stringify(error.code)}, error.message: ${JSON.stringify(error.message)}');
}
}).catch((err) => {
console.log('Caller GetCaller error, error.code: ' + JSON.stringify(err.code) +
' error.message: ' + JSON.stringify(err.message));
console.log('Caller GetCaller error, error.code: ${JSON.stringify(err.code)}, error.message: ${JSON.stringify(err.message)}');
});
}
}
......@@ -557,7 +549,7 @@ Registers a callback that is invoked when the stub on the target ability is disc
## Caller.on
on(type: "release", callback: OnReleaseCallback): void;
on(type: 'release', callback: OnReleaseCallback): void;
Registers a callback that is invoked when the stub on the target ability is disconnected.
......@@ -568,7 +560,7 @@ Registers a callback that is invoked when the stub on the target ability is disc
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| type | string | Yes| Event type. The value is fixed at **release**.|
| callback | [OnReleaseCallBack](#onreleasecallback) | Yes| Callback used for the **onRelease** API.|
| callback | [OnReleaseCallBack](#onreleasecallback) | Yes| Callback used to return the result.|
**Error codes**
......@@ -581,31 +573,127 @@ For details about the error codes, see [Ability Error Codes](../errorcodes/error
**Example**
```ts
var caller;
let caller;
export default class MainUIAbility extends UIAbility {
onWindowStageCreate(windowStage) {
this.context.startUIAbilityByCall({
bundleName: "com.example.myservice",
abilityName: "MainUIAbility",
deviceId: ""
this.context.startAbilityByCall({
bundleName: 'com.example.myservice',
abilityName: 'MainUIAbility',
deviceId: ''
}).then((obj) => {
caller = obj;
try {
caller.on("release", (str) => {
console.log(' Caller OnRelease CallBack is called ' + str);
caller.on('release', (str) => {
console.log(' Caller OnRelease CallBack is called ${str}');
});
} catch (error) {
console.log('Caller.on catch error, error.code: ' + JSON.stringify(error.code) +
' error.message: ' + JSON.stringify(error.message));
console.log('Caller.on catch error, error.code: ${JSON.stringify(error.code)}, error.message: ${JSON.stringify(error.message)}');
}
}).catch((err) => {
console.log('Caller GetCaller error, error.code: ' + JSON.stringify(err.code) +
' error.message: ' + JSON.stringify(err.message));
console.log('Caller GetCaller error, error.code: ${JSON.stringify(err.code)}, error.message: ${JSON.stringify(err.message)}');
});
}
}
```
## Caller.off
off(type: 'release', callback: OnReleaseCallback): void;
Deregisters a callback that is invoked when the stub on the target ability is disconnected. This capability is reserved.
**System capability**: SystemCapability.Ability.AbilityRuntime.AbilityCore
**Parameters**
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| type | string | Yes| Event type. The value is fixed at **release**.|
| callback | [OnReleaseCallBack](#onreleasecallback) | Yes| Callback used to return the result.|
**Error codes**
| ID| Error Message|
| ------- | -------------------------------- |
| 401 | If the input parameter is not valid parameter. |
For other IDs, see [Ability Error Codes](../errorcodes/errorcode-ability.md).
**Example**
```ts
let caller;
export default class MainUIAbility extends UIAbility {
onWindowStageCreate(windowStage) {
this.context.startAbilityByCall({
bundleName: 'com.example.myservice',
abilityName: 'MainUIAbility',
deviceId: ''
}).then((obj) => {
caller = obj;
try {
let onReleaseCallBack = (str) => {
console.log(' Caller OnRelease CallBack is called ${str}');
};
caller.on('release', onReleaseCallBack);
caller.off('release', onReleaseCallBack);
} catch (error) {
console.log('Caller.on or Caller.off catch error, error.code: ${JSON.stringify(error.code)}, error.message: ${JSON.stringify(error.message)}');
}
}).catch((err) => {
console.log('Caller GetCaller error, error.code: ${JSON.stringify(err.code)}, error.message: ${JSON.stringify(err.message)}');
});
}
}
```
## Caller.off
off(type: 'release'): void;
Deregisters a callback that is invoked when the stub on the target ability is disconnected. This capability is reserved.
**System capability**: SystemCapability.Ability.AbilityRuntime.AbilityCore
**Parameters**
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| type | string | Yes| Event type. The value is fixed at **release**.|
**Error codes**
| ID| Error Message|
| ------- | -------------------------------- |
| 401 | If the input parameter is not valid parameter. |
For other IDs, see [Ability Error Codes](../errorcodes/errorcode-ability.md).
**Example**
```ts
let caller;
export default class MainUIAbility extends UIAbility {
onWindowStageCreate(windowStage) {
this.context.startAbilityByCall({
bundleName: 'com.example.myservice',
abilityName: 'MainUIAbility',
deviceId: ''
}).then((obj) => {
caller = obj;
try {
let onReleaseCallBack = (str) => {
console.log(' Caller OnRelease CallBack is called ${str}');
};
caller.on('release', onReleaseCallBack);
caller.off('release');
} catch (error) {
console.error('Caller.on or Caller.off catch error, error.code: ${JSON.stringify(error.code)}, error.message: ${JSON.stringify(error.message)}');
}
}).catch((err) => {
console.error('Caller GetCaller error, error.code: ${JSON.stringify(err.code)}, error.message: ${JSON.stringify(err.message)}');
});
}
}
```
## Callee
......@@ -638,8 +726,8 @@ For details about the error codes, see [Ability Error Codes](../errorcodes/error
```ts
class MyMessageAble{
name:""
str:""
name:''
str:''
num: 1
constructor(name, str) {
this.name = name;
......@@ -648,22 +736,22 @@ For details about the error codes, see [Ability Error Codes](../errorcodes/error
marshalling(messageParcel) {
messageParcel.writeInt(this.num);
messageParcel.writeString(this.str);
console.log('MyMessageAble marshalling num[' + this.num + '] str[' + this.str + ']');
console.log('MyMessageAble marshalling num[${this.num}] str[${this.str}]');
return true;
}
unmarshalling(messageParcel) {
this.num = messageParcel.readInt();
this.str = messageParcel.readString();
console.log('MyMessageAble unmarshalling num[' + this.num + '] str[' + this.str + ']');
console.log('MyMessageAble unmarshalling num[${this.num}] str[${this.str}]');
return true;
}
};
var method = 'call_Function';
let method = 'call_Function';
function funcCallBack(pdata) {
console.log('Callee funcCallBack is called ' + pdata);
let msg = new MyMessageAble("test", "");
console.log('Callee funcCallBack is called ${pdata}');
let msg = new MyMessageAble('test', '');
pdata.readSequenceable(msg);
return new MyMessageAble("test1", "Callee test");
return new MyMessageAble('test1', 'Callee test');
}
export default class MainUIAbility extends UIAbility {
onCreate(want, launchParam) {
......@@ -671,8 +759,7 @@ For details about the error codes, see [Ability Error Codes](../errorcodes/error
try {
this.callee.on(method, funcCallBack);
} catch (error) {
console.log('Callee.on catch error, error.code: ' + JSON.stringify(error.code) +
' error.message: ' + JSON.stringify(error.message));
console.log('Callee.on catch error, error.code: ${JSON.stringify(error.code)}, error.message: ${JSON.stringify(error.message)}');
}
}
}
......@@ -704,15 +791,14 @@ For details about the error codes, see [Ability Error Codes](../errorcodes/error
**Example**
```ts
var method = 'call_Function';
let method = 'call_Function';
export default class MainUIAbility extends UIAbility {
onCreate(want, launchParam) {
console.log('Callee onCreate is called');
try {
this.callee.off(method);
} catch (error) {
console.log('Callee.off catch error, error.code: ' + JSON.stringify(error.code) +
' error.message: ' + JSON.stringify(error.message));
console.log('Callee.off catch error, error.code: ${JSON.stringify(error.code)}, error.message: ${JSON.stringify(error.message)}');
}
}
}
......
......@@ -22,115 +22,133 @@ import Want from '@ohos.app.ability.Want';
| bundleName | string | No | Bundle name of the 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.|
| [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). |
| [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.|
| 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 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). |
| 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.|
| 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**.|
| 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.|
| 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. |
| 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.|
| 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.|
**Example**
- Basic usage (called in a UIAbility object, where context in the example is the context object of the UIAbility).
- Basic usage: called in a UIAbility object, as shown in the example below. For details about how to obtain the context, see [Obtaining the Context of UIAbility](../../application-models/uiability-usage.md#obtaining-the-context-of-uiability).
```ts
let want = {
"deviceId": "", // An empty deviceId indicates the local device.
"bundleName": "com.example.myapplication",
"abilityName": "FuncAbility",
"moduleName": "entry" // moduleName is optional.
};
this.context.startAbility(want, (error) => {
// Start an ability explicitly. The bundleName, abilityName, and moduleName parameters work together to uniquely identify an ability.
console.log("error.code = " + error.code)
})
let want = {
'deviceId': '', // An empty deviceId indicates the local device.
'bundleName': 'com.example.myapplication',
'abilityName': 'FuncAbility',
'moduleName': 'entry' // moduleName is optional.
};
this.context.startAbility(want, (err) => {
// Start an ability explicitly. The bundleName, abilityName, and moduleName parameters work together to uniquely identify an ability.
console.error(`startAbility failed, code is ${err.code}, message is ${err.message}`);
});
```
- 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 (called in a UIAbility object, as shown in the example below. For details about how to obtain the context, see [Obtaining the Context of UIAbility](../../application-models/uiability-usage.md#obtaining-the-context-of-uiability).)
* String
```ts
let want = {
bundleName: "com.example.myapplication",
abilityName: "FuncAbility",
parameters: {
keyForString: "str",
},
}
bundleName: 'com.example.myapplication',
abilityName: 'FuncAbility',
parameters: {
keyForString: 'str',
},
};
this.context.startAbility(want, (err) => {
console.error(`startAbility failed, code is ${err.code}, message is ${err.message}`);
});
```
* Number
```ts
let want = {
bundleName: "com.example.myapplication",
abilityName: "FuncAbility",
parameters: {
keyForInt: 100,
keyForDouble: 99.99,
},
}
bundleName: 'com.example.myapplication',
abilityName: 'FuncAbility',
parameters: {
keyForInt: 100,
keyForDouble: 99.99,
},
};
this.context.startAbility(want, (err) => {
console.error(`startAbility failed, code is ${err.code}, message is ${err.message}`);
});
```
* Boolean
```ts
let want = {
bundleName: "com.example.myapplication",
abilityName: "FuncAbility",
parameters: {
keyForBool: true,
},
}
bundleName: 'com.example.myapplication',
abilityName: 'FuncAbility',
parameters: {
keyForBool: true,
},
};
this.context.startAbility(want, (err) => {
console.error(`startAbility failed, code is ${err.code}, message is ${err.message}`);
});
```
* Object
```ts
let want = {
bundleName: "com.example.myapplication",
abilityName: "FuncAbility",
parameters: {
keyForObject: {
keyForObjectString: "str",
keyForObjectInt: -200,
keyForObjectDouble: 35.5,
keyForObjectBool: false,
},
bundleName: 'com.example.myapplication',
abilityName: 'FuncAbility',
parameters: {
keyForObject: {
keyForObjectString: 'str',
keyForObjectInt: -200,
keyForObjectDouble: 35.5,
keyForObjectBool: false,
},
}
},
};
this.context.startAbility(want, (err) => {
console.error(`startAbility failed, code is ${err.code}, message is ${err.message}`);
});
```
* Array
```ts
let want = {
bundleName: "com.example.myapplication",
abilityName: "FuncAbility",
parameters: {
keyForArrayString: ["str1", "str2", "str3"],
keyForArrayInt: [100, 200, 300, 400],
keyForArrayDouble: [0.1, 0.2],
keyForArrayObject: [{obj1: "aaa"}, {obj2: 100}],
},
}
bundleName: 'com.example.myapplication',
abilityName: 'FuncAbility',
parameters: {
keyForArrayString: ['str1', 'str2', 'str3'],
keyForArrayInt: [100, 200, 300, 400],
keyForArrayDouble: [0.1, 0.2],
keyForArrayObject: [{ obj1: 'aaa' }, { obj2: 100 }],
},
};
this.context.startAbility(want, (err) => {
console.error(`startAbility failed, code is ${err.code}, message is ${err.message}`);
});
```
* File descriptor (FD)
```ts
import fileio from '@ohos.fileio';
let fd;
try {
fd = fileio.openSync("/data/storage/el2/base/haps/pic.png");
fd = fileio.openSync('/data/storage/el2/base/haps/pic.png');
} catch(e) {
console.log("openSync fail:" + JSON.stringify(e));
console.log('openSync fail: ${JSON.stringify(e)}');
}
let want = {
"deviceId": "", // An empty deviceId indicates the local device.
"bundleName": "com.example.myapplication",
"abilityName": "FuncAbility",
"moduleName": "entry", // moduleName is optional.
"parameters": {
"keyFd":{"type":"FD", "value":fd}
}
'deviceId': '', // An empty deviceId indicates the local device.
'bundleName': 'com.example.myapplication',
'abilityName': 'FuncAbility',
'moduleName': 'entry', // moduleName is optional.
'parameters': {
'keyFd': { 'type': 'FD', 'value': fd } // {'type':'FD', 'value':fd} is a fixed usage, indicating that the data is a file descriptor.
}
};
this.context.startAbility(want, (error) => {
// Start an ability explicitly. The bundleName, abilityName, and moduleName parameters work together to uniquely identify an ability.
console.log("error.code = " + error.code)
})
this.context.startAbility(want, (err) => {
console.error(`startAbility failed, code is ${err.code}, message is ${err.message}`);
});
```
- For more details and examples, see [Want](../../application-models/want-overview.md).
......@@ -8,65 +8,21 @@ The **wantConstant** module provides the actions, entities, and flags used in **
## Modules to Import
```js
```ts
import wantConstant from '@ohos.app.ability.wantConstant';
```
## wantConstant.Action
## wantConstant.Params
Enumerates the action constants of the **Want** object. **action** specifies the operation to execute.
Defines **Params** (specifying the action that can be performed) in the Want.
**System capability**: SystemCapability.Ability.AbilityBase
| Name | Value | Description |
| ------------ | ------------------ | ---------------------- |
| ACTION_HOME | ohos.want.action.home | Action of returning to the home page. |
| ACTION_DIAL | ohos.want.action.dial | Action of launching the numeric keypad. |
| ACTION_SEARCH | ohos.want.action.search | Action of launching the search function. |
| ACTION_WIRELESS_SETTINGS | ohos.settings.wireless | Action of launching the UI that provides wireless network settings, for example, Wi-Fi options. |
| ACTION_MANAGE_APPLICATIONS_SETTINGS | ohos.settings.manage.applications | Action of launching the UI for managing installed applications. |
| ACTION_APPLICATION_DETAILS_SETTINGS | ohos.settings.application.details | Action of launching the UI that displays the details of an application. |
| ACTION_SET_ALARM | ohos.want.action.setAlarm | Action of launching the UI for setting the alarm clock. |
| ACTION_SHOW_ALARMS | ohos.want.action.showAlarms | Action of launching the UI that displays all alarms. |
| ACTION_SNOOZE_ALARM | ohos.want.action.snoozeAlarm | Action of launching the UI for snoozing an alarm. |
| ACTION_DISMISS_ALARM | ohos.want.action.dismissAlarm | Action of launching the UI for deleting an alarm. |
| ACTION_DISMISS_TIMER | ohos.want.action.dismissTimer | Action of launching the UI for dismissing a timer. |
| ACTION_SEND_SMS | ohos.want.action.sendSms | Action of launching the UI for sending an SMS message. |
| ACTION_CHOOSE | ohos.want.action.choose | Action of launching the UI for opening a contact or picture. |
| ACTION_IMAGE_CAPTURE | ohos.want.action.imageCapture | Action of launching the UI for photographing. |
| ACTION_VIDEO_CAPTURE | ohos.want.action.videoCapture | Action of launching the UI for shooting a video. |
| ACTION_SELECT | ohos.want.action.select | Action of launching the UI for application selection. |
| ACTION_SEND_DATA | ohos.want.action.sendData | Action of launching the UI for sending a single data record. |
| ACTION_SEND_MULTIPLE_DATA | ohos.want.action.sendMultipleData | Action of launching the UI for sending multiple data records. |
| ACTION_SCAN_MEDIA_FILE | ohos.want.action.scanMediaFile | Action of requesting a media scanner to scan a file and add the file to the media library. |
| ACTION_VIEW_DATA | ohos.want.action.viewData | Action of viewing data. |
| ACTION_EDIT_DATA | ohos.want.action.editData | Action of editing data. |
| 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. |
| ACTION_FILE_SELECT | ohos.action.fileSelect | Action of selecting a file. |
| PARAMS_STREAM | ability.params.stream | URI of the data stream associated with the target when the data is sent. |
| ACTION_APP_ACCOUNT_AUTH | account.appAccount.action.auth | Action of providing the authentication service. |
| ACTION_MARKET_DOWNLOAD | 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_CROWDTEST | ohos.want.action.marketCrowdTest | Action of crowdtesting an application from the application market.<br>**System API**: This is a system API and cannot be called by third-party applications. |
| DLP_PARAMS_SANDBOX |ohos.dlp.params.sandbox | Action of obtaining the sandbox flag.<br>**System API**: This is a system API and cannot be called by third-party applications. |
| DLP_PARAMS_BUNDLE_NAME |ohos.dlp.params.bundleName |Action of obtaining the DLP bundle name.<br>**System API**: This is a system API and cannot be called by third-party applications. |
| DLP_PARAMS_MODULE_NAME |ohos.dlp.params.moduleName |Action of obtaining the DLP module name.<br>**System API**: This is a system API and cannot be called by third-party applications. |
| DLP_PARAMS_ABILITY_NAME |ohos.dlp.params.abilityName |Action of obtaining the DLP ability name.<br>**System API**: This is a system API and cannot be called by third-party applications. |
| DLP_PARAMS_INDEX |ohos.dlp.params.index |Action of obtaining the DLP index.<br>**System API**: This is a system API and cannot be called by third-party applications. |
## wantConstant.Entity
Enumerates the entity constants of the **Want** object. **entity** specifies additional information of the target ability.
**System capability**: SystemCapability.Ability.AbilityBase
| Name | Value | Description |
| ------------ | ------------------ | ---------------------- |
| ENTITY_DEFAULT | entity.system.default | Default entity. The default entity is used if no entity is specified. |
| ENTITY_HOME | entity.system.home | Home screen entity. |
| ENTITY_VOICE | entity.system.voice | Voice interaction entity. |
| ENTITY_BROWSABLE | entity.system.browsable | Browser type entity. |
| ENTITY_VIDEO | entity.system.video | Video type entity. |
| Name | Value | Description |
| ----------------------- | --------------------------- | ------------------------------------------------------------ |
| DLP_PARAMS_SANDBOX | ohos.dlp.params.sandbox | Action of obtaining the sandbox flag.<br>**System API**: This is a system API and cannot be called by third-party applications.|
| DLP_PARAMS_BUNDLE_NAME | ohos.dlp.params.bundleName | Action of obtaining the DLP bundle name.<br>**System API**: This is a system API and cannot be called by third-party applications.|
| DLP_PARAMS_MODULE_NAME | ohos.dlp.params.moduleName | Action of obtaining the DLP module name.<br>**System API**: This is a system API and cannot be called by third-party applications.|
| DLP_PARAMS_ABILITY_NAME | ohos.dlp.params.abilityName | Action of obtaining the DLP ability name.<br>**System API**: This is a system API and cannot be called by third-party applications.|
| DLP_PARAMS_INDEX | ohos.dlp.params.index | Action of obtaining the DLP index.<br>**System API**: This is a system API and cannot be called by third-party applications.|
## wantConstant.Flags
......
......@@ -35,7 +35,7 @@ Creates a **FormBindingData** object.
| Name| Type | Mandatory| Description |
| ------ | -------------- | ---- | ------------------------------------------------------------ |
| 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**
......@@ -48,14 +48,14 @@ Creates a **FormBindingData** object.
**Example**
```ts
import fs from '@ohos.file.fs';
import formBindingData from '@ohos.app.form.formBindingData';
import fs from '@ohos.file.fs';
try {
let fd = fs.openSync('/path/to/form.png')
let fd = fs.openSync('/path/to/form.png');
let obj = {
"temperature": "21°",
"formImages": { "image": fd }
'temperature': '21°',
'formImages': { 'image': fd }
};
formBindingData.createFormBindingData(obj);
} catch (error) {
......
......@@ -43,7 +43,7 @@ Deletes a widget. After this API is called, the application can no longer use th
import formHost from '@ohos.app.form.formHost';
try {
let formId = "12400633174999288";
let formId = '12400633174999288';
formHost.deleteForm(formId, (error) => {
if (error) {
console.log(`error, code: ${error.code}, message: ${error.message}`);
......@@ -92,7 +92,7 @@ Deletes a widget. After this API is called, the application can no longer use th
import formHost from '@ohos.app.form.formHost';
try {
let formId = "12400633174999288";
let formId = '12400633174999288';
formHost.deleteForm(formId).then(() => {
console.log('formHost deleteForm success');
}).catch((error) => {
......@@ -133,7 +133,7 @@ Releases a widget. After this API is called, the application can no longer use t
import formHost from '@ohos.app.form.formHost';
try {
let formId = "12400633174999288";
let formId = '12400633174999288';
formHost.releaseForm(formId, (error) => {
if (error) {
console.log(`error, code: ${error.code}, message: ${error.message}`);
......@@ -175,7 +175,7 @@ Releases a widget. After this API is called, the application can no longer use t
import formHost from '@ohos.app.form.formHost';
try {
let formId = "12400633174999288";
let formId = '12400633174999288';
formHost.releaseForm(formId, true, (error) => {
if (error) {
console.log(`error, code: ${error.code}, message: ${error.message}`);
......@@ -222,7 +222,7 @@ Releases a widget. After this API is called, the application can no longer use t
import formHost from '@ohos.app.form.formHost';
try {
let formId = "12400633174999288";
let formId = '12400633174999288';
formHost.releaseForm(formId, true).then(() => {
console.log('formHost releaseForm success');
}).catch((error) => {
......@@ -263,7 +263,7 @@ Requests a widget update. This API uses an asynchronous callback to return the r
import formHost from '@ohos.app.form.formHost';
try {
let formId = "12400633174999288";
let formId = '12400633174999288';
formHost.requestForm(formId, (error) => {
if (error) {
console.log(`error, code: ${error.code}, message: ${error.message}`);
......@@ -309,7 +309,7 @@ Requests a widget update. This API uses a promise to return the result.
import formHost from '@ohos.app.form.formHost';
try {
let formId = "12400633174999288";
let formId = '12400633174999288';
formHost.requestForm(formId).then(() => {
console.log('formHost requestForm success');
}).catch((error) => {
......@@ -351,7 +351,7 @@ Converts a temporary widget to a normal one. This API uses an asynchronous callb
import formHost from '@ohos.app.form.formHost';
try {
let formId = "12400633174999288";
let formId = '12400633174999288';
formHost.castToNormalForm(formId, (error) => {
if (error) {
console.log(`error, code: ${error.code}, message: ${error.message}`);
......@@ -397,7 +397,7 @@ Converts a temporary widget to a normal one. This API uses a promise to return t
import formHost from '@ohos.app.form.formHost';
try {
let formId = "12400633174999288";
let formId = '12400633174999288';
formHost.castToNormalForm(formId).then(() => {
console.log('formHost castTempForm success');
}).catch((error) => {
......@@ -438,7 +438,7 @@ Instructs the widget framework to make a widget visible. After this API is calle
import formHost from '@ohos.app.form.formHost';
try {
let formId = ["12400633174999288"];
let formId = ['12400633174999288'];
formHost.notifyVisibleForms(formId, (error) => {
if (error) {
console.log(`error, code: ${error.code}, message: ${error.message}`);
......@@ -484,7 +484,7 @@ Instructs the widget framework to make a widget visible. After this API is calle
import formHost from '@ohos.app.form.formHost';
try {
let formId = ["12400633174999288"];
let formId = ['12400633174999288'];
formHost.notifyVisibleForms(formId).then(() => {
console.log('formHost notifyVisibleForms success');
}).catch((error) => {
......@@ -525,7 +525,7 @@ Instructs the widget framework to make a widget invisible. After this API is cal
import formHost from '@ohos.app.form.formHost';
try {
let formId = ["12400633174999288"];
let formId = ['12400633174999288'];
formHost.notifyInvisibleForms(formId, (error) => {
if (error) {
console.log(`error, code: ${error.code}, message: ${error.message}`);
......@@ -571,7 +571,7 @@ Instructs the widget framework to make a widget invisible. After this API is cal
import formHost from '@ohos.app.form.formHost';
try {
let formId = ["12400633174999288"];
let formId = ['12400633174999288'];
formHost.notifyInvisibleForms(formId).then(() => {
console.log('formHost notifyInvisibleForms success');
}).catch((error) => {
......@@ -612,7 +612,7 @@ Instructs the widget framework to make a widget updatable. After this API is cal
import formHost from '@ohos.app.form.formHost';
try {
let formId = ["12400633174999288"];
let formId = ['12400633174999288'];
formHost.enableFormsUpdate(formId, (error) => {
if (error) {
console.log(`error, code: ${error.code}, message: ${error.message}`);
......@@ -658,7 +658,7 @@ Instructs the widget framework to make a widget updatable. After this API is cal
import formHost from '@ohos.app.form.formHost';
try {
let formId = ["12400633174999288"];
let formId = ['12400633174999288'];
formHost.enableFormsUpdate(formId).then(() => {
console.log('formHost enableFormsUpdate success');
}).catch((error) => {
......@@ -699,7 +699,7 @@ Instructs the widget framework to make a widget not updatable. After this API is
import formHost from '@ohos.app.form.formHost';
try {
let formId = ["12400633174999288"];
let formId = ['12400633174999288'];
formHost.disableFormsUpdate(formId, (error) => {
if (error) {
console.log(`error, code: ${error.code}, message: ${error.message}`);
......@@ -745,7 +745,7 @@ Instructs the widget framework to make a widget not updatable. After this API is
import formHost from '@ohos.app.form.formHost';
try {
let formId = ["12400633174999288"];
let formId = ['12400633174999288'];
formHost.disableFormsUpdate(formId).then(() => {
console.log('formHost disableFormsUpdate success');
}).catch((error) => {
......@@ -842,7 +842,7 @@ try {
if (error) {
console.log(`error, code: ${error.code}, message: ${error.message}`);
} else {
console.log('formHost getAllFormsInfo, data:' + JSON.stringify(data));
console.log('formHost getAllFormsInfo, data: ${JSON.stringify(data)}');
}
});
} catch(error) {
......@@ -873,7 +873,7 @@ import formHost from '@ohos.app.form.formHost';
try {
formHost.getAllFormsInfo().then((data) => {
console.log('formHost getAllFormsInfo data:' + JSON.stringify(data));
console.log('formHost getAllFormsInfo data: ${JSON.stringify(data)}');
}).catch((error) => {
console.log(`error, code: ${error.code}, message: ${error.message}`);
});
......@@ -912,11 +912,11 @@ Obtains the widget information provided by a given application on the device. Th
import formHost from '@ohos.app.form.formHost';
try {
formHost.getFormsInfo("com.example.ohos.formjsdemo", (error, data) => {
formHost.getFormsInfo('com.example.ohos.formjsdemo', (error, data) => {
if (error) {
console.log(`error, code: ${error.code}, message: ${error.message}`);
} else {
console.log('formHost getFormsInfo, data:' + JSON.stringify(data));
console.log('formHost getFormsInfo, data: ${JSON.stringify(data)}');
}
});
} catch(error) {
......@@ -955,11 +955,11 @@ Obtains the widget information provided by a given application on the device. Th
import formHost from '@ohos.app.form.formHost';
try {
formHost.getFormsInfo("com.example.ohos.formjsdemo", "entry", (error, data) => {
formHost.getFormsInfo('com.example.ohos.formjsdemo', 'entry', (error, data) => {
if (error) {
console.log(`error, code: ${error.code}, message: ${error.message}`);
} else {
console.log('formHost getFormsInfo, data:' + JSON.stringify(data));
console.log('formHost getFormsInfo, data: ${JSON.stringify(data)}');
}
});
} catch(error) {
......@@ -1003,8 +1003,8 @@ Obtains the widget information provided by a given application on the device. Th
import formHost from '@ohos.app.form.formHost';
try {
formHost.getFormsInfo("com.example.ohos.formjsdemo", "entry").then((data) => {
console.log('formHost getFormsInfo, data:' + JSON.stringify(data));
formHost.getFormsInfo('com.example.ohos.formjsdemo', 'entry').then((data) => {
console.log('formHost getFormsInfo, data: ${JSON.stringify(data)}');
}).catch((error) => {
console.log(`error, code: ${error.code}, message: ${error.message}`);
});
......@@ -1036,12 +1036,12 @@ Deletes invalid widgets from the list. This API uses an asynchronous callback to
import formHost from '@ohos.app.form.formHost';
try {
let formIds = new Array("12400633174999288", "12400633174999289");
let formIds = new Array('12400633174999288', '12400633174999289');
formHost.deleteInvalidForms(formIds, (error, data) => {
if (error) {
console.log(`error, code: ${error.code}, message: ${error.message}`);
} else {
console.log('formHost deleteInvalidForms, data:' + JSON.stringify(data));
console.log('formHost deleteInvalidForms, data: ${JSON.stringify(data)}');
}
});
} catch(error) {
......@@ -1077,9 +1077,9 @@ Deletes invalid widgets from the list. This API uses a promise to return the res
import formHost from '@ohos.app.form.formHost';
try {
let formIds = new Array("12400633174999288", "12400633174999289");
let formIds = new Array('12400633174999288', '12400633174999289');
formHost.deleteInvalidForms(formIds).then((data) => {
console.log('formHost deleteInvalidForms, data:' + JSON.stringify(data));
console.log('formHost deleteInvalidForms, data: ${JSON.stringify(data)}');
}).catch((error) => {
console.log(`error, code: ${error.code}, message: ${error.message}`);
});
......@@ -1118,13 +1118,13 @@ Obtains the widget state. This API uses an asynchronous callback to return the r
import formHost from '@ohos.app.form.formHost';
let want = {
"deviceId": "",
"bundleName": "ohos.samples.FormApplication",
"abilityName": "FormAbility",
"parameters": {
"ohos.extra.param.key.module_name": "entry",
"ohos.extra.param.key.form_name": "widget",
"ohos.extra.param.key.form_dimension": 2
'deviceId': '',
'bundleName': 'ohos.samples.FormApplication',
'abilityName': 'FormAbility',
'parameters': {
'ohos.extra.param.key.module_name': 'entry',
'ohos.extra.param.key.form_name': 'widget',
'ohos.extra.param.key.form_dimension': 2
}
};
try {
......@@ -1132,7 +1132,7 @@ try {
if (error) {
console.log(`error, code: ${error.code}, message: ${error.message}`);
} else {
console.log('formHost acquireFormState, data:' + JSON.stringify(data));
console.log('formHost acquireFormState, data: ${JSON.stringify(data)}');
}
});
} catch(error) {
......@@ -1175,18 +1175,18 @@ Obtains the widget state. This API uses a promise to return the result.
import formHost from '@ohos.app.form.formHost';
let want = {
"deviceId": "",
"bundleName": "ohos.samples.FormApplication",
"abilityName": "FormAbility",
"parameters": {
"ohos.extra.param.key.module_name": "entry",
"ohos.extra.param.key.form_name": "widget",
"ohos.extra.param.key.form_dimension": 2
'deviceId': '',
'bundleName': 'ohos.samples.FormApplication',
'abilityName': 'FormAbility',
'parameters': {
'ohos.extra.param.key.module_name': 'entry',
'ohos.extra.param.key.form_name': 'widget',
'ohos.extra.param.key.form_dimension': 2
}
};
try {
formHost.acquireFormState(want).then((data) => {
console.log('formHost acquireFormState, data:' + JSON.stringify(data));
console.log('formHost acquireFormState, data: ${JSON.stringify(data)}');
}).catch((error) => {
console.log(`error, code: ${error.code}, message: ${error.message}`);
});
......@@ -1195,9 +1195,9 @@ try {
}
```
## on("formUninstall")
## on('formUninstall')
on(type: "formUninstall", callback: Callback&lt;string&gt;): void
on(type: 'formUninstall', callback: Callback&lt;string&gt;): void
Subscribes to widget uninstall events. This API uses an asynchronous callback to return the result.
......@@ -1207,7 +1207,7 @@ Subscribes to widget uninstall events. This API uses an asynchronous callback to
| 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&lt;string&gt; | Yes| Callback used to return the widget ID.|
**Example**
......@@ -1216,14 +1216,14 @@ Subscribes to widget uninstall events. This API uses an asynchronous callback to
import formHost from '@ohos.app.form.formHost';
let callback = function(formId) {
console.log('formHost on formUninstall, formId:' + formId);
console.log('formHost on formUninstall, formId: ${formId}');
}
formHost.on("formUninstall", callback);
formHost.on('formUninstall', callback);
```
## off("formUninstall")
## off('formUninstall')
off(type: "formUninstall", callback?: Callback&lt;string&gt;): void
off(type: 'formUninstall', callback?: Callback&lt;string&gt;): void
Unsubscribes from widget uninstall events. This API uses an asynchronous callback to return the result.
......@@ -1233,8 +1233,8 @@ Unsubscribes from widget uninstall events. This API uses an asynchronous callbac
| Name| Type | Mandatory| Description |
| ------ | ------ | ---- | ------- |
| type | string | Yes | Event type. The value **formUninstall** indicates a widget uninstallation event.|
| callback | Callback&lt;string&gt; | 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")**.|
| type | string | Yes | Event type. The value **'formUninstall'** indicates a widget uninstallation event.|
| callback | Callback&lt;string&gt; | 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**
......@@ -1242,9 +1242,9 @@ Unsubscribes from widget uninstall events. This API uses an asynchronous callbac
import formHost from '@ohos.app.form.formHost';
let callback = 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
......@@ -1277,7 +1277,7 @@ Instructs the widgets to make themselves visible. This API uses an asynchronous
```ts
import formHost from '@ohos.app.form.formHost';
let formIds = new Array("12400633174999288", "12400633174999289");
let formIds = new Array('12400633174999288', '12400633174999289');
try {
formHost.notifyFormsVisible(formIds, true, (error) => {
if (error) {
......@@ -1324,7 +1324,7 @@ Instructs the widgets to make themselves visible. This API uses a promise to ret
```ts
import formHost from '@ohos.app.form.formHost';
let formIds = new Array("12400633174999288", "12400633174999289");
let formIds = new Array('12400633174999288', '12400633174999289');
try {
formHost.notifyFormsVisible(formIds, true).then(() => {
console.log('formHost notifyFormsVisible success');
......@@ -1366,7 +1366,7 @@ Instructs the widgets to enable or disable updates. This API uses an asynchronou
```ts
import formHost from '@ohos.app.form.formHost';
let formIds = new Array("12400633174999288", "12400633174999289");
let formIds = new Array('12400633174999288', '12400633174999289');
try {
formHost.notifyFormsEnableUpdate(formIds, true, (error) => {
if (error) {
......@@ -1413,7 +1413,7 @@ Instructs the widgets to enable or disable updates. This API uses a promise to r
```ts
import formHost from '@ohos.app.form.formHost';
let formIds = new Array("12400633174999288", "12400633174999289");
let formIds = new Array('12400633174999288', '12400633174999289');
try {
formHost.notifyFormsEnableUpdate(formIds, true).then(() => {
console.log('formHost notifyFormsEnableUpdate success');
......@@ -1454,8 +1454,8 @@ Shares a specified widget with a remote device. This API uses an asynchronous ca
```ts
import formHost from '@ohos.app.form.formHost';
let formId = "12400633174999288";
let deviceId = "EFC11C0C53628D8CC2F8CB5052477E130D075917034613B9884C55CD22B3DEF2";
let formId = '12400633174999288';
let deviceId = 'EFC11C0C53628D8CC2F8CB5052477E130D075917034613B9884C55CD22B3DEF2';
try {
formHost.shareForm(formId, deviceId, (error) => {
if (error) {
......@@ -1502,8 +1502,8 @@ Shares a specified widget with a remote device. This API uses a promise to retur
```ts
import formHost from '@ohos.app.form.formHost';
let formId = "12400633174999288";
let deviceId = "EFC11C0C53628D8CC2F8CB5052477E130D075917034613B9884C55CD22B3DEF2";
let formId = '12400633174999288';
let deviceId = 'EFC11C0C53628D8CC2F8CB5052477E130D075917034613B9884C55CD22B3DEF2';
try {
formHost.shareForm(formId, deviceId).then(() => {
console.log('formHost shareForm success');
......@@ -1545,7 +1545,7 @@ Notifies that the privacy protection status of the specified widgets changes. Th
```ts
import formHost from '@ohos.app.form.formHost';
let formIds = new Array("12400633174999288", "12400633174999289");
let formIds = new Array('12400633174999288', '12400633174999289');
try {
formHost.notifyFormsPrivacyProtected(formIds, true, (error) => {
if (error) {
......@@ -1590,7 +1590,7 @@ Notifies that the privacy protection status of the specified widgets changes. Th
```ts
import formHost from '@ohos.app.form.formHost';
let formIds = new Array("12400633174999288", "12400633174999289");
let formIds = new Array('12400633174999288', '12400633174999289');
try {
formHost.notifyFormsPrivacyProtected(formIds, true).then(() => {
console.log('formHost notifyFormsPrivacyProtected success');
......
......@@ -31,7 +31,6 @@ Describes widget information.
| isDefault | boolean | Yes | No | Whether the widget is the default one. |
| updateEnabled | boolean | Yes | No | Whether the widget is updatable. |
| formVisibleNotify | boolean | Yes | No | Whether to send a notification when the widget is visible. |
| relatedBundleName | string | Yes | No | Name of the associated bundle to which the widget belongs. |
| scheduledUpdateTime | string | Yes | No | Time when the widget was updated. |
| formConfigAbility | string | Yes | No | Configuration ability of the widget, that is, the ability corresponding to the option in the selection box displayed when the widget is long pressed. |
| updateDuration | number | Yes | No | Update period of the widget.|
......@@ -93,16 +92,16 @@ Enumerates the widget parameters.
| Name | Value | Description |
| ----------- | ---- | ------------ |
| IDENTITY_KEY | "ohos.extra.param.key.form_identity" | Widget ID. |
| DIMENSION_KEY | "ohos.extra.param.key.form_dimension" | Widget dimension. |
| NAME_KEY | "ohos.extra.param.key.form_name" | Widget name. |
| MODULE_NAME_KEY | "ohos.extra.param.key.module_name" | Name of the module to which the widget belongs. |
| WIDTH_KEY | "ohos.extra.param.key.form_width" | Widget width. |
| HEIGHT_KEY | "ohos.extra.param.key.form_height" | Widget height. |
| TEMPORARY_KEY | "ohos.extra.param.key.form_temporary" | Temporary widget. |
| ABILITY_NAME_KEY | "ohos.extra.param.key.ability_name" | Ability name. |
| DEVICE_ID_KEY | "ohos.extra.param.key.device_id" | Device ID. |
| BUNDLE_NAME_KEY | "ohos.extra.param.key.bundle_name" | Key that specifies the target bundle name.|
| IDENTITY_KEY | 'ohos.extra.param.key.form_identity' | Widget ID. |
| DIMENSION_KEY | 'ohos.extra.param.key.form_dimension' | Widget dimension. |
| NAME_KEY | 'ohos.extra.param.key.form_name' | Widget name. |
| MODULE_NAME_KEY | 'ohos.extra.param.key.module_name' | Name of the module to which the widget belongs. |
| WIDTH_KEY | 'ohos.extra.param.key.form_width' | Widget width. |
| HEIGHT_KEY | 'ohos.extra.param.key.form_height' | Widget height. |
| TEMPORARY_KEY | 'ohos.extra.param.key.form_temporary' | Temporary widget. |
| ABILITY_NAME_KEY | 'ohos.extra.param.key.ability_name' | Ability name. |
| DEVICE_ID_KEY | 'ohos.extra.param.key.device_id' | Device ID. |
| BUNDLE_NAME_KEY | 'ohos.extra.param.key.bundle_name' | Key that specifies the target bundle name.|
## FormDimension
......
......@@ -39,7 +39,7 @@ Sets the next refresh time for a widget. This API uses an asynchronous callback
```ts
import formProvider from '@ohos.app.form.formProvider';
let formId = "12400633174999288";
let formId = '12400633174999288';
try {
formProvider.setFormNextRefreshTime(formId, 5, (error, data) => {
if (error) {
......@@ -86,7 +86,7 @@ Sets the next refresh time for a widget. This API uses a promise to return the r
```ts
import formProvider from '@ohos.app.form.formProvider';
let formId = "12400633174999288";
let formId = '12400633174999288';
try {
formProvider.setFormNextRefreshTime(formId, 5).then(() => {
console.log(`formProvider setFormNextRefreshTime success`);
......@@ -127,9 +127,9 @@ Updates a widget. This API uses an asynchronous callback to return the result.
import formBindingData from '@ohos.app.form.formBindingData';
import formProvider from '@ohos.app.form.formProvider';
let formId = "12400633174999288";
let formId = '12400633174999288';
try {
let obj = formBindingData.createFormBindingData({temperature:"22c", time:"22:00"});
let obj = formBindingData.createFormBindingData({temperature:'22c', time:'22:00'});
formProvider.updateForm(formId, obj, (error, data) => {
if (error) {
console.log(`callback error, code: ${error.code}, message: ${error.message})`);
......@@ -176,8 +176,8 @@ Updates a widget. This API uses a promise to return the result.
import formBindingData from '@ohos.app.form.formBindingData';
import formProvider from '@ohos.app.form.formProvider';
let formId = "12400633174999288";
let obj = formBindingData.createFormBindingData({ temperature: "22c", time: "22:00" });
let formId = '12400633174999288';
let obj = formBindingData.createFormBindingData({ temperature: '22c', time: '22:00' });
try {
formProvider.updateForm(formId, obj).then(() => {
console.log(`formProvider updateForm success`);
......@@ -221,7 +221,7 @@ try {
if (error) {
console.log(`callback error, code: ${error.code}, message: ${error.message})`);
} else {
console.log('formProvider getFormsInfo, data: ' + JSON.stringify(data));
console.log('formProvider getFormsInfo, data: ${JSON.stringify(data)}');
}
});
} catch (error) {
......@@ -258,14 +258,14 @@ import formProvider from '@ohos.app.form.formProvider';
const filter: formInfo.FormInfoFilter = {
// get info of forms belong to module entry.
moduleName: "entry"
moduleName: 'entry'
};
try {
formProvider.getFormsInfo(filter, (error, data) => {
if (error) {
console.log(`callback error, code: ${error.code}, message: ${error.message})`);
} else {
console.log('formProvider getFormsInfo, data: ' + JSON.stringify(data));
console.log('formProvider getFormsInfo, data: ${JSON.stringify(data)}');
}
});
} catch (error) {
......@@ -308,11 +308,11 @@ import formProvider from '@ohos.app.form.formProvider';
const filter: formInfo.FormInfoFilter = {
// get info of forms belong to module entry.
moduleName: "entry"
moduleName: 'entry'
};
try {
formProvider.getFormsInfo(filter).then((data) => {
console.log('formProvider getFormsInfo, data:' + JSON.stringify(data));
console.log('formProvider getFormsInfo, data: ${JSON.stringify(data)}');
}).catch((error) => {
console.log(`promise error, code: ${error.code}, message: ${error.message})`);
});
......@@ -335,7 +335,7 @@ Requests to publish a widget carrying data to the widget host. This API uses an
| Name| Type | Mandatory| Description |
| ------ | ---------------------------------------------------------------------- | ---- | ---------------- |
| 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.|
| callback | AsyncCallback&lt;string&gt; | Yes| Callback used to return the widget ID.|
......@@ -353,20 +353,20 @@ import formBindingData from '@ohos.app.form.formBindingData';
import formProvider from '@ohos.app.form.formProvider';
let want = {
abilityName: "FormAbility",
abilityName: 'FormAbility',
parameters: {
"ohos.extra.param.key.form_dimension": 2,
"ohos.extra.param.key.form_name": "widget",
"ohos.extra.param.key.module_name": "entry"
'ohos.extra.param.key.form_dimension': 2,
'ohos.extra.param.key.form_name': 'widget',
'ohos.extra.param.key.module_name': 'entry'
}
};
try {
let obj = formBindingData.createFormBindingData({ temperature: "22c", time: "22:00" });
let obj = formBindingData.createFormBindingData({ temperature: '22c', time: '22:00' });
formProvider.requestPublishForm(want, obj, (error, data) => {
if (error) {
console.log(`callback error, code: ${error.code}, message: ${error.message})`);
} else {
console.log('formProvider requestPublishForm, form ID is: ' + JSON.stringify(data));
console.log('formProvider requestPublishForm, form ID is: ${JSON.stringify(data)}');
}
});
} catch (error) {
......@@ -388,7 +388,7 @@ Requests to publish a widget to the widget host. This API uses an asynchronous c
| Name | Type | Mandatory| Description |
| -------- | ----------------------------------- | ---- | ------------------------------------------------------------ |
| 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&lt;string&gt; | Yes | Callback used to return the widget ID.|
**Error codes**
......@@ -404,11 +404,11 @@ Requests to publish a widget to the widget host. This API uses an asynchronous c
import formProvider from '@ohos.app.form.formProvider';
let want = {
abilityName: "FormAbility",
abilityName: 'FormAbility',
parameters: {
"ohos.extra.param.key.form_dimension": 2,
"ohos.extra.param.key.form_name": "widget",
"ohos.extra.param.key.module_name": "entry"
'ohos.extra.param.key.form_dimension': 2,
'ohos.extra.param.key.form_name': 'widget',
'ohos.extra.param.key.module_name': 'entry'
}
};
try {
......@@ -416,7 +416,7 @@ try {
if (error) {
console.log(`callback error, code: ${error.code}, message: ${error.message})`);
} else {
console.log('formProvider requestPublishForm, form ID is: ' + JSON.stringify(data));
console.log('formProvider requestPublishForm, form ID is: ${JSON.stringify(data)}');
}
});
} catch (error) {
......@@ -438,7 +438,7 @@ Requests to publish a widget to the widget host. This API uses a promise to retu
| Name | Type | Mandatory| Description |
| --------------- | ------------------------------------------------------------ | ---- | ------------------------------------------------------------ |
| 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. |
**Return value**
......@@ -460,16 +460,16 @@ Requests to publish a widget to the widget host. This API uses a promise to retu
import formProvider from '@ohos.app.form.formProvider';
let want = {
abilityName: "FormAbility",
abilityName: 'FormAbility',
parameters: {
"ohos.extra.param.key.form_dimension": 2,
"ohos.extra.param.key.form_name": "widget",
"ohos.extra.param.key.module_name": "entry"
'ohos.extra.param.key.form_dimension': 2,
'ohos.extra.param.key.form_name': 'widget',
'ohos.extra.param.key.module_name': 'entry'
}
};
try {
formProvider.requestPublishForm(want).then((data) => {
console.log('formProvider requestPublishForm success, form ID is :' + JSON.stringify(data));
console.log('formProvider requestPublishForm success, form ID is : ${JSON.stringify(data)}');
}).catch((error) => {
console.log(`promise error, code: ${error.code}, message: ${error.message})`);
});
......@@ -506,11 +506,11 @@ try {
} else {
if (isSupported) {
var want = {
abilityName: "FormAbility",
abilityName: 'FormAbility',
parameters: {
"ohos.extra.param.key.form_dimension": 2,
"ohos.extra.param.key.form_name": "widget",
"ohos.extra.param.key.module_name": "entry"
'ohos.extra.param.key.form_dimension': 2,
'ohos.extra.param.key.form_name': 'widget',
'ohos.extra.param.key.module_name': 'entry'
}
};
try {
......@@ -518,7 +518,7 @@ try {
if (error) {
console.log(`callback error, code: ${error.code}, message: ${error.message})`);
} else {
console.log('formProvider requestPublishForm, form ID is: ' + JSON.stringify(data));
console.log('formProvider requestPublishForm, form ID is: ${JSON.stringify(data)}');
}
});
} catch (error) {
......@@ -557,16 +557,16 @@ try {
formProvider.isRequestPublishFormSupported().then((isSupported) => {
if (isSupported) {
var want = {
abilityName: "FormAbility",
abilityName: 'FormAbility',
parameters: {
"ohos.extra.param.key.form_dimension": 2,
"ohos.extra.param.key.form_name": "widget",
"ohos.extra.param.key.module_name": "entry"
'ohos.extra.param.key.form_dimension': 2,
'ohos.extra.param.key.form_name': 'widget',
'ohos.extra.param.key.module_name': 'entry'
}
};
try {
formProvider.requestPublishForm(want).then((data) => {
console.log('formProvider requestPublishForm success, form ID is :' + JSON.stringify(data));
console.log('formProvider requestPublishForm success, form ID is : ${JSON.stringify(data)}');
}).catch((error) => {
console.log(`promise error, code: ${error.code}, message: ${error.message})`);
});
......
# @ohos.application.abilityDelegatorRegistry (AbilityDelegatorRegistry)
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**
>
......@@ -43,7 +43,7 @@ Obtains the **AbilityDelegator** object of the application.
**Example**
```ts
var abilityDelegator;
let abilityDelegator;
abilityDelegator = AbilityDelegatorRegistry.getAbilityDelegator();
```
......@@ -65,8 +65,8 @@ Obtains the **AbilityDelegatorArgs** object of the application.
**Example**
```ts
var args = AbilityDelegatorRegistry.getArguments();
console.info("getArguments bundleName:" + args.bundleName);
console.info("getArguments testCaseNames:" + args.testCaseNames);
console.info("getArguments testRunnerClassName:" + args.testRunnerClassName);
let args = AbilityDelegatorRegistry.getArguments();
console.info('getArguments bundleName: ${args.bundleName}');
console.info('getArguments testCaseNames: ${args.testCaseNames}');
console.info('getArguments testRunnerClassName: ${args.testRunnerClassName}');
```
......@@ -49,13 +49,13 @@ Updates the configuration. This API uses an asynchronous callback to return the
**Example**
```ts
var config = {
let config = {
language: 'chinese'
}
};
abilityManager.updateConfiguration(config, () => {
console.log('------------ updateConfiguration -----------');
})
});
```
## updateConfiguration
......@@ -83,15 +83,15 @@ Updates the configuration. This API uses a promise to return the result.
**Example**
```ts
var config = {
let config = {
language: 'chinese'
}
};
abilityManager.updateConfiguration(config).then(() => {
console.log('updateConfiguration success');
}).catch((err) => {
console.log('updateConfiguration fail');
})
});
```
## getAbilityRunningInfos
......@@ -114,7 +114,7 @@ Obtains the ability running information. This API uses an asynchronous callback
```ts
abilityManager.getAbilityRunningInfos((err,data) => {
console.log("getAbilityRunningInfos err: " + err + " data: " + JSON.stringify(data));
console.log('getAbilityRunningInfos err: ${err}, data: ${JSON.stringify(data)}');
});
```
......@@ -138,115 +138,8 @@ Obtains the ability running information. This API uses a promise to return the r
```ts
abilityManager.getAbilityRunningInfos().then((data) => {
console.log("getAbilityRunningInfos data: " + JSON.stringify(data))
console.log('getAbilityRunningInfos data: ${JSON.stringify(data)}');
}).catch((err) => {
console.log("getAbilityRunningInfos err: " + err)
console.log('getAbilityRunningInfos err: ${JSON.stringify(err)}');
});
```
## getExtensionRunningInfos<sup>9+</sup>
getExtensionRunningInfos(upperLimit: number, callback: AsyncCallback\<Array\<ExtensionRunningInfo>>): void
Obtains the extension running information. This API uses an asynchronous callback to return the result.
**Required permissions**: ohos.permission.GET_RUNNING_INFO
**System capability**: SystemCapability.Ability.AbilityRuntime.Core
**Parameters**
| Name | Type | Mandatory | Description |
| --------- | ---------------------------------------- | ---- | -------------- |
| upperLimit | number | Yes| Maximum number of messages that can be obtained.|
| callback | AsyncCallback\<Array\<[ExtensionRunningInfo](js-apis-inner-application-extensionRunningInfo.md)>> | Yes | Callback used to return the result. |
**Example**
```ts
var upperLimit = 0;
abilityManager.getExtensionRunningInfos(upperLimit, (err,data) => {
console.log("getExtensionRunningInfos err: " + err + " data: " + JSON.stringify(data));
});
```
## getExtensionRunningInfos<sup>9+</sup>
getExtensionRunningInfos(upperLimit: number): Promise\<Array\<ExtensionRunningInfo>>
Obtains the extension running information. This API uses a promise to return the result.
**Required permissions**: ohos.permission.GET_RUNNING_INFO
**System capability**: SystemCapability.Ability.AbilityRuntime.Core
**Parameters**
| Name | Type | Mandatory | Description |
| --------- | ---------------------------------------- | ---- | -------------- |
| upperLimit | number | Yes| Maximum number of messages that can be obtained.|
**Return value**
| Type | Description |
| ---------------------------------------- | ------- |
| Promise\<Array\<[ExtensionRunningInfo](js-apis-inner-application-extensionRunningInfo.md)>> | Promise used to return the result.|
**Example**
```ts
var upperLimit = 0;
abilityManager.getExtensionRunningInfos(upperLimit).then((data) => {
console.log("getAbilityRunningInfos data: " + JSON.stringify(data));
}).catch((err) => {
console.log("getAbilityRunningInfos err: " + err);
})
```
## getTopAbility<sup>9+</sup>
getTopAbility(callback: AsyncCallback\<ElementName>): void;
Obtains the top ability, which is the ability that has the window focus. This API uses an asynchronous callback to return the result.
**System capability**: SystemCapability.Ability.AbilityRuntime.Core
**Parameters**
| Name | Type | Mandatory | Description |
| --------- | ---------------------------------------- | ---- | -------------- |
| callback | AsyncCallback\<[ElementName](js-apis-bundleManager-elementName.md)> | Yes | Callback used to return the result. |
**Example**
```ts
abilityManager.getTopAbility((err,data) => {
console.log("getTopAbility err: " + err + " data: " + JSON.stringify(data));
});
```
## getTopAbility<sup>9+</sup>
getTopAbility(): Promise\<ElementName>;
Obtains the top ability, which is the ability that has the window focus. This API uses a promise to return the result.
**System capability**: SystemCapability.Ability.AbilityRuntime.Core
**Return value**
| Type | Description |
| ---------------------------------------- | ------- |
| Promise\<[ElementName](js-apis-bundleManager-elementName.md)>| Promise used to return the result.|
**Example**
```ts
abilityManager.getTopAbility().then((data) => {
console.log("getTopAbility data: " + JSON.stringify(data));
}).catch((err) => {
console.log("getTopAbility err: " + err);
})
```
......@@ -22,9 +22,9 @@ Checks whether this application is undergoing a stability test. This API uses an
**Parameters**
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| callback | AsyncCallback&lt;boolean&gt; | Yes| Callback used to return the result. If the application is undergoing a stability test, **true** will be returned; otherwise, **false** will be returned.|
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| callback | AsyncCallback&lt;boolean&gt; | 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**
......@@ -32,7 +32,7 @@ Checks whether this application is undergoing a stability test. This API uses an
appManager.isRunningInStabilityTest((err, flag) => {
console.log('error: ${JSON.stringify(err)}');
console.log('The result of isRunningInStabilityTest is: ${JSON.stringify(flag)}');
})
});
```
......@@ -46,9 +46,9 @@ Checks whether this application is undergoing a stability test. This API uses a
**Return value**
| Type| Description|
| -------- | -------- |
| Promise&lt;boolean&gt; | Promise used to return the result. If the application is undergoing a stability test, **true** will be returned; otherwise, **false** will be returned.|
| Type| Description|
| -------- | -------- |
| Promise&lt;boolean&gt; | Promise used to return the result. If the application is undergoing a stability test, **true** will be returned; otherwise, **false** will be returned.|
**Example**
......@@ -71,9 +71,9 @@ Checks whether this application is running on a RAM constrained device. This API
**Return value**
| Type| Description|
| -------- | -------- |
| Promise&lt;boolean&gt; | 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.|
| Type| Description|
| -------- | -------- |
| Promise&lt;boolean&gt; | 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**
......@@ -95,9 +95,9 @@ Checks whether this application is running on a RAM constrained device. This API
**Parameters**
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| callback | AsyncCallback&lt;boolean&gt; | 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.|
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| callback | AsyncCallback&lt;boolean&gt; | 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**
......@@ -105,7 +105,7 @@ Checks whether this application is running on a RAM constrained device. This API
appManager.isRamConstrainedDevice((err, data) => {
console.log('error: ${JSON.stringify(err)}');
console.log('The result of isRamConstrainedDevice is: ${JSON.stringify(data)}');
})
});
```
## appManager.getAppMemorySize
......@@ -118,9 +118,9 @@ Obtains the memory size of this application. This API uses a promise to return t
**Return value**
| Type| Description|
| -------- | -------- |
| Promise&lt;number&gt; | Promise used to return the memory size, in MB.|
| Type| Description|
| -------- | -------- |
| Promise&lt;number&gt; | Promise used to return the memory size, in MB.|
**Example**
......@@ -142,9 +142,9 @@ Obtains the memory size of this application. This API uses an asynchronous callb
**Parameters**
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| callback | AsyncCallback&lt;number&gt; | Yes| Callback used to return the memory size, in MB.|
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| callback | AsyncCallback&lt;number&gt; | Yes| Callback used to return the memory size, in MB.|
**Example**
......
# @ohos.application.Configuration (Configuration)
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**
> 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.
## Modules to Import
```ts
import Configuration from '@ohos.application.Configuration'
```
**System capability**: SystemCapability.Ability.AbilityBase
| Name| Type| Readable| Writable| Description|
| -------- | -------- | -------- | -------- | -------- |
| language<sup>8+</sup> | string | Yes| Yes| Language of the application, for example, **zh**.|
| 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.
**Example**
```ts
import hilog from '@ohos.hilog';
import UIAbility from '@ohos.app.ability.UIAbility';
import Window from '@ohos.window';
......@@ -41,13 +30,9 @@ export default class EntryAbility extends UIAbility {
onWindowStageCreate(windowStage: Window.WindowStage) {
let envCallback = {
onConfigurationUpdated(config) {
console.info(`envCallback onConfigurationUpdated success: ${JSON.stringify(config)}`)
console.info(`envCallback onConfigurationUpdated success: ${JSON.stringify(config)}`);
let language = config.language;
let colorMode = config.colorMode;
let direction = config.direction;
let screenDensity = config.screenDensity;
let displayId = config.displayId;
let hasPointerDevice = config.hasPointerDevice;
}
};
......@@ -56,12 +41,10 @@ export default class EntryAbility extends UIAbility {
windowStage.loadContent('pages/index', (err, data) => {
if (err.code) {
hilog.isLoggable(0x0000, 'testTag', hilog.LogLevel.ERROR);
hilog.error(0x0000, 'testTag', 'Failed to load the content. Cause: %{public}s', JSON.stringify(err) ?? '');
console.error('failed to load the content, error: + ${JSON.stringify(err)}');
return;
}
hilog.isLoggable(0x0000, 'testTag', hilog.LogLevel.INFO);
hilog.info(0x0000, 'testTag', 'Succeeded in loading the content. Data: %{public}s', JSON.stringify(data) ?? '');
console.info('Succeeded in loading the content, data: + ${JSON.stringify(data)}');
});
}
}
......
......@@ -23,33 +23,3 @@ You can obtain the value of this constant by calling the **ConfigurationConstant
| COLOR_MODE_NOT_SET | -1 | Unspecified color mode.|
| COLOR_MODE_DARK | 0 | Dark mode.|
| COLOR_MODE_LIGHT | 1 | Light mode.|
## ConfigurationConstant.Direction<sup>9+</sup>
You can obtain the value of this constant by calling the **ConfigurationConstant.Direction** API.
**System capability**: SystemCapability.Ability.AbilityBase
| Name| Value| Description|
| -------- | -------- | -------- |
| DIRECTION_NOT_SET | -1 | Unspecified direction.|
| DIRECTION_VERTICAL | 0 | Vertical direction.|
| DIRECTION_HORIZONTAL | 1 | Horizontal direction.|
## ConfigurationConstant.ScreenDensity<sup>9+</sup>
You can obtain the value of this constant by calling the **ConfigurationConstant.ScreenDensity** API.
**System capability**: SystemCapability.Ability.AbilityBase
| Name| Value| Description|
| -------- | -------- | -------- |
| SCREEN_DENSITY_NOT_SET | 0 | Unspecified screen resolution.|
| SCREEN_DENSITY_SDPI | 120 | The screen resolution is sdpi.|
| SCREEN_DENSITY_MDPI | 160 | The screen resolution is mdpi.|
| SCREEN_DENSITY_LDPI | 240 | The screen resolution is ldpi.|
| SCREEN_DENSITY_XLDPI | 320 | The screen resolution is xldpi.|
| SCREEN_DENSITY_XXLDPI | 480 | The screen resolution is xxldpi.|
| SCREEN_DENSITY_XXXLDPI | 640 | The screen resolution is xxxldpi.|
......@@ -11,7 +11,7 @@ The **EnvironmentCallback** module provides APIs, such as **onConfigurationUpdat
## Modules to Import
```ts
import EnvironmentCallback from "@ohos.application.EnvironmentCallback";
import EnvironmentCallback from '@ohos.application.EnvironmentCallback';
```
......@@ -41,37 +41,37 @@ Called when the system memory level changes.
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| level | [MemoryLevel](js-apis-application-abilityConstant.md#abilityconstantmemorylevel) | Yes| New memory level.|
| level | [MemoryLevel](js-apis-app-ability-abilityConstant.md#abilityconstantmemorylevel) | Yes| New memory level.|
**Example**
```ts
import UIAbility from '@ohos.app.ability.UIAbility';
var callbackId;
let callbackId;
export default class EntryAbility extends UIAbility {
onCreate() {
console.log("MyAbility onCreate")
console.log('MyAbility onCreate');
globalThis.applicationContext = this.context.getApplicationContext();
let EnvironmentCallback = {
onConfigurationUpdated(config){
console.log("onConfigurationUpdated config:" + JSON.stringify(config));
console.log('onConfigurationUpdated config: ${JSON.stringify(config)}');
},
onMemoryLevel(level){
console.log("onMemoryLevel level:" + level);
console.log('onMemoryLevel level: ${level}');
}
}
};
// 1. Obtain an applicationContext object.
let applicationContext = globalThis.applicationContext;
// 2. Register a listener for the environment changes through the applicationContext object.
callbackId = applicationContext.registerEnvironmentCallback(EnvironmentCallback);
console.log("registerEnvironmentCallback number: " + JSON.stringify(callbackId));
console.log('registerEnvironmentCallback number: ${JSON.stringify(callbackId)}');
}
onDestroy() {
let applicationContext = globalThis.applicationContext;
applicationContext.unregisterEnvironmentCallback(callbackId, (error, data) => {
console.log("unregisterEnvironmentCallback success, err: " + JSON.stringify(error));
console.log('unregisterEnvironmentCallback success, err: ${JSON.stringify(error)}');
});
}
}
......
......@@ -35,7 +35,7 @@ Creates a **FormBindingData** object.
| Name| Type | Mandatory| Description |
| ------ | -------------- | ---- | ------------------------------------------------------------ |
| 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**
......@@ -52,13 +52,13 @@ import formBindingData from '@ohos.application.formBindingData';
import fs from '@ohos.file.fs';
try {
let fd = fs.openSync('/path/to/form.png')
let fd = fs.openSync('/path/to/form.png');
let obj = {
"temperature": "21°",
"formImages": { "image": fd }
'temperature': '21°',
'formImages': { 'image': fd }
};
formBindingData.createFormBindingData(obj);
} catch (error.code) {
console.log('catch error, error:' + JSON.stringify(error));
} catch (error) {
console.log('catch error, error: ${JSON.stringify(error)}');
}
```
......@@ -49,7 +49,6 @@ Enumerates the widget types.
| Name | Value | Description |
| ----------- | ---- | ------------ |
| JS | 1 | JS widget. |
| eTS<sup>9+<sup> | 2 | eTS widget.|
## ColorMode
......@@ -94,48 +93,10 @@ Enumerates the widget parameters.
| Name | Value | Description |
| ----------- | ---- | ------------ |
| IDENTITY_KEY<sup>9+</sup> | "ohos.extra.param.key.form_identity" | Widget ID.<br>**System API**: This is a system API. |
| DIMENSION_KEY | "ohos.extra.param.key.form_dimension" | Widget dimension. |
| NAME_KEY | "ohos.extra.param.key.form_name" | Widget name. |
| MODULE_NAME_KEY | "ohos.extra.param.key.module_name" | Name of the module to which the widget belongs. |
| WIDTH_KEY | "ohos.extra.param.key.form_width" | Widget width. |
| HEIGHT_KEY | "ohos.extra.param.key.form_height" | Widget height. |
| TEMPORARY_KEY | "ohos.extra.param.key.form_temporary" | Temporary widget. |
| ABILITY_NAME_KEY<sup>9+</sup> | "ohos.extra.param.key.ability_name" | Ability name. |
| DEVICE_ID_KEY<sup>9+</sup> | "ohos.extra.param.key.device_id" | Device ID. |
| BUNDLE_NAME_KEY<sup>9+</sup> | "ohos.extra.param.key.bundle_name" | Key that specifies the target bundle name.|
## FormDimension<sup>9+</sup>
Enumerates the widget dimensions.
**System capability**: SystemCapability.Ability.Form
| Name | Value | Description |
| ----------- | ---- | ------------ |
| Dimension_1_2 <sup>9+</sup> | 1 | 1 x 2. |
| Dimension_2_2 <sup>9+</sup> | 2 | 2 x 2. |
| Dimension_2_4 <sup>9+</sup> | 3 | 2 x 4. |
| Dimension_4_4 <sup>9+</sup> | 4 | 4 x 4. |
| Dimension_2_1 <sup>9+</sup> | 5 | 2 x 1. |
## FormInfoFilter<sup>9+</sup>
Defines the widget information filter. Only the widget information that meets the filter is returned.
**System capability**: SystemCapability.Ability.Form
| Name | Description |
| ----------- | ------------ |
| moduleName<sup>9+</sup> | Optional. Only the information about the widget whose **moduleName** is the same as the provided value is returned.<br>If this parameter is not set, **moduleName** is not used for filtering.|
## VisibilityType<sup>9+</sup>
Enumerates the visibility types of the widget.
**System capability**: SystemCapability.Ability.Form
| Name | Value | Description |
| ----------- | ---- | ------------ |
| FORM_VISIBLE<sup>9+<sup> | 1 | The widget is visible.|
| FORM_INVISIBLE<sup>9+<sup> | 2 | The widget is invisible.|
| IDENTITY_KEY | 'ohos.extra.param.key.form_identity' | Widget ID.<br>**System API**: This is a system API. |
| DIMENSION_KEY | 'ohos.extra.param.key.form_dimension' | Widget dimension. |
| NAME_KEY | 'ohos.extra.param.key.form_name' | Widget name. |
| MODULE_NAME_KEY | 'ohos.extra.param.key.module_name' | Name of the module to which the widget belongs. |
| WIDTH_KEY | 'ohos.extra.param.key.form_width' | Widget width. |
| HEIGHT_KEY | 'ohos.extra.param.key.form_height' | Widget height. |
| TEMPORARY_KEY | 'ohos.extra.param.key.form_temporary' | Temporary widget. |
......@@ -10,7 +10,7 @@ The **StaticSubscriberExtensionAbility** module provides Extension abilities for
## Modules to Import
```ts
import StaticSubscriberExtensionAbility from '@ohos.application.StaticSubscriberExtensionAbility'
import StaticSubscriberExtensionAbility from '@ohos.application.StaticSubscriberExtensionAbility';
```
## StaticSubscriberExtensionAbility.onReceiveEvent
......@@ -32,12 +32,9 @@ Callback of the common event of a static subscriber.
**Example**
```ts
var StaticSubscriberExtensionAbility = requireNapi("application.StaticSubscriberExtensionAbility")
{
onReceiveEvent(event){
console.log('onReceiveEvent,event:' + event.code);
}
}
export default MyStaticSubscriberExtensionAbility
class MyStaticSubscriberExtensionAbility extends StaticSubscriberExtensionAbility {
onReceiveEvent(event) {
console.log('onReceiveEvent, event: ${JSON.stringify(event)}');
}
}
```
......@@ -11,7 +11,7 @@ To implement your own unit test framework, extend this class and override its AP
## Modules to Import
```ts
import TestRunner from '@ohos.application.testRunner'
import TestRunner from '@ohos.application.testRunner';
```
## TestRunner.onPrepare
......@@ -27,7 +27,7 @@ Prepares the unit test environment to run test cases.
```ts
export default class UserTestRunner implements TestRunner {
onPrepare() {
console.log("Trigger onPrepare")
console.log('Trigger onPrepare');
}
onRun() {}
};
......@@ -49,7 +49,7 @@ Runs test cases.
export default class UserTestRunner implements TestRunner {
onPrepare() {}
onRun() {
console.log("Trigger onRun")
console.log('Trigger onRun');
}
};
```
......@@ -4,7 +4,7 @@ Want is a carrier for information transfer between objects (application componen
> **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
......@@ -22,10 +22,10 @@ import Want from '@ohos.application.Want';
| bundleName | string | No | Bundle name.|
| 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**.|
| 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).|
| 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). |
| 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). |
| moduleName<sup>9+</sup> | string | No | Module to which the ability belongs.|
......@@ -35,15 +35,15 @@ import Want from '@ohos.application.Want';
```ts
let want = {
"deviceId": "", // An empty deviceId indicates the local device.
"bundleName": "com.example.myapplication",
"abilityName": "EntryAbility",
"moduleName": "entry" // moduleName is optional.
'deviceId': '', // An empty deviceId indicates the local device.
'bundleName': 'com.example.myapplication',
'abilityName': 'EntryAbility',
'moduleName': 'entry' // moduleName is optional.
};
this.context.startAbility(want, (error) => {
// 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):
......@@ -51,84 +51,84 @@ import Want from '@ohos.application.Want';
* String
```ts
let want = {
bundleName: "com.example.myapplication",
abilityName: "EntryAbility",
bundleName: 'com.example.myapplication',
abilityName: 'EntryAbility',
parameters: {
keyForString: "str",
keyForString: 'str',
},
}
};
```
* Number
```ts
let want = {
bundleName: "com.example.myapplication",
abilityName: "EntryAbility",
bundleName: 'com.example.myapplication',
abilityName: 'EntryAbility',
parameters: {
keyForInt: 100,
keyForDouble: 99.99,
},
}
};
```
* Boolean
```ts
let want = {
bundleName: "com.example.myapplication",
abilityName: "EntryAbility",
bundleName: 'com.example.myapplication',
abilityName: 'EntryAbility',
parameters: {
keyForBool: true,
},
}
};
```
* Object
```ts
let want = {
bundleName: "com.example.myapplication",
abilityName: "EntryAbility",
bundleName: 'com.example.myapplication',
abilityName: 'EntryAbility',
parameters: {
keyForObject: {
keyForObjectString: "str",
keyForObjectString: 'str',
keyForObjectInt: -200,
keyForObjectDouble: 35.5,
keyForObjectBool: false,
},
},
}
};
```
* Array
```ts
let want = {
bundleName: "com.example.myapplication",
abilityName: "EntryAbility",
bundleName: 'com.example.myapplication',
abilityName: 'EntryAbility',
parameters: {
keyForArrayString: ["str1", "str2", "str3"],
keyForArrayString: ['str1', 'str2', 'str3'],
keyForArrayInt: [100, 200, 300, 400],
keyForArrayDouble: [0.1, 0.2],
keyForArrayObject: [{obj1: "aaa"}, {obj2: 100}],
keyForArrayObject: [{obj1: 'aaa'}, {obj2: 100}],
},
}
};
```
* File descriptor (FD)
```ts
import fileio from '@ohos.fileio';
let fd;
try {
fd = fileio.openSync("/data/storage/el2/base/haps/pic.png");
fd = fileio.openSync('/data/storage/el2/base/haps/pic.png');
} catch(e) {
console.log("openSync fail:" + JSON.stringify(e));
console.log('openSync fail: ${JSON.stringify(e)}');
}
let want = {
"deviceId": "", // An empty deviceId indicates the local device.
"bundleName": "com.example.myapplication",
"abilityName": "EntryAbility",
"moduleName": "entry", // moduleName is optional.
"parameters": {
"keyFd":{"type":"FD", "value":fd}
'deviceId': '', // An empty deviceId indicates the local device.
'bundleName': 'com.example.myapplication',
'abilityName': 'EntryAbility',
'moduleName': 'entry', // moduleName is optional.
'parameters': {
'keyFd':{'type':'FD', 'value':fd}
}
};
this.context.startAbility(want, (error) => {
// 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}');
});
```
- For more details and examples, see [Want](../../application-models/want-overview.md).
......
......@@ -5,7 +5,7 @@
> **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.
......@@ -22,7 +22,7 @@ import WindowExtensionAbility from '@ohos.application.WindowExtensionAbility';
| Name | Type| Readable| Writable| Description |
| --------- | -------- | ---- | ---- | ------------------------- |
| context | [ExtensionContext](js-apis-inner-application-extensionContext.md) | Yes | No | Context of an Extension ability. |
| context | [WindowExtensionContext](js-apis-inner-application-windowExtensionContext.md) | Yes | No | Context of an Extension ability. |
## WindowExtensionAbility.onConnect
......@@ -44,7 +44,7 @@ Called when this Window Extension ability is connected to an ability for the fir
export default class MyWindowExtensionAbility extends WindowExtensionAbility {
onConnect(want) {
console.info('WindowExtAbility onConnect ' + want.abilityName);
console.info('WindowExtAbility onConnect, abilityName: ${want.abilityName}');
}
}
......@@ -71,7 +71,7 @@ Called when this Window Extension ability is disconnected from all connected abi
export default class MyWindowExtensionAbility extends WindowExtensionAbility {
onDisconnect(want) {
console.info('WindowExtAbility onDisconnect ' + want.abilityName);
console.info('WindowExtAbility onDisconnect, abilityName: ${want.abilityName}');
}
}
......@@ -100,10 +100,10 @@ export default class MyWindowExtensionAbility extends WindowExtensionAbility {
onWindowReady(window) {
window.loadContent('WindowExtAbility/pages/index1').then(() => {
window.getProperties().then((pro) => {
console.log('WindowExtension ' + JSON.stringify(pro));
})
console.log('WindowExtension pro: ${JSON.stringify(pro)}');
});
window.show();
})
});
}
}
......
......@@ -9,3 +9,26 @@
| onConnect<sup>7+</sup> | function | Yes | Callback invoked when a connection is set up. |
| onDisconnect<sup>7+</sup> | function | Yes | Callback invoked when a connection is interrupted. |
| onFailed<sup>7+</sup> | function | Yes | Callback invoked when a connection fails.|
**Example**
```ts
let want = {
bundleName: 'com.example.myapp',
abilityName: 'MyAbility'
};
let connectOptions = {
onConnect(elementName, remote) {
console.log('onConnect elementName: ${elementName}');
},
onDisconnect(elementName) {
console.log('onDisconnect elementName: ${elementName}');
},
onFailed(code) {
console.error('onFailed code: ${code}');
}
};
let connection = this.context.connectAbility(want, connectOptions);
```
......@@ -11,7 +11,7 @@ The **DataAbilityOperation** module defines the operation on DataAbilities. It c
| Name | Template | Mandatory| Description |
| -------- | -------- | --------| -------- |
| 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'. |
| type | featureAbility.DataAbilityOperationType | Yes | Operation type. |
| valuesBucket? | rdb.ValuesBucket | No | Data value to set. |
| valueBackReferences? | rdb.ValuesBucket | No | **ValuesBucket** object that contains a set of key-value pairs. |
......
......@@ -16,31 +16,31 @@ The **StartAbilityParameter** module defines the parameters for starting an abil
**Example**
```ts
import featureAbility from '@ohos.ability.featureAbility'
import featureAbility from '@ohos.ability.featureAbility';
let Want = {
bundleName: "com.example.abilityStartSettingApp2",
abilityName: "com.example.abilityStartSettingApp.EntryAbility",
}
bundleName: 'com.example.abilityStartSettingApp2',
abilityName: 'com.example.abilityStartSettingApp.EntryAbility',
};
let abilityStartSetting ={
[featureAbility.AbilityStartSetting.BOUNDS_KEY] : [100,200,300,400],
[featureAbility.AbilityStartSetting.WINDOW_MODE_KEY] :
featureAbility.AbilityWindowConfiguration.WINDOW_MODE_UNDEFINED,
[featureAbility.AbilityStartSetting.DISPLAY_ID_KEY] : 1,
}
};
let startAbilityParameter = {
want : Want,
abilityStartSetting : abilityStartSetting
}
};
try {
featureAbility.startAbility(startAbilityParameter, (err, data) => {
console.log('errCode : ' + JSON.stringify(err));
console.log('data : ' + JSON.stringify(data));
console.log('errCode : ${JSON.stringify(err)}');
console.log('data : ${JSON.stringify(data)}');
});
} catch(error) {
console.log("startAbility error: " + JSON.stringify(error));
console.log('startAbility error: ${JSON.stringify(error)}');
}
```
......@@ -28,5 +28,5 @@ Describes the ability delegator arguments.
```ts
import AbilityDelegatorRegistry from '@ohos.app.ability.abilityDelegatorRegistry';
var args = AbilityDelegatorRegistry.getArguments();
let args = AbilityDelegatorRegistry.getArguments();
```
......@@ -22,7 +22,7 @@ import UIAbility from '@ohos.app.ability.UIAbility';
class EntryAbility extends UIAbility {
onCreate(want, launchParam) {
// EntryAbility onCreate, isStageMode: true
console.log("EntryAbility onCreate, isStageMode: " + this.context.stageMode);
console.log('EntryAbility onCreate, isStageMode: ${this.context.stageMode}');
}
}
```
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册