提交 2bfb0cc3 编写于 作者: M mingxihua

mingxihua@huawei.com.cn

Signed-off-by: Nmingxihua <mingxihua@huawei.com>
上级 7e9154af
......@@ -63,7 +63,7 @@ const config = {
language: 'Zh-Hans', // 简体中文
colorMode: COLOR_MODE_LIGHT, // 浅色模式
direction: DIRECTION_VERTICAL, // 垂直方向
screenDensity: SCREEN_DENSITY_SDPI, // 屏幕分辨率为'sdpi'
screenDensity: SCREEN_DENSITY_SDPI, // 屏幕像素密度为'sdpi'
displayId: 1, // 应用在Id为1的物理屏上显示
hasPointerDevice: true, // 指针类型设备已连接
};
......@@ -121,7 +121,7 @@ const config = {
language: 'Zh-Hans', // 简体中文
colorMode: COLOR_MODE_LIGHT, // 浅色模式
direction: DIRECTION_VERTICAL, // 垂直方向
screenDensity: SCREEN_DENSITY_SDPI, // 屏幕分辨率为'sdpi'
screenDensity: SCREEN_DENSITY_SDPI, // 屏幕像素密度为'sdpi'
displayId: 1, // 应用在Id为1的物理屏上显示
hasPointerDevice: true, // 指针类型设备已连接
};
......@@ -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));
......@@ -310,7 +310,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));
......@@ -384,5 +384,5 @@ abilityManager.getTopAbility().then((data) => {
console.log('getTopAbility success, data: ' + JSON.stringify(data));
}).catch((err) => {
console.log('getTopAbility fail, err: ' + JSON.stringify(err));
})
});
```
\ No newline at end of file
......@@ -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.getProcessRunningInformation
......@@ -299,7 +299,7 @@ appManager.getProcessRunningInformation((err, data) => {
} else {
console.log('The process running information is:' + JSON.stringify(data));
}
})
});
```
## appManager.on
......@@ -356,7 +356,7 @@ let applicationStateObserver = {
onProcessStateChanged(processData) {
console.log(`[appManager] onProcessStateChanged: ${JSON.stringify(processData)}`);
}
}
};
try {
const observerId = appManager.on('applicationState', applicationStateObserver);
console.log(`[appManager] observerCode: ${observerId}`);
......@@ -420,7 +420,7 @@ let applicationStateObserver = {
onProcessStateChanged(processData) {
console.log(`[appManager] onProcessStateChanged: ${JSON.stringify(processData)}`);
}
}
};
let bundleNameList = ['bundleName1', 'bundleName2'];
try {
const observerId = appManager.on('applicationState', applicationStateObserver, bundleNameList);
......@@ -482,7 +482,7 @@ let applicationStateObserver = {
onProcessStateChanged(processData) {
console.log(`[appManager] onProcessStateChanged: ${JSON.stringify(processData)}`);
}
}
};
let bundleNameList = ['bundleName1', 'bundleName2'];
try {
observerId = appManager.on('applicationState', applicationStateObserver, bundleNameList);
......@@ -563,7 +563,7 @@ let applicationStateObserver = {
onProcessStateChanged(processData) {
console.log(`[appManager] onProcessStateChanged: ${JSON.stringify(processData)}`);
}
}
};
let bundleNameList = ['bundleName1', 'bundleName2'];
try {
observerId = appManager.on('applicationState', applicationStateObserver, bundleNameList);
......@@ -578,7 +578,7 @@ try {
console.log('unregisterApplicationStateObserver success, data: ' + JSON.stringify(data));
}).catch((err) => {
console.log('unregisterApplicationStateObserver faile, err: ' + JSON.stringify(err));
})
});
} catch (paramError) {
console.log('error: ' + paramError.code + ', ' + paramError.message);
}
......@@ -664,7 +664,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
......@@ -706,7 +706,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);
}
......@@ -848,7 +848,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);
}
......@@ -944,7 +944,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);
}
......
......@@ -13,7 +13,7 @@
| language | string | 是 | 是 | 表示应用程序的当前语言。例如:zh。 |
| colorMode | [ColorMode](js-apis-app-ability-configurationConstant.md#configurationconstantcolormode) | 是 | 是 | 表示深浅色模式,取值范围:未设置(COLOR_MODE_NOT_SET),浅色模式(COLOR_MODE_LIGHT),深色模式(COLOR_MODE_DARK)。默认为浅色。 |
| direction | [Direction](js-apis-app-ability-configurationConstant.md#configurationconstantdirection) | 是 | 否 | 表示屏幕方向,取值范围:未设置(DIRECTION_NOT_SET),水平方向(DIRECTION_HORIZONTAL),垂直方向(DIRECTION_VERTICAL)。 |
| screenDensity | [ScreenDensity](js-apis-app-ability-configurationConstant.md#configurationconstantscreendensity) | 是 | 否 | 表示屏幕分辨率,取值范围:未设置(SCREEN_DENSITY_NOT_SET),SCREEN_DENSITY_SDPI(120)、SCREEN_DENSITY_MDPI(160)、SCREEN_DENSITY_LDPI(240)、SCREEN_DENSITY_XLDPI(320)、SCREEN_DENSITY_XXLDPI(480)、SCREEN_DENSITY_XXXLDPI(640)。 |
| screenDensity | [ScreenDensity](js-apis-app-ability-configurationConstant.md#configurationconstantscreendensity) | 是 | 否 | 表示屏幕像素密度,取值范围:未设置(SCREEN_DENSITY_NOT_SET),SCREEN_DENSITY_SDPI(120)、SCREEN_DENSITY_MDPI(160)、SCREEN_DENSITY_LDPI(240)、SCREEN_DENSITY_XLDPI(320)、SCREEN_DENSITY_XXLDPI(480)、SCREEN_DENSITY_XXXLDPI(640)。 |
| displayId | number | 是 | 否 | 表示应用所在的物理屏幕Id。 |
| hasPointerDevice | boolean | 是 | 否 | 指示指针类型设备是否已连接,如键鼠、触控板等。 |
......@@ -28,7 +28,7 @@
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;
......
......@@ -46,10 +46,10 @@ import ConfigurationConstant from '@ohos.app.ability.ConfigurationConstant';
| 名称 | 值 | 说明 |
| -------- | -------- | -------- |
| SCREEN_DENSITY_NOT_SET | 0 | 未设置屏幕分辨率。 |
| SCREEN_DENSITY_SDPI | 120 | 屏幕分辨率为'sdpi'。 |
| SCREEN_DENSITY_MDPI | 160 | 屏幕分辨率为'mdpi'。 |
| SCREEN_DENSITY_LDPI | 240 | 屏幕分辨率为'ldpi'。 |
| SCREEN_DENSITY_XLDPI | 320 | 屏幕分辨率为'xldpi'。 |
| SCREEN_DENSITY_XXLDPI | 480 | 屏幕分辨率为'xxldpi'。 |
| SCREEN_DENSITY_XXXLDPI | 640 | 屏幕分辨率为'xxxldpi'。 |
| SCREEN_DENSITY_NOT_SET | 0 | 未设置屏幕像素密度。 |
| SCREEN_DENSITY_SDPI | 120 | 屏幕像素密度为'sdpi'。 |
| SCREEN_DENSITY_MDPI | 160 | 屏幕像素密度为'mdpi'。 |
| SCREEN_DENSITY_LDPI | 240 | 屏幕像素密度为'ldpi'。 |
| SCREEN_DENSITY_XLDPI | 320 | 屏幕像素密度为'xldpi'。 |
| SCREEN_DENSITY_XXLDPI | 480 | 屏幕像素密度为'xxldpi'。 |
| SCREEN_DENSITY_XXXLDPI | 640 | 屏幕像素密度为'xxxldpi'。 |
......@@ -53,20 +53,20 @@ let callbackId;
export default class MyAbility extends Ability {
onCreate() {
console.log('MyAbility onCreate')
console.log('MyAbility onCreate');
globalThis.applicationContext = this.context.getApplicationContext();
let EnvironmentCallback = {
let environmentCallback = {
onConfigurationUpdated(config){
console.log('onConfigurationUpdated config:' + JSON.stringify(config));
},
onMemoryLevel(level){
console.log('onMemoryLevel level: ${JSON.stringify(level)}');
}
}
};
// 1.获取applicationContext
let applicationContext = globalThis.applicationContext;
// 2.通过applicationContext注册监听应用内生命周期
callbackId = applicationContext.registerEnvironmentCallback(EnvironmentCallback);
callbackId = applicationContext.registerEnvironmentCallback(environmentCallback);
console.log('registerEnvironmentCallback number: ' + JSON.stringify(callbackId));
}
onDestroy() {
......
......@@ -31,9 +31,9 @@ on(type: 'error', observer: ErrorObserver): number;
```js
let observer = {
onUnhandledException(errorMsg) {
console.log('onUnhandledException, errorMsg: ', errorMsg)
console.log('onUnhandledException, errorMsg: ', errorMsg);
}
}
};
try {
errorManager.on('error', observer);
} catch (paramError) {
......@@ -106,7 +106,7 @@ try {
})
.catch((err) => {
console.log('----------- unregisterErrorObserver fail ----------', err);
})
});
} catch (paramError) {
console.log('error: ' + paramError.code + ', ' + paramError.message);
}
......
......@@ -9,7 +9,7 @@ missionManager模块提供系统任务管理能力,包括对系统任务执行
## 导入模块
```ts
import missionManager from '@ohos.app.ability.missionManager'
import missionManager from '@ohos.app.ability.missionManager';
```
## 权限列表
......@@ -51,7 +51,7 @@ on(type:'mission', listener: MissionListener): number;
onMissionIconUpdated: function (mission, icon) {console.log('--------onMissionIconUpdated-------');},
onMissionClosed: function (mission) {console.log('--------onMissionClosed-------');}
};
console.log('registerMissionListener')
console.log('registerMissionListener');
try {
let listenerid = missionManager.on('mission', listener);
} catch (paramError) {
......@@ -90,13 +90,13 @@ off(type: 'mission', listenerId: number, callback: AsyncCallback&lt;void&gt;): v
onMissionIconUpdated: function (mission, icon) {console.log('--------onMissionIconUpdated-------');},
onMissionClosed: function (mission) {console.log('--------onMissionClosed-------');}
};
console.log('registerMissionListener')
console.log('registerMissionListener');
try {
let listenerid = missionManager.registerMissionListener(listener);
missionManager.unregisterMissionListener(listenerid, (error) => {
console.log('unregisterMissionListener');
})
});
} catch (paramError) {
console.log('error: ' + paramError.code + ', ' + paramError.message);
}
......@@ -138,7 +138,7 @@ off(type: 'mission', listenerId: number): Promise&lt;void&gt;;
onMissionIconUpdated: function (mission, icon) {console.log('--------onMissionIconUpdated-------');},
onMissionClosed: function (mission) {console.log('--------onMissionClosed-------');}
};
console.log('registerMissionListener')
console.log('registerMissionListener');
try {
let listenerid = missionManager.registerMissionListener(listener);
......@@ -174,7 +174,7 @@ getMissionInfo(deviceId: string, missionId: number, callback: AsyncCallback&lt;M
**示例:**
```ts
import missionManager from '@ohos.app.ability.missionManager'
import missionManager from '@ohos.app.ability.missionManager';
try {
let allMissions=missionManager.getMissionInfos('',10).catch(function(err){console.log(err);});
......@@ -221,7 +221,7 @@ getMissionInfo(deviceId: string, missionId: number): Promise&lt;MissionInfo&gt;;
**示例:**
```ts
import missionManager from '@ohos.app.ability.missionManager'
import missionManager from '@ohos.app.ability.missionManager';
try {
let mission = missionManager.getMissionInfo('', 10).catch(function (err){
......@@ -256,14 +256,14 @@ getMissionInfos(deviceId: string, numMax: number, callback: AsyncCallback&lt;Arr
**示例:**
```ts
import missionManager from '@ohos.app.ability.missionManager'
import missionManager from '@ohos.app.ability.missionManager';
try {
missionManager.getMissionInfos('', 10, (error, missions) => {
console.log('getMissionInfos is called, error.code = ' + error.code);
console.log('size = ' + missions.length);
console.log('missions = ' + JSON.stringify(missions));
})
});
} catch (paramError) {
console.log('error: ' + paramError.code + ', ' + paramError.message);
}
......@@ -298,7 +298,7 @@ getMissionInfos(deviceId: string, numMax: number): Promise&lt;Array&lt;MissionIn
**示例:**
```ts
import missionManager from '@ohos.app.ability.missionManager'
import missionManager from '@ohos.app.ability.missionManager';
try {
let allMissions = missionManager.getMissionInfos('', 10).catch(function (err){
......@@ -333,7 +333,7 @@ getMissionSnapShot(deviceId: string, missionId: number, callback: AsyncCallback&
**示例:**
```ts
import missionManager from '@ohos.app.ability.missionManager'
import missionManager from '@ohos.app.ability.missionManager';
try {
missionManager.getMissionInfos('', 10, (error, missions) => {
......@@ -345,8 +345,8 @@ getMissionSnapShot(deviceId: string, missionId: number, callback: AsyncCallback&
missionManager.getMissionSnapShot('', id, (error, snapshot) => {
console.log('getMissionSnapShot is called, error.code = ' + error.code);
console.log('bundleName = ' + snapshot.ability.bundleName);
})
})
});
});
} catch (paramError) {
console.log('error: ' + paramError.code + ', ' + paramError.message);
}
......@@ -435,8 +435,8 @@ getLowResolutionMissionSnapShot(deviceId: string, missionId: number, callback: A
missionManager.getLowResolutionMissionSnapShot('', id, (error, snapshot) => {
console.log('getLowResolutionMissionSnapShot is called, error.code = ' + error.code);
console.log('bundleName = ' + snapshot.ability.bundleName);
})
})
});
});
} catch (paramError) {
console.log('error: ' + paramError.code + ', ' + paramError.message);
}
......
......@@ -77,7 +77,7 @@ applyQuickFix(hapModuleQuickFixFiles: Array\<string>, callback: AsyncCallback\<v
} else {
console.info( 'applyQuickFix success');
}
})
});
} catch (paramError) {
console.log('error: ' + paramError.code + ', ' + paramError.message);
}
......@@ -118,7 +118,7 @@ applyQuickFix(hapModuleQuickFixFiles: Array\<string>): Promise\<void>;
console.info('applyQuickFix success');
}).catch((error) => {
console.info(`applyQuickFix err: + ${error}`);
})
});
} catch (paramError) {
console.log('error: ' + paramError.code + ', ' + paramError.message);
}
......@@ -149,14 +149,14 @@ getApplicationQuickFixInfo(bundleName: string, callback: AsyncCallback\<Applicat
import quickFixManager from '@ohos.app.ability.quickFixManager';
try {
let bundleName = 'bundleName'
let bundleName = 'bundleName';
quickFixManager.getApplicationQuickFixInfo(bundleName, (error, data) => {
if (error) {
console.info(`getApplicationQuickFixInfo error: + ${error}`);
} else {
console.info(`getApplicationQuickFixInfo success: + ${data}`);
}
})
});
} catch (paramError) {
console.log('error: ' + paramError.code + ', ' + paramError.message);
}
......@@ -197,7 +197,7 @@ getApplicationQuickFixInfo(bundleName: string): Promise\<ApplicationQuickFixInfo
console.info(`getApplicationQuickFixInfo success: + ${data}`);
}).catch((error) => {
console.info(`getApplicationQuickFixInfo err: + ${error}`);
})
});
} catch (paramError) {
console.log('error: ' + paramError.code + ', ' + paramError.message);
}
......
......@@ -34,7 +34,7 @@ import Want from '@ohos.app.ability.Want';
- 基础用法
```ts
var want = {
let want = {
'deviceId': '', // deviceId为空表示本设备
'bundleName': 'com.extreme.test',
'abilityName': 'MainAbility',
......@@ -43,7 +43,7 @@ import Want from '@ohos.app.ability.Want';
this.context.startAbility(want, (error) => {
// 显式拉起Ability,通过bundleName、abilityName和moduleName可以唯一确定一个Ability
console.log('error.code = ' + error.code);
})
});
```
- 通过自定字段传递数据, 以下为当前支持类型。
......@@ -110,13 +110,13 @@ import Want from '@ohos.app.ability.Want';
* 文件描述符(FD)
```ts
import fileio from '@ohos.fileio';
var fd;
let fd;
try {
fd = fileio.openSync('/data/storage/el2/base/haps/pic.png');
} catch(e) {
console.log('openSync fail:' + JSON.stringify(e));
}
var want = {
let want = {
'deviceId': '', // deviceId为空表示本设备
'bundleName': 'com.extreme.test',
'abilityName': 'MainAbility',
......
......@@ -37,7 +37,7 @@ function getWantAgentCallback(err, data) {
console.info('==========================>getWantAgentCallback=======================>');
}
//WantAgentInfo对象
var wantAgentInfo = {
let wantAgentInfo = {
wants: [
{
deviceId: 'deviceId',
......@@ -62,7 +62,7 @@ var wantAgentInfo = {
operationType: WantAgent.OperationType.START_ABILITIES,
requestCode: 0,
wantAgentFlags:[WantAgent.WantAgentFlags.UPDATE_PRESENT_FLAG]
}
};
try {
WantAgent.getWantAgent(wantAgentInfo, getWantAgentCallback);
......@@ -100,7 +100,7 @@ import WantAgent from '@ohos.app.ability.wantAgent';
//WantAgentInfo对象
var wantAgentInfo = {
let wantAgentInfo = {
wants: [
{
deviceId: 'deviceId',
......@@ -160,7 +160,7 @@ import WantAgent from '@ohos.app.ability.wantAgent';
//wantAgent对象
var wantAgent;
let wantAgent;
//getWantAgent回调
function getWantAgentCallback(err, data) {
......@@ -172,7 +172,7 @@ function getWantAgentCallback(err, data) {
}
}
//WantAgentInfo对象
var wantAgentInfo = {
let wantAgentInfo = {
wants: [
{
deviceId: 'deviceId',
......@@ -241,10 +241,10 @@ import WantAgent from '@ohos.app.ability.wantAgent';
//wantAgent对象
var wantAgent;
let wantAgent;
//WantAgentInfo对象
var wantAgentInfo = {
let wantAgentInfo = {
wants: [
{
deviceId: 'deviceId',
......@@ -309,7 +309,7 @@ import WantAgent from '@ohos.app.ability.wantAgent';
//wantAgent对象
var wantAgent;
let wantAgent;
//getWantAgent回调
function getWantAgentCallback(err, data) {
......@@ -321,7 +321,7 @@ function getWantAgentCallback(err, data) {
}
}
//WantAgentInfo对象
var wantAgentInfo = {
let wantAgentInfo = {
wants: [
{
deviceId: 'deviceId',
......@@ -390,10 +390,10 @@ import WantAgent from '@ohos.app.ability.wantAgent';
//wantAgent对象
var wantAgent;
let wantAgent;
//WantAgentInfo对象
var wantAgentInfo = {
let wantAgentInfo = {
wants: [
{
deviceId: 'deviceId',
......@@ -460,7 +460,7 @@ import WantAgent from '@ohos.app.ability.wantAgent';
//wantAgent对象
var wantAgent;
let wantAgent;
//getWantAgent回调
function getWantAgentCallback(err, data) {
......@@ -472,7 +472,7 @@ function getWantAgentCallback(err, data) {
}
}
//WantAgentInfo对象
var wantAgentInfo = {
let wantAgentInfo = {
wants: [
{
deviceId: 'deviceId',
......@@ -543,10 +543,10 @@ import WantAgent from '@ohos.app.ability.wantAgent';
//wantAgent对象
var wantAgent;
let wantAgent;
//WantAgentInfo对象
var wantAgentInfo = {
let wantAgentInfo = {
wants: [
{
deviceId: 'deviceId',
......@@ -611,7 +611,7 @@ import WantAgent from '@ohos.app.ability.wantAgent';
//wantAgent对象
var wantAgent;
let wantAgent;
//getWantAgent回调
function getWantAgentCallback(err, data) {
......@@ -623,7 +623,7 @@ function getWantAgentCallback(err, data) {
}
}
//WantAgentInfo对象
var wantAgentInfo = {
let wantAgentInfo = {
wants: [
{
deviceId: 'deviceId',
......@@ -692,10 +692,10 @@ import WantAgent from '@ohos.app.ability.wantAgent';
//wantAgent对象
var wantAgent;
let wantAgent;
//WantAgentInfo对象
var wantAgentInfo = {
let wantAgentInfo = {
wants: [
{
deviceId: 'deviceId',
......@@ -761,7 +761,7 @@ import WantAgent from '@ohos.app.ability.wantAgent';
//wantAgent对象
var wantAgent;
let wantAgent;
//getWantAgent回调
function getWantAgentCallback(err, data) {
......@@ -773,7 +773,7 @@ function getWantAgentCallback(err, data) {
}
}
//WantAgentInfo对象
var wantAgentInfo = {
let wantAgentInfo = {
wants: [
{
deviceId: 'deviceId',
......@@ -809,7 +809,7 @@ try {
}
var triggerInfo = {
let triggerInfo = {
code:0
};
WantAgent.trigger(wantAgent, triggerInfo, triggerCallback);
......@@ -843,8 +843,8 @@ import WantAgent from '@ohos.app.ability.wantAgent';
//wantAgent对象
var wantAgent1;
var wantAgent2;
let wantAgent1;
let wantAgent2;
//getWantAgent回调
function getWantAgentCallback(err, data) {
......@@ -857,7 +857,7 @@ function getWantAgentCallback(err, data) {
}
}
//WantAgentInfo对象
var wantAgentInfo = {
let wantAgentInfo = {
wants: [
{
deviceId: 'deviceId',
......@@ -927,11 +927,11 @@ import WantAgent from '@ohos.app.ability.wantAgent';
//wantAgent对象
var wantAgent1;
var wantAgent2;
let wantAgent1;
let wantAgent2;
//WantAgentInfo对象
var wantAgentInfo = {
let wantAgentInfo = {
wants: [
{
deviceId: 'deviceId',
......@@ -994,10 +994,10 @@ getOperationType(agent: WantAgent, callback: AsyncCallback\<number>): void;
import WantAgent from '@ohos.app.ability.wantAgent';
//wantAgent对象
var wantAgent;
let wantAgent;
//WantAgentInfo对象
var wantAgentInfo = {
let wantAgentInfo = {
wants: [
{
deviceId: 'deviceId',
......@@ -1032,7 +1032,7 @@ try {
WantAgent.getOperationType(wantAgent, (OperationType) => {
console.log('----------- getOperationType ----------, OperationType: ' + OperationType);
})
});
} catch (paramError) {
console.log('error: ' + paramError.code + ', ' + paramError.message);
}
......@@ -1064,10 +1064,10 @@ getOperationType(agent: WantAgent): Promise\<number>;
import WantAgent from '@ohos.app.ability.wantAgent';
//wantAgent对象
var wantAgent;
let wantAgent;
//WantAgentInfo对象
var wantAgentInfo = {
let wantAgentInfo = {
wants: [
{
deviceId: 'deviceId',
......@@ -1104,7 +1104,7 @@ try {
console.log('getOperationType success, OperationType: ' + OperationType);
}).catch((err) => {
console.log('getOperationType fail, err: ' + err);
})
});
} catch (paramError) {
console.log('error: ' + paramError.code + ', ' + paramError.message);
}
......
......@@ -18,9 +18,8 @@
**示例:**
```ts
import hilog from '@ohos.hilog';
import Ability from '@ohos.application.Ability'
import Window from '@ohos.window'
import Ability from '@ohos.application.Ability';
import Window from '@ohos.window';
export default class MainAbility extends Ability {
onCreate(want, launchParam) {
......@@ -43,12 +42,10 @@ export default class MainAbility extends Ability {
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)}');
});
}
}
......
......@@ -34,7 +34,7 @@ deleteForm(formId: string, callback: AsyncCallback&lt;void&gt;): void
**示例:**
```ts
var formId = '12400633174999288';
let formId = '12400633174999288';
formHost.deleteForm(formId, (error, data) => {
if (error.code) {
console.log('formHost deleteForm, error:' + JSON.stringify(error));
......@@ -67,7 +67,7 @@ deleteForm(formId: string): Promise&lt;void&gt;
**参数:**
```ts
var formId = '12400633174999288';
let formId = '12400633174999288';
formHost.deleteForm(formId).then(() => {
console.log('formHost deleteForm success');
}).catch((error) => {
......@@ -95,7 +95,7 @@ releaseForm(formId: string, callback: AsyncCallback&lt;void&gt;): void
**示例:**
```ts
var formId = '12400633174999288';
let formId = '12400633174999288';
formHost.releaseForm(formId, (error, data) => {
if (error.code) {
console.log('formHost releaseForm, error:' + JSON.stringify(error));
......@@ -124,7 +124,7 @@ releaseForm(formId: string, isReleaseCache: boolean, callback: AsyncCallback&lt;
**示例:**
```ts
var formId = '12400633174999288';
let formId = '12400633174999288';
formHost.releaseForm(formId, true, (error, data) => {
if (error.code) {
console.log('formHost releaseForm, error:' + JSON.stringify(error));
......@@ -158,7 +158,7 @@ releaseForm(formId: string, isReleaseCache?: boolean): Promise&lt;void&gt;
**示例:**
```ts
var formId = '12400633174999288';
let formId = '12400633174999288';
formHost.releaseForm(formId, true).then(() => {
console.log('formHost releaseForm success');
}).catch((error) => {
......@@ -186,7 +186,7 @@ requestForm(formId: string, callback: AsyncCallback&lt;void&gt;): void
**示例:**
```ts
var formId = '12400633174999288';
let formId = '12400633174999288';
formHost.requestForm(formId, (error, data) => {
if (error.code) {
console.log('formHost requestForm, error:' + JSON.stringify(error));
......@@ -219,7 +219,7 @@ requestForm(formId: string): Promise&lt;void&gt;
**示例:**
```ts
var formId = '12400633174999288';
let formId = '12400633174999288';
formHost.requestForm(formId).then(() => {
console.log('formHost requestForm success');
}).catch((error) => {
......@@ -247,7 +247,7 @@ castTempForm(formId: string, callback: AsyncCallback&lt;void&gt;): void
**示例:**
```ts
var formId = '12400633174999288';
let formId = '12400633174999288';
formHost.castTempForm(formId, (error, data) => {
if (error.code) {
console.log('formHost castTempForm, error:' + JSON.stringify(error));
......@@ -280,7 +280,7 @@ castTempForm(formId: string): Promise&lt;void&gt;
**示例:**
```ts
var formId = '12400633174999288';
let formId = '12400633174999288';
formHost.castTempForm(formId).then(() => {
console.log('formHost castTempForm success');
}).catch((error) => {
......@@ -308,7 +308,7 @@ notifyVisibleForms(formIds: Array&lt;string&gt;, callback: AsyncCallback&lt;void
**示例:**
```ts
var formId = ['12400633174999288'];
let formId = ['12400633174999288'];
formHost.notifyVisibleForms(formId, (error, data) => {
if (error.code) {
console.log('formHost notifyVisibleForms, error:' + JSON.stringify(error));
......@@ -341,7 +341,7 @@ notifyVisibleForms(formIds: Array&lt;string&gt;): Promise&lt;void&gt;
**示例:**
```ts
var formId = ['12400633174999288'];
let formId = ['12400633174999288'];
formHost.notifyVisibleForms(formId).then(() => {
console.log('formHost notifyVisibleForms success');
}).catch((error) => {
......@@ -369,7 +369,7 @@ notifyInvisibleForms(formIds: Array&lt;string&gt;, callback: AsyncCallback&lt;vo
**示例:**
```ts
var formId = ['12400633174999288'];
let formId = ['12400633174999288'];
formHost.notifyInvisibleForms(formId, (error, data) => {
if (error.code) {
console.log('formHost notifyInvisibleForms, error:' + JSON.stringify(error));
......@@ -402,7 +402,7 @@ notifyInvisibleForms(formIds: Array&lt;string&gt;): Promise&lt;void&gt;
**示例:**
```ts
var formId = ['12400633174999288'];
let formId = ['12400633174999288'];
formHost.notifyInvisibleForms(formId).then(() => {
console.log('formHost notifyInvisibleForms success');
}).catch((error) => {
......@@ -430,7 +430,7 @@ enableFormsUpdate(formIds: Array&lt;string&gt;, callback: AsyncCallback&lt;void&
**示例:**
```ts
var formId = ['12400633174999288'];
let formId = ['12400633174999288'];
formHost.enableFormsUpdate(formId, (error, data) => {
if (error.code) {
console.log('formHost enableFormsUpdate, error:' + JSON.stringify(error));
......@@ -463,7 +463,7 @@ enableFormsUpdate(formIds: Array&lt;string&gt;): Promise&lt;void&gt;
**示例:**
```ts
var formId = ['12400633174999288'];
let formId = ['12400633174999288'];
formHost.enableFormsUpdate(formId).then(() => {
console.log('formHost enableFormsUpdate success');
}).catch((error) => {
......@@ -491,7 +491,7 @@ disableFormsUpdate(formIds: Array&lt;string&gt;, callback: AsyncCallback&lt;void
**示例:**
```ts
var formId = ['12400633174999288'];
let formId = ['12400633174999288'];
formHost.disableFormsUpdate(formId, (error, data) => {
if (error.code) {
console.log('formHost disableFormsUpdate, error:' + JSON.stringify(error));
......@@ -524,7 +524,7 @@ disableFormsUpdate(formIds: Array&lt;string&gt;): Promise&lt;void&gt;
**示例:**
```ts
var formId = ['12400633174999288'];
let formId = ['12400633174999288'];
formHost.disableFormsUpdate(formId).then(() => {
console.log('formHost disableFormsUpdate success');
}).catch((error) => {
......@@ -549,7 +549,7 @@ isSystemReady(callback: AsyncCallback&lt;void&gt;): void
**示例:**
```ts
var formId = '12400633174999288';
let formId = '12400633174999288';
formHost.isSystemReady((error, data) => {
if (error.code) {
console.log('formHost isSystemReady, error:' + JSON.stringify(error));
......@@ -574,7 +574,7 @@ isSystemReady(): Promise&lt;void&gt;
**示例:**
```ts
var formId = '12400633174999288';
let formId = '12400633174999288';
formHost.isSystemReady().then(() => {
console.log('formHost isSystemReady success');
}).catch((error) => {
......@@ -748,7 +748,7 @@ deleteInvalidForms(formIds: Array&lt;string&gt;, callback: AsyncCallback&lt;numb
**示例:**
```ts
var formIds = new Array('12400633174999288', '12400633174999289');
let formIds = new Array('12400633174999288', '12400633174999289');
formHost.deleteInvalidForms(formIds, (error, data) => {
if (error.code) {
console.log('formHost deleteInvalidForms, error:' + JSON.stringify(error));
......@@ -783,7 +783,7 @@ deleteInvalidForms(formIds: Array&lt;string&gt;): Promise&lt;number&gt;
**示例:**
```ts
var formIds = new Array('12400633174999288', '12400633174999289');
let formIds = new Array('12400633174999288', '12400633174999289');
formHost.deleteInvalidForms(formIds).then((data) => {
console.log('formHost deleteInvalidForms, data:' + JSON.stringify(data));
}).catch((error) => {
......@@ -811,7 +811,7 @@ acquireFormState(want: Want, callback: AsyncCallback&lt;formInfo.FormStateInfo&g
**示例:**
```ts
var want = {
let want = {
'deviceId': '',
'bundleName': 'ohos.samples.FormApplication',
'abilityName': 'FormAbility',
......@@ -855,7 +855,7 @@ acquireFormState(want: Want): Promise&lt;formInfo.FormStateInfo&gt;
**示例:**
```ts
var want = {
let want = {
'deviceId': '',
'bundleName': 'ohos.samples.FormApplication',
'abilityName': 'FormAbility',
......@@ -941,7 +941,7 @@ notifyFormsVisible(formIds: Array&lt;string&gt;, isVisible: boolean, callback: A
**示例:**
```ts
var formIds = new Array('12400633174999288', '12400633174999289');
let formIds = new Array('12400633174999288', '12400633174999289');
formHost.notifyFormsVisible(formIds, true, (error, data) => {
if (error.code) {
console.log('formHost notifyFormsVisible, error:' + JSON.stringify(error));
......@@ -975,7 +975,7 @@ notifyFormsVisible(formIds: Array&lt;string&gt;, isVisible: boolean): Promise&lt
**示例:**
```ts
var formIds = new Array('12400633174999288', '12400633174999289');
let formIds = new Array('12400633174999288', '12400633174999289');
formHost.notifyFormsVisible(formIds, true).then(() => {
console.log('formHost notifyFormsVisible success');
}).catch((error) => {
......@@ -1004,7 +1004,7 @@ notifyFormsEnableUpdate(formIds: Array&lt;string&gt;, isEnableUpdate: boolean, c
**示例:**
```ts
var formIds = new Array('12400633174999288', '12400633174999289');
let formIds = new Array('12400633174999288', '12400633174999289');
formHost.notifyFormsEnableUpdate(formIds, true, (error, data) => {
if (error.code) {
console.log('formHost notifyFormsEnableUpdate, error:' + JSON.stringify(error));
......@@ -1038,7 +1038,7 @@ notifyFormsEnableUpdate(formIds: Array&lt;string&gt;, isEnableUpdate: boolean):
**示例:**
```ts
var formIds = new Array('12400633174999288', '12400633174999289');
let formIds = new Array('12400633174999288', '12400633174999289');
formHost.notifyFormsEnableUpdate(formIds, true).then(() => {
console.log('formHost notifyFormsEnableUpdate success');
}).catch((error) => {
......@@ -1066,8 +1066,8 @@ shareForm(formId: string, deviceId: string, callback: AsyncCallback&lt;void&gt;)
**示例:**
```ts
var formId = '12400633174999288';
var deviceId = 'EFC11C0C53628D8CC2F8CB5052477E130D075917034613B9884C55CD22B3DEF2';
let formId = '12400633174999288';
let deviceId = 'EFC11C0C53628D8CC2F8CB5052477E130D075917034613B9884C55CD22B3DEF2';
formHost.shareForm(formId, deviceId, (error, data) => {
if (error.code) {
console.log('formHost shareForm, error:' + JSON.stringify(error));
......@@ -1101,8 +1101,8 @@ shareForm(formId: string, deviceId: string): Promise&lt;void&gt;
**参数:**
```ts
var formId = '12400633174999288';
var deviceId = 'EFC11C0C53628D8CC2F8CB5052477E130D075917034613B9884C55CD22B3DEF2';
let formId = '12400633174999288';
let deviceId = 'EFC11C0C53628D8CC2F8CB5052477E130D075917034613B9884C55CD22B3DEF2';
formHost.shareForm(formId, deviceId).then(() => {
console.log('formHost shareForm success');
}).catch((error) => {
......@@ -1126,7 +1126,7 @@ notifyFormsPrivacyProtected(formIds: Array\<string>, isProtected: boolean, callb
| deviceId | string | 是 | 远程设备标识。 |
```ts
var formIds = new Array('12400633174999288', '12400633174999289');
let formIds = new Array('12400633174999288', '12400633174999289');
formHost.notifyFormsPrivacyProtected(formIds, true).then(() => {
console.log('formHost shareForm success');
}).catch((error) => {
......
......@@ -31,7 +31,7 @@ setFormNextRefreshTime(formId: string, minute: number, callback: AsyncCallback&l
**示例:**
```ts
var formId = '12400633174999288';
let formId = '12400633174999288';
formProvider.setFormNextRefreshTime(formId, 5, (error, data) => {
if (error.code) {
console.log('formProvider setFormNextRefreshTime, error:' + JSON.stringify(error));
......@@ -63,7 +63,7 @@ setFormNextRefreshTime(formId: string, minute: number): Promise&lt;void&gt;
**示例:**
```ts
var formId = '12400633174999288';
let formId = '12400633174999288';
formProvider.setFormNextRefreshTime(formId, 5).then(() => {
console.log('formProvider setFormNextRefreshTime success');
}).catch((error) => {
......@@ -91,7 +91,7 @@ updateForm(formId: string, formBindingData: formBindingData.FormBindingData,call
```ts
import formBindingData from '@ohos.application.formBindingData';
var formId = '12400633174999288';
let formId = '12400633174999288';
let obj = formBindingData.createFormBindingData({temperature:'22c', time:'22:00'});
formProvider.updateForm(formId, obj, (error, data) => {
if (error.code) {
......@@ -125,7 +125,7 @@ updateForm(formId: string, formBindingData: formBindingData.FormBindingData): Pr
```ts
import formBindingData from '@ohos.application.formBindingData';
var formId = '12400633174999288';
let formId = '12400633174999288';
let obj = formBindingData.createFormBindingData({temperature:'22c', time:'22:00'});
formProvider.updateForm(formId, obj).then(() => {
console.log('formProvider updateForm success');
......@@ -248,7 +248,7 @@ requestPublishForm(want: Want, formBindingData: formBindingData.FormBindingData,
```ts
import formBindingData from '@ohos.application.formBindingData';
var want = {
let want = {
abilityName: 'FormAbility',
parameters: {
'ohos.extra.param.key.form_dimension': 2,
......@@ -286,7 +286,7 @@ requestPublishForm(want: Want, callback: AsyncCallback&lt;string&gt;): void
**示例:**
```ts
var want = {
let want = {
abilityName: 'FormAbility',
parameters: {
'ohos.extra.param.key.form_dimension': 2,
......@@ -329,7 +329,7 @@ requestPublishForm(want: Want, formBindingData?: formBindingData.FormBindingData
**示例:**
```ts
var want = {
let want = {
abilityName: 'FormAbility',
parameters: {
'ohos.extra.param.key.form_dimension': 2,
......@@ -368,7 +368,7 @@ formProvider.isRequestPublishFormSupported((error, isSupported) => {
console.log('formProvider isRequestPublishFormSupported, error:' + JSON.stringify(error));
} else {
if (isSupported) {
var want = {
let want = {
abilityName: 'FormAbility',
parameters: {
'ohos.extra.param.key.form_dimension': 2,
......@@ -409,7 +409,7 @@ isRequestPublishFormSupported(): Promise&lt;boolean&gt;
```ts
formProvider.isRequestPublishFormSupported().then((isSupported) => {
if (isSupported) {
var want = {
let want = {
abilityName: 'FormAbility',
parameters: {
'ohos.extra.param.key.form_dimension': 2,
......
......@@ -34,7 +34,7 @@ import Want from '@ohos.application.Want';
- 基础用法
```ts
var want = {
let want = {
'deviceId': '', // deviceId为空表示本设备
'bundleName': 'com.extreme.test',
'abilityName': 'MainAbility',
......@@ -110,13 +110,13 @@ import Want from '@ohos.application.Want';
* 文件描述符(FD)
```ts
import fileio from '@ohos.fileio';
var fd;
let fd;
try {
fd = fileio.openSync('/data/storage/el2/base/haps/pic.png');
} catch(e) {
console.log('openSync fail:' + JSON.stringify(e));
}
var want = {
let want = {
'deviceId': '', // deviceId为空表示本设备
'bundleName': 'com.extreme.test',
'abilityName': 'MainAbility',
......
......@@ -101,7 +101,7 @@ export default class MyWindowExtensionAbility extends WindowExtensionAbility {
window.loadContent('WindowExtAbility/pages/index1').then(() => {
window.getProperties().then((pro) => {
console.log('WindowExtension ' + JSON.stringify(pro));
})
});
window.show();
})
}
......
......@@ -35,13 +35,13 @@ addAbilityMonitor(monitor: AbilityMonitor, callback: AsyncCallback\<void>): void
**示例:**
```ts
var abilityDelegator;
let abilityDelegator;
function onAbilityCreateCallback(data) {
console.info('onAbilityCreateCallback');
}
var monitor = {
let monitor = {
abilityName: 'abilityname',
onAbilityCreate: onAbilityCreateCallback
};
......@@ -75,13 +75,13 @@ addAbilityMonitor(monitor: AbilityMonitor): Promise\<void>;
**示例:**
```ts
var abilityDelegator;
let abilityDelegator;
function onAbilityCreateCallback(data) {
console.info('onAbilityCreateCallback');
}
var monitor = {
let monitor = {
abilityName: 'abilityname',
onAbilityCreate: onAbilityCreateCallback
};
......@@ -112,13 +112,13 @@ removeAbilityMonitor(monitor: AbilityMonitor, callback: AsyncCallback\<void>): v
**示例:**
```ts
var abilityDelegator;
let abilityDelegator;
function onAbilityCreateCallback(data) {
console.info('onAbilityCreateCallback');
}
var monitor = {
let monitor = {
abilityName: 'abilityname',
onAbilityCreate: onAbilityCreateCallback
};
......@@ -154,13 +154,13 @@ removeAbilityMonitor(monitor: AbilityMonitor): Promise\<void>;
- 示例
```ts
var abilityDelegator;
let abilityDelegator;
function onAbilityCreateCallback(data) {
console.info('onAbilityCreateCallback');
}
var monitor = {
let monitor = {
abilityName: 'abilityname',
onAbilityCreate: onAbilityCreateCallback
};
......@@ -191,13 +191,13 @@ waitAbilityMonitor(monitor: AbilityMonitor, callback: AsyncCallback\<UIAbility>)
**示例:**
```ts
var abilityDelegator;
let abilityDelegator;
function onAbilityCreateCallback(data) {
console.info('onAbilityCreateCallback');
}
var monitor = {
let monitor = {
abilityName: 'abilityname',
onAbilityCreate: onAbilityCreateCallback
};
......@@ -227,14 +227,14 @@ waitAbilityMonitor(monitor: AbilityMonitor, timeout: number, callback: AsyncCall
**示例:**
```ts
var abilityDelegator;
var timeout = 100;
let abilityDelegator;
let timeout = 100;
function onAbilityCreateCallback(data) {
console.info('onAbilityCreateCallback');
}
var monitor = {
let monitor = {
abilityName: 'abilityname',
onAbilityCreate: onAbilityCreateCallback
};
......@@ -271,13 +271,13 @@ waitAbilityMonitor(monitor: AbilityMonitor, timeout?: number): Promise\<UIAbilit
**示例:**
```ts
var abilityDelegator;
let abilityDelegator;
function onAbilityCreateCallback(data) {
console.info('onAbilityCreateCallback');
}
var monitor = {
let monitor = {
abilityName: 'abilityname',
onAbilityCreate: onAbilityCreateCallback
};
......@@ -307,10 +307,10 @@ getAppContext(): Context;
**示例:**
```ts
var abilityDelegator;
let abilityDelegator;
abilityDelegator = AbilityDelegatorRegistry.getAbilityDelegator();
var context = abilityDelegator.getAppContext();
let context = abilityDelegator.getAppContext();
```
......@@ -338,14 +338,14 @@ getAbilityState(ability: UIAbility): number;
**示例:**
```ts
var abilityDelegator;
var ability;
let abilityDelegator;
let ability;
abilityDelegator = AbilityDelegatorRegistry.getAbilityDelegator();
abilityDelegator.getCurrentTopAbility((err : any, data : any) => {
console.info('getCurrentTopAbility callback');
ability = data;
var state = abilityDelegator.getAbilityState(ability);
let state = abilityDelegator.getAbilityState(ability);
console.info('getAbilityState' + state);
});
```
......@@ -369,8 +369,8 @@ getCurrentTopAbility(callback: AsyncCallback\<UIAbility>): void;
**示例:**
```ts
var abilityDelegator;
var ability;
let abilityDelegator;
let ability;
abilityDelegator = AbilityDelegatorRegistry.getAbilityDelegator();
abilityDelegator.getCurrentTopAbility((err : any, data : any) => {
......@@ -398,8 +398,8 @@ getCurrentTopAbility(): Promise\<UIAbility>;
**示例:**
```ts
var abilityDelegator;
var ability;
let abilityDelegator;
let ability;
abilityDelegator = AbilityDelegatorRegistry.getAbilityDelegator();
abilityDelegator.getCurrentTopAbility().then((data : any) => {
......@@ -428,8 +428,8 @@ startAbility(want: Want, callback: AsyncCallback\<void>): void;
**示例:**
```ts
var abilityDelegator;
var want = {
let abilityDelegator;
let want = {
bundleName: 'bundleName',
abilityName: 'abilityName'
};
......@@ -465,8 +465,8 @@ startAbility(want: Want): Promise\<void>;
**示例:**
```ts
var abilityDelegator;
var want = {
let abilityDelegator;
let want = {
bundleName: 'bundleName',
abilityName: 'abilityName'
};
......@@ -497,8 +497,8 @@ doAbilityForeground(ability: UIAbility, callback: AsyncCallback\<void>): void;
**示例:**
```ts
var abilityDelegator;
var ability;
let abilityDelegator;
let ability;
abilityDelegator = AbilityDelegatorRegistry.getAbilityDelegator();
abilityDelegator.getCurrentTopAbility((err : any, data : any) => {
......@@ -535,8 +535,8 @@ doAbilityForeground(ability: UIAbility): Promise\<void>;
**示例:**
```ts
var abilityDelegator;
var ability;
let abilityDelegator;
let ability;
abilityDelegator = AbilityDelegatorRegistry.getAbilityDelegator();
abilityDelegator.getCurrentTopAbility((err : any, data : any) => {
......@@ -568,8 +568,8 @@ doAbilityBackground(ability: UIAbility, callback: AsyncCallback\<void>): void;
**示例:**
```ts
var abilityDelegator;
var ability;
let abilityDelegator;
let ability;
abilityDelegator = AbilityDelegatorRegistry.getAbilityDelegator();
abilityDelegator.getCurrentTopAbility((err : any, data : any) => {
......@@ -606,8 +606,8 @@ doAbilityBackground(ability: UIAbility): Promise\<void>;
**示例:**
```ts
var abilityDelegator;
var ability;
let abilityDelegator;
let ability;
abilityDelegator = AbilityDelegatorRegistry.getAbilityDelegator();
abilityDelegator.getCurrentTopAbility((err : any, data : any) => {
......@@ -638,8 +638,8 @@ printSync(msg: string): void;
**示例:**
```ts
var abilityDelegator;
var msg = 'msg';
let abilityDelegator;
let msg = 'msg';
abilityDelegator = AbilityDelegatorRegistry.getAbilityDelegator();
abilityDelegator.printSync(msg);
......@@ -665,8 +665,8 @@ print(msg: string, callback: AsyncCallback\<void>): void;
**示例:**
```ts
var abilityDelegator;
var msg = 'msg';
let abilityDelegator;
let msg = 'msg';
abilityDelegator = AbilityDelegatorRegistry.getAbilityDelegator();
abilityDelegator.print(msg, (err : any) => {
......@@ -699,8 +699,8 @@ print(msg: string): Promise\<void>;
**示例:**
```ts
var abilityDelegator;
var msg = 'msg';
let abilityDelegator;
let msg = 'msg';
abilityDelegator = AbilityDelegatorRegistry.getAbilityDelegator();
abilityDelegator.print(msg).then(() => {
......@@ -728,8 +728,8 @@ executeShellCommand(cmd: string, callback: AsyncCallback\<ShellCmdResult>): void
**示例:**
```ts
var abilityDelegator;
var cmd = 'cmd';
let abilityDelegator;
let cmd = 'cmd';
abilityDelegator = AbilityDelegatorRegistry.getAbilityDelegator();
abilityDelegator.executeShellCommand(cmd, (err : any, data : any) => {
......@@ -758,9 +758,9 @@ executeShellCommand(cmd: string, timeoutSecs: number, callback: AsyncCallback\<S
**示例:**
```ts
var abilityDelegator;
var cmd = 'cmd';
var timeout = 100;
let abilityDelegator;
let cmd = 'cmd';
let timeout = 100;
abilityDelegator = AbilityDelegatorRegistry.getAbilityDelegator();
abilityDelegator.executeShellCommand(cmd, timeout, (err : any, data : any) => {
......@@ -794,9 +794,9 @@ executeShellCommand(cmd: string, timeoutSecs?: number): Promise\<ShellCmdResult>
**示例:**
```ts
var abilityDelegator;
var cmd = 'cmd';
var timeout = 100;
let abilityDelegator;
let cmd = 'cmd';
let timeout = 100;
abilityDelegator = AbilityDelegatorRegistry.getAbilityDelegator();
abilityDelegator.executeShellCommand(cmd, timeout).then((data : any) => {
......@@ -825,8 +825,8 @@ finishTest(msg: string, code: number, callback: AsyncCallback\<void>): void;
**示例:**
```ts
var abilityDelegator;
var msg = 'msg';
let abilityDelegator;
let msg = 'msg';
abilityDelegator = AbilityDelegatorRegistry.getAbilityDelegator();
abilityDelegator.finishTest(msg, 0, (err : any) => {
......@@ -860,8 +860,8 @@ finishTest(msg: string, code: number): Promise\<void>;
**示例:**
```ts
var abilityDelegator;
var msg = 'msg';
let abilityDelegator;
let msg = 'msg';
abilityDelegator = AbilityDelegatorRegistry.getAbilityDelegator();
abilityDelegator.finishTest(msg, 0).then(() => {
......@@ -887,9 +887,9 @@ addAbilityStageMonitor(monitor: AbilityStageMonitor, callback: AsyncCallback\<vo
**示例:**
```ts
var abilityDelegator;
let abilityDelegator;
var monitor = {
let monitor = {
moduleName: 'moduleName',
srcEntrance: 'srcEntrance',
};
......@@ -925,9 +925,9 @@ addAbilityStageMonitor(monitor: AbilityStageMonitor): Promise\<void>;
**示例:**
```ts
var abilityDelegator;
let abilityDelegator;
var monitor = {
let monitor = {
moduleName: 'moduleName',
srcEntrance: 'srcEntrance',
};
......@@ -956,9 +956,9 @@ removeAbilityStageMonitor(monitor: AbilityStageMonitor, callback: AsyncCallback\
**示例:**
```ts
var abilityDelegator;
let abilityDelegator;
var monitor = {
let monitor = {
moduleName: 'moduleName',
srcEntrance: 'srcEntrance',
};
......@@ -994,9 +994,9 @@ removeAbilityStageMonitor(monitor: AbilityStageMonitor): Promise\<void>;
**示例:**
```ts
var abilityDelegator;
let abilityDelegator;
var monitor = {
let monitor = {
moduleName: 'moduleName',
srcEntrance: 'srcEntrance',
};
......@@ -1025,13 +1025,13 @@ waitAbilityStageMonitor(monitor: AbilityStageMonitor, callback: AsyncCallback\<A
**示例:**
```ts
var abilityDelegator;
let abilityDelegator;
function onAbilityCreateCallback(data) {
console.info('onAbilityCreateCallback');
}
var monitor = {
let monitor = {
moduleName: 'moduleName',
srcEntrance: 'srcEntrance',
};
......@@ -1066,13 +1066,13 @@ waitAbilityStageMonitor(monitor: AbilityStageMonitor, timeout?: number): Promise
**示例:**
```ts
var abilityDelegator;
let abilityDelegator;
function onAbilityCreateCallback(data) {
console.info('onAbilityCreateCallback');
}
var monitor = {
let monitor = {
moduleName: 'moduleName',
srcEntrance: 'srcEntrance',
};
......@@ -1102,14 +1102,14 @@ waitAbilityStageMonitor(monitor: AbilityStageMonitor, timeout: number, callback:
**示例:**
```ts
var abilityDelegator;
var timeout = 100;
let abilityDelegator;
let timeout = 100;
function onAbilityCreateCallback(data) {
console.info('onAbilityCreateCallback');
}
var monitor = {
let monitor = {
moduleName: 'moduleName',
srcEntrance: 'srcEntrance',
};
......
......@@ -50,7 +50,7 @@ startAbility(want: Want, callback: AsyncCallback&lt;void&gt;): void
**示例:**
```ts
var want = {
let want = {
deviceId: '',
bundleName: 'com.example.formstartability',
abilityName: 'MainAbility',
......@@ -94,7 +94,7 @@ startAbility(want: Want): Promise&lt;void&gt;
**示例:**
```ts
var want = {
let want = {
deviceId: '',
bundleName: 'com.example.formstartability',
abilityName: 'MainAbility',
......
......@@ -16,7 +16,7 @@
**示例:**
```ts
import appManager from '@ohos.application.appManager'
import appManager from '@ohos.application.appManager';
let applicationStateObserver = {
onForegroundApplicationChanged(appStateData) {
......@@ -38,6 +38,6 @@ let applicationStateObserver = {
console.log('onProcessStateChanged processData.isContinuousTask : ' + JSON.stringify(processData.isContinuousTask));
console.log('onProcessStateChanged processData.isKeepAlive : ' + JSON.stringify(processData.isKeepAlive));
}
}
};
let observerCode = appManager.registerApplicationStateObserver(applicationStateObserver);
```
\ No newline at end of file
......@@ -66,7 +66,7 @@ startAbility(want: Want, callback: AsyncCallback&lt;void&gt;): void;
**示例:**
```ts
var want = {
let want = {
bundleName: 'com.example.myapp',
abilityName: 'MyAbility'
};
......@@ -138,12 +138,12 @@ startAbility(want: Want, options: StartOptions, callback: AsyncCallback&lt;void&
**示例:**
```ts
var want = {
let want = {
deviceId: '',
bundleName: 'com.extreme.test',
abilityName: 'MainAbility'
};
var options = {
let options = {
windowMode: 0
};
......@@ -218,11 +218,11 @@ startAbility(want: Want, options?: StartOptions): Promise&lt;void&gt;;
**示例:**
```ts
var want = {
let want = {
bundleName: 'com.example.myapp',
abilityName: 'MyAbility'
};
var options = {
let options = {
windowMode: 0,
};
......@@ -295,7 +295,7 @@ startAbilityForResult(want: Want, callback: AsyncCallback&lt;AbilityResult&gt;):
**示例:**
```ts
var want = {
let want = {
deviceId: '',
bundleName: 'com.extreme.test',
abilityName: 'MainAbility'
......@@ -371,12 +371,12 @@ startAbilityForResult(want: Want, options: StartOptions, callback: AsyncCallback
**示例:**
```ts
var want = {
let want = {
deviceId: '',
bundleName: 'com.extreme.test',
abilityName: 'MainAbility'
};
var options = {
let options = {
windowMode: 0,
};
......@@ -457,11 +457,11 @@ startAbilityForResult(want: Want, options?: StartOptions): Promise&lt;AbilityRes
**示例:**
```ts
var want = {
let want = {
bundleName: 'com.example.myapp',
abilityName: 'MyAbility'
};
var options = {
let options = {
windowMode: 0,
};
......@@ -531,12 +531,12 @@ startAbilityForResultWithAccount(want: Want, accountId: number, callback: AsyncC
**示例:**
```ts
var want = {
let want = {
deviceId: '',
bundleName: 'com.extreme.test',
abilityName: 'MainAbility'
};
var accountId = 100;
let accountId = 100;
try {
this.context.startAbilityForResultWithAccount(want, accountId, (error, result) => {
......@@ -607,13 +607,13 @@ startAbilityForResultWithAccount(want: Want, accountId: number, options: StartOp
**示例:**
```ts
var want = {
let want = {
deviceId: '',
bundleName: 'com.extreme.test',
abilityName: 'MainAbility'
};
var accountId = 100;
var options = {
let accountId = 100;
let options = {
windowMode: 0
};
......@@ -691,13 +691,13 @@ startAbilityForResultWithAccount(want: Want, accountId: number, options?: StartO
**示例:**
```ts
var want = {
let want = {
deviceId: '',
bundleName: 'com.extreme.test',
abilityName: 'MainAbility'
};
var accountId = 100;
var options = {
let accountId = 100;
let options = {
windowMode: 0
};
......@@ -756,7 +756,7 @@ startServiceExtensionAbility(want: Want, callback: AsyncCallback\<void>): void;
**示例:**
```ts
var want = {
let want = {
deviceId: '',
bundleName: 'com.extreme.test',
abilityName: 'MainAbility'
......@@ -816,7 +816,7 @@ startServiceExtensionAbility(want: Want): Promise\<void>;
**示例:**
```ts
var want = {
let want = {
deviceId: '',
bundleName: 'com.extreme.test',
abilityName: 'MainAbility'
......@@ -877,12 +877,12 @@ startServiceExtensionAbilityWithAccount(want: Want, accountId: number, callback:
**示例:**
```ts
var want = {
let want = {
deviceId: '',
bundleName: 'com.extreme.test',
abilityName: 'MainAbility'
};
var accountId = 100;
let accountId = 100;
try {
this.context.startServiceExtensionAbilityWithAccount(want, accountId, (error) => {
......@@ -942,12 +942,12 @@ startServiceExtensionAbilityWithAccount(want: Want, accountId: number): Promise\
**示例:**
```ts
var want = {
let want = {
deviceId: '',
bundleName: 'com.extreme.test',
abilityName: 'MainAbility'
};
var accountId = 100;
let accountId = 100;
try {
this.context.startServiceExtensionAbilityWithAccount(want, accountId)
......@@ -1000,7 +1000,7 @@ stopServiceExtensionAbility(want: Want, callback: AsyncCallback\<void>): void;
**示例:**
```ts
var want = {
let want = {
deviceId: '',
bundleName: 'com.extreme.test',
abilityName: 'MainAbility'
......@@ -1057,7 +1057,7 @@ stopServiceExtensionAbility(want: Want): Promise\<void>;
**示例:**
```ts
var want = {
let want = {
deviceId: '',
bundleName: 'com.extreme.test',
abilityName: 'MainAbility'
......@@ -1119,12 +1119,12 @@ stopServiceExtensionAbilityWithAccount(want: Want, accountId: number, callback:
**示例:**
```ts
var want = {
let want = {
deviceId: '',
bundleName: 'com.extreme.test',
abilityName: 'MainAbility'
};
var accountId = 100;
let accountId = 100;
try {
this.context.stopServiceExtensionAbilityWithAccount(want, accountId, (error) => {
......@@ -1181,12 +1181,12 @@ stopServiceExtensionAbilityWithAccount(want: Want, accountId: number): Promise\<
**示例:**
```ts
var want = {
let want = {
deviceId: '',
bundleName: 'com.extreme.test',
abilityName: 'MainAbility'
};
var accountId = 100;
let accountId = 100;
try {
this.context.stopServiceExtensionAbilityWithAccount(want, accountId)
......@@ -1315,13 +1315,13 @@ terminateSelfWithResult(parameter: AbilityResult, callback: AsyncCallback&lt;voi
**示例:**
```ts
var want = {
let want = {
bundleName: 'com.extreme.myapplication',
abilityName: 'SecondAbility'
}
var resultCode = 100;
let resultCode = 100;
// 返回给接口调用方AbilityResult信息
var abilityResult = {
let abilityResult = {
want,
resultCode
}
......@@ -1380,13 +1380,13 @@ terminateSelfWithResult(parameter: AbilityResult): Promise&lt;void&gt;;
**示例:**
```ts
var want = {
let want = {
bundleName: 'com.extreme.myapplication',
abilityName: 'SecondAbility'
}
var resultCode = 100;
let resultCode = 100;
// 返回给接口调用方AbilityResult信息
var abilityResult = {
let abilityResult = {
want,
resultCode
}
......@@ -1445,18 +1445,18 @@ connectServiceExtensionAbility(want: Want, options: ConnectOptions): number;
**示例:**
```ts
var want = {
let want = {
deviceId: '',
bundleName: 'com.extreme.test',
abilityName: 'MainAbility'
};
var options = {
let options = {
onConnect(elementName, remote) { console.log('----------- onConnect -----------') },
onDisconnect(elementName) { console.log('----------- onDisconnect -----------') },
onFailed(code) { console.log('----------- onFailed -----------') }
}
var connection = null;
let connection = null;
try {
connection = this.context.connectServiceExtensionAbility(want, options);
} catch (paramError) {
......@@ -1509,19 +1509,19 @@ connectServiceExtensionAbilityWithAccount(want: Want, accountId: number, options
**示例:**
```ts
var want = {
let want = {
deviceId: '',
bundleName: 'com.extreme.test',
abilityName: 'MainAbility'
};
var accountId = 100;
var options = {
let accountId = 100;
let options = {
onConnect(elementName, remote) { console.log('----------- onConnect -----------') },
onDisconnect(elementName) { console.log('----------- onDisconnect -----------') },
onFailed(code) { console.log('----------- onFailed -----------') }
}
var connection = null;
let connection = null;
try {
connection = this.context.connectServiceExtensionAbilityWithAccount(want, accountId, options);
} catch (paramError) {
......@@ -1568,7 +1568,7 @@ disconnectServiceExtensionAbility(connection: number): Promise\<void>;
```ts
// connection为connectServiceExtensionAbility中的返回值
var connection = 1;
let connection = 1;
try {
this.context.disconnectServiceExtensionAbility(connection)
......@@ -1620,7 +1620,7 @@ disconnectServiceExtensionAbility(connection: number, callback:AsyncCallback\<vo
```ts
// connection为connectServiceExtensionAbility中的返回值
var connection = 1;
let connection = 1;
try {
this.context.disconnectServiceExtensionAbility(connection, (error) => {
......@@ -1670,10 +1670,10 @@ startAbilityByCall(want: Want): Promise&lt;Caller&gt;;
后台启动:
```ts
var caller = undefined;
let caller = undefined;
// 后台启动Ability,不配置parameters
var wantBackground = {
let wantBackground = {
bundleName: 'com.example.myservice',
moduleName: 'entry',
abilityName: 'MainAbility',
......@@ -1701,10 +1701,10 @@ startAbilityByCall(want: Want): Promise&lt;Caller&gt;;
前台启动:
```ts
var caller = undefined;
let caller = undefined;
// 前台启动Ability,将parameters中的'ohos.aafwk.param.callAbilityToForeground'配置为true
var wantForeground = {
let wantForeground = {
bundleName: 'com.example.myservice',
moduleName: 'entry',
abilityName: 'MainAbility',
......@@ -1780,12 +1780,12 @@ startAbilityWithAccount(want: Want, accountId: number, callback: AsyncCallback\<
**示例:**
```ts
var want = {
let want = {
deviceId: '',
bundleName: 'com.extreme.test',
abilityName: 'MainAbility'
};
var accountId = 100;
let accountId = 100;
try {
this.context.startAbilityWithAccount(want, accountId, (error) => {
......@@ -1855,13 +1855,13 @@ startAbilityWithAccount(want: Want, accountId: number, options: StartOptions, ca
**示例:**
```ts
var want = {
let want = {
deviceId: '',
bundleName: 'com.extreme.test',
abilityName: 'MainAbility'
};
var accountId = 100;
var options = {
let accountId = 100;
let options = {
windowMode: 0
};
......@@ -1932,13 +1932,13 @@ startAbilityWithAccount(want: Want, accountId: number, options?: StartOptions):
**示例:**
```ts
var want = {
let want = {
deviceId: '',
bundleName: 'com.extreme.test',
abilityName: 'MainAbility'
};
var accountId = 100;
var options = {
let accountId = 100;
let options = {
windowMode: 0
};
......@@ -1978,7 +1978,7 @@ requestPermissionsFromUser(permissions: Array&lt;string&gt;, requestCallback: As
**示例:**
```ts
var permissions=['com.example.permission']
let permissions=['com.example.permission']
this.context.requestPermissionsFromUser(permissions,(result) => {
console.log('requestPermissionsFromUserresult:' + JSON.stringify(result));
});
......@@ -2009,7 +2009,7 @@ requestPermissionsFromUser(permissions: Array&lt;string&gt;) : Promise&lt;Permis
**示例:**
```ts
var permissions=['com.example.permission']
let permissions=['com.example.permission']
this.context.requestPermissionsFromUser(permissions).then((data) => {
console.log('success:' + JSON.stringify(data));
}).catch((error) => {
......@@ -2093,9 +2093,9 @@ setMissionIcon(icon: image.PixelMap, callback:AsyncCallback\<void>): void;
```ts
import image from '@ohos.multimedia.image';
var imagePixelMap;
var color = new ArrayBuffer(0);
var initializationOptions = {
let imagePixelMap;
let color = new ArrayBuffer(0);
let initializationOptions = {
size: {
height: 100,
width: 100
......@@ -2140,9 +2140,9 @@ setMissionIcon(icon: image.PixelMap): Promise\<void>;
```ts
import image from '@ohos.multimedia.image';
var imagePixelMap;
var color = new ArrayBuffer(0);
var initializationOptions = {
let imagePixelMap;
let color = new ArrayBuffer(0);
let initializationOptions = {
size: {
height: 100,
width: 100
......@@ -2180,7 +2180,7 @@ restoreWindowStage(localStorage: LocalStorage) : void;
**示例:**
```ts
var storage = new LocalStorage();
let storage = new LocalStorage();
this.context.restoreWindowStage(storage);
```
......@@ -2201,6 +2201,6 @@ isTerminating(): boolean;
**示例:**
```ts
var isTerminating = this.context.isTerminating();
let isTerminating = this.context.isTerminating();
console.log('ability state :' + isTerminating);
```
\ No newline at end of file
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册