未验证 提交 5183da0f 编写于 作者: O openharmony_ci 提交者: Gitee

!15778 翻译完成:15306+15241 资料描述优化

Merge pull request !15778 from wusongqing/TR15306
......@@ -57,8 +57,12 @@ featureAbility.startAbility(
uri: ''
},
},
(err, data) => {
console.info('startAbility err: ${JSON.stringify(err)}, data: ${JSON.stringify(data)}');
(error, data) => {
if (error && error.code !== 0) {
console.error('startAbility fail, error: ${JSON.stringify(error)}');
} else {
console.log('startAbility success, data: ${JSON.stringify(data)}');
}
}
);
```
......@@ -99,7 +103,7 @@ featureAbility.startAbility(
{
want:
{
action: 'action.system.home',
action: 'ohos.want.action.home',
entities: ['entity.system.home'],
type: 'MIMETYPE',
flags: wantConstant.Flags.FLAG_AUTH_READ_URI_PERMISSION,
......@@ -182,7 +186,7 @@ featureAbility.startAbilityForResult(
{
want:
{
action: 'action.system.home',
action: 'ohos.want.action.home',
entities: ['entity.system.home'],
type: 'MIMETYPE',
flags: wantConstant.Flags.FLAG_AUTH_READ_URI_PERMISSION,
......@@ -193,8 +197,12 @@ featureAbility.startAbilityForResult(
uri:''
},
},
(err, data) => {
console.info('startAbilityForResult err: ${JSON.stringify(err)}, data: ${JSON.stringify(data)}');
(error, data) => {
if (error && error.code !== 0) {
console.error('startAbilityForResult fail, error: ${JSON.stringify(error)}');
} else {
console.log('startAbilityForResult success, data: ${JSON.stringify(data)}');
}
}
);
```
......@@ -236,7 +244,7 @@ featureAbility.startAbilityForResult(
{
want:
{
action: 'action.system.home',
action: 'ohos.want.action.home',
entities: ['entity.system.home'],
type: 'MIMETYPE',
flags: wantConstant.Flags.FLAG_AUTH_READ_URI_PERMISSION,
......@@ -288,7 +296,7 @@ featureAbility.terminateSelfWithResult(
resultCode: 1,
want:
{
action: 'action.system.home',
action: 'ohos.want.action.home',
entities: ['entity.system.home'],
type: 'MIMETYPE',
flags: wantConstant.Flags.FLAG_AUTH_READ_URI_PERMISSION,
......@@ -309,8 +317,8 @@ featureAbility.terminateSelfWithResult(
}
},
},
(err) => {
console.error('err: ${JSON.stringify(err)}');
(error) => {
console.error('error: ${JSON.stringify(error)}');
}
);
```
......@@ -345,7 +353,7 @@ featureAbility.terminateSelfWithResult(
resultCode: 1,
want:
{
action: 'action.system.home',
action: 'ohos.want.action.home',
entities: ['entity.system.home'],
type: 'MIMETYPE',
flags: wantConstant.Flags.FLAG_AUTH_READ_URI_PERMISSION,
......@@ -389,8 +397,12 @@ Checks whether the main window of this ability has the focus. This API uses an a
```ts
import featureAbility from '@ohos.ability.featureAbility';
featureAbility.hasWindowFocus((err, data) => {
console.info('hasWindowFocus err: ${JSON.stringify(err)}, data: ${JSON.stringify(data)}');
featureAbility.hasWindowFocus((error, data) => {
if (error && error.code !== 0) {
console.error('hasWindowFocus fail, error: ${JSON.stringify(error)}');
} else {
console.log('hasWindowFocus success, data: ${JSON.stringify(data)}');
}
});
```
......@@ -435,8 +447,12 @@ Obtains the Want corresponding to the ability to start. This API uses an asynchr
```ts
import featureAbility from '@ohos.ability.featureAbility';
featureAbility.getWant((err, data) => {
console.info('getWant err: ${JSON.stringify(err)}, data: ${JSON.stringify(data)}');
featureAbility.getWant((error, data) => {
if (error && error.code !== 0) {
console.error('getWant fail, error: ${JSON.stringify(error)}');
} else {
console.log('getWant success, data: ${JSON.stringify(data)}');
}
});
```
......@@ -482,8 +498,12 @@ Obtains the application context.
```ts
import featureAbility from '@ohos.ability.featureAbility';
let context = featureAbility.getContext();
context.getBundleName((err, data) => {
console.info('getBundleName err: ${JSON.stringify(err)}, data: ${JSON.stringify(data)}');
context.getBundleName((error, data) => {
if (error && error.code !== 0) {
console.error('getBundleName fail, error: ${JSON.stringify(error)}');
} else {
console.log('getBundleName success, data: ${JSON.stringify(data)}');
}
});
```
......@@ -506,8 +526,8 @@ Terminates this ability. This API uses an asynchronous callback to return the re
```ts
import featureAbility from '@ohos.ability.featureAbility';
featureAbility.terminateSelf(
(err) => {
console.error('err: ${JSON.stringify(err)}');
(error) => {
console.error('error: ${JSON.stringify(error)}');
}
)
```
......@@ -574,7 +594,7 @@ function onDisconnectCallback(element){
console.log('ConnectAbility onDisconnect element.deviceId : ${element.deviceId}')
}
function onFailedCallback(code){
console.log('featureAbilityTest ConnectAbility onFailed errCode : ${code}')
console.error('featureAbilityTest ConnectAbility onFailed errCode : ${code}')
}
let connectId = featureAbility.connectAbility(
{
......@@ -617,7 +637,7 @@ function onDisconnectCallback(element){
console.log('ConnectAbility onDisconnect element.deviceId : ${element.deviceId}');
}
function onFailedCallback(code){
console.log('featureAbilityTest ConnectAbility onFailed errCode : ${code}');
console.error('featureAbilityTest ConnectAbility onFailed errCode : ${code}');
}
let connectId = featureAbility.connectAbility(
{
......@@ -631,8 +651,12 @@ let connectId = featureAbility.connectAbility(
},
);
featureAbility.disconnectAbility(connectId, (err) => {
console.error('featureAbilityTest disconnectAbility err: ${JSON.stringify(err)}');
featureAbility.disconnectAbility(connectId, (error) => {
if (error && error.code !== 0) {
console.error('disconnectAbility fail, connectId: ${connectId}, error: ${JSON.stringify(error)}');
} else {
console.log('disconnectAbility success, connectId: ${connectId}');
}
});
```
......@@ -668,7 +692,7 @@ function onDisconnectCallback(element){
console.log('ConnectAbility onDisconnect element.deviceId : ${element.deviceId}');
}
function onFailedCallback(code){
console.log('featureAbilityTest ConnectAbility onFailed errCode : ${code}');
console.error('featureAbilityTest ConnectAbility onFailed errCode : ${code}');
}
let connectId = featureAbility.connectAbility(
{
......@@ -707,8 +731,12 @@ Obtains the window corresponding to this ability. This API uses an asynchronous
**Example**
```ts
featureAbility.getWindow((err, data) => {
console.info('getWindow err: ${JSON.stringify(err)}, data: ${typeof(data)}');
featureAbility.getWindow((error, data) => {
if (error && error.code !== 0) {
console.error('getWindow fail, error: ${JSON.stringify(error)}');
} else {
console.log('getWindow success, data: ${JSON.stringify(data)}');
}
});
```
......@@ -823,6 +851,6 @@ Enumerates the flags that specify how the Want will be handled.
| FLAG_ABILITY_CONTINUATION_REVERSIBLE | 0x00000400 | Indicates that the migration is reversible. |
| FLAG_INSTALL_ON_DEMAND | 0x00000800 | Indicates that the specific ability will be installed if it has not been installed. |
| FLAG_INSTALL_WITH_BACKGROUND_MODE | 0x80000000 | Indicates that the specific ability will be installed in the background if it has not been installed. |
| FLAG_ABILITY_CLEAR_MISSION | 0x00008000 | Clears other operation missions. This flag can be set for the **Want** object in the **startAbility** API passed to [ohos.app.Context](js-apis-ability-context.md) and must be used together with **flag_ABILITY_NEW_MISSION**.|
| FLAG_ABILITY_CLEAR_MISSION | 0x00008000 | Clears other operation missions. This flag can be set for [Want](js-apis-application-want.md) under the [parameter](js-apis-inner-ability-startAbilityParameter.md) object passed to the [startAbility](#featureabilitystartability) API in **FeatureAbility**. It must be used together with **flag_ABILITY_NEW_MISSION**.|
| FLAG_ABILITY_NEW_MISSION | 0x10000000 | Creates a mission on an existing mission stack. |
| FLAG_ABILITY_MISSION_TOP | 0x20000000 | Reuses an ability instance if it is on the top of an existing mission stack; creates an ability instance otherwise.|
......@@ -47,7 +47,7 @@ particleAbility.startAbility(
{
want:
{
action: 'action.system.home',
action: 'ohos.want.action.home',
entities: ['entity.system.home'],
type: 'MIMETYPE',
flags: wantConstant.Flags.FLAG_AUTH_READ_URI_PERMISSION,
......@@ -57,8 +57,12 @@ particleAbility.startAbility(
uri: ''
},
},
(error, result) => {
console.error('particleAbility startAbility errCode: ${JSON.stringify(error)}, result: ${JSON.stringify(result)}');
(error, data) => {
if (error && error.code !== 0) {
console.error('startAbility fail, error: ${JSON.stringify(error)}');
} else {
console.log('startAbility success, data: ${JSON.stringify(data)}');
}
},
);
```
......@@ -98,7 +102,7 @@ particleAbility.startAbility(
{
want:
{
action: 'action.system.home',
action: 'ohos.want.action.home',
entities: ['entity.system.home'],
type: 'MIMETYPE',
flags: wantConstant.Flags.FLAG_AUTH_READ_URI_PERMISSION,
......@@ -133,8 +137,12 @@ Terminates this ParticleAbility. This API uses an asynchronous callback to retur
import particleAbility from '@ohos.ability.particleAbility';
particleAbility.terminateSelf(
(error, result) => {
console.log('particleAbility terminateSelf errCode: ${JSON.stringify(error)}, result: ${JSON.stringify(result)}');
(error, data) => {
if (error && error.code !== 0) {
console.error('terminateSelf fail, error: ${JSON.stringify(error)}');
} else {
console.log('terminateSelf success, data: ${JSON.stringify(data)}');
}
}
);
```
......@@ -226,11 +234,11 @@ import notification from '@ohos.notification';
import particleAbility from '@ohos.ability.particleAbility';
import wantAgent from '@ohos.app.ability.wantAgent';
function callback(err, data) {
if (err) {
console.error('Operation failed cause: ${JSON.stringify(err)}');
function callback(error, data) {
if (error && error.code !== 0) {
console.error('Operation failed error: ${JSON.stringify(error)}');
} else {
console.info('Operation succeeded');
console.info('Operation succeeded, data: ${data}');
}
}
......@@ -349,11 +357,11 @@ Requests to cancel a continuous task from the system. This API uses an asynchron
```ts
import particleAbility from '@ohos.ability.particleAbility';
function callback(err, data) {
if (err) {
console.error('Operation failed cause: ${JSON.stringify(err)}');
function callback(error, data) {
if (error && error.code !== 0) {
console.error('Operation failed error: ${JSON.stringify(error)}');
} else {
console.info('Operation succeeded');
console.info('Operation succeeded, data: ${data}');
}
}
......@@ -421,11 +429,11 @@ function onConnectCallback(element, remote) {
}
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.error('particleAbilityTest ConnectAbility onFailed errCode: ${code}');
}
let connId = particleAbility.connectAbility(
......@@ -441,9 +449,9 @@ let 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.error('particleAbilityTest result errCode: ${error.code}');
});
```
......@@ -472,11 +480,11 @@ function onConnectCallback(element, remote) {
}
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.error('particleAbilityTest ConnectAbility onFailed errCode: ${code}');
}
let connId = particleAbility.connectAbility(
......@@ -492,7 +500,7 @@ let connId = particleAbility.connectAbility(
);
particleAbility.disconnectAbility(connId, (err) => {
console.log('particleAbilityTest disconnectAbility err: ${JSON.stringify(err)}');
console.error('particleAbilityTest disconnectAbility err: ${JSON.stringify(err)}');
});
```
......@@ -522,11 +530,11 @@ function onConnectCallback(element, remote) {
}
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.error('particleAbilityTest ConnectAbility onFailed errCode: ${code}');
}
let connId = particleAbility.connectAbility(
......@@ -544,7 +552,7 @@ let connId = particleAbility.connectAbility(
particleAbility.disconnectAbility(connId).then((data) => {
console.log(' data: ${data}');
}).catch((error) => {
console.log('particleAbilityTest result errCode : ${error.code}');
console.error('particleAbilityTest result errCode : ${error.code}');
});
```
......
......@@ -35,8 +35,8 @@ Enumerates the initial ability launch reasons. You can use it together with [onC
| Name | Value | Description |
| ----------------------------- | ---- | ------------------------------------------------------------ |
| UNKNOWN | 0 | Unknown reason.|
| START_ABILITY | 1 | The ability is started by calling [startAbility](js-apis-ability-context.md#abilitycontextstartability).|
| CALL | 2 | The ability is started by calling [startAbilityByCall](js-apis-ability-context.md#abilitycontextstartabilitybycall).|
| START_ABILITY | 1 | The ability is started by calling [startAbility](js-apis-inner-application-uiAbilityContext.md#uiabilitycontextstartability).|
| CALL | 2 | The ability is started by calling [startAbilityByCall](js-apis-inner-application-uiAbilityContext.md#uiabilitycontextstartabilitybycall).|
| CONTINUATION | 3 | The ability is started by means of cross-device migration.|
| APP_RECOVERY | 4 | The ability is automatically started when the application is restored from a fault.|
......@@ -135,7 +135,7 @@ let option = {
this.context.startAbility(want, option).then(()={
console.log('Succeed to start ability.');
}).catch((error)=>{
console.log('Failed to start ability with error: ${JSON.stringify(error)}');
console.error('Failed to start ability with error: ${JSON.stringify(error)}');
});
```
......
......@@ -56,7 +56,7 @@ abilityDelegator.startAbility(want, (err) => {
if (!err || err.code === 0) {
console.log('Success start ability.');
} else {
console.log('Failed start ability, error: ${JSON.stringify(err)}');
console.error('Failed start ability, error: ${JSON.stringify(err)}');
}
});
```
......
......@@ -277,7 +277,7 @@ export default class MyFirstAbility extends UIAbility {
globalThis.lifecycleId = applicationContext.on('abilityLifecycle', abilityLifecycleCallback);
console.log('registerAbilityLifecycleCallback number: ${JSON.stringify(lifecycleId)}');
} catch (paramError) {
console.log('error: ${paramError.code}, ${paramError.message}');
console.error('error: ${paramError.code}, ${paramError.message}');
}
}
}
......@@ -293,7 +293,7 @@ export default class MySecondAbility extends UIAbility {
// 3. Deregister the listener for the ability lifecycle changes through the applicationContext object.
applicationContext.off('abilityLifecycle', globalThis.lifecycleId, (error) => {
if (error && error.code !== 0) {
console.log('unregisterAbilityLifecycleCallback fail, error: ${JSON.stringify(error)}');
console.error('unregisterAbilityLifecycleCallback fail, error: ${JSON.stringify(error)}');
} else {
console.log('unregisterAbilityLifecycleCallback success.');
}
......
......@@ -105,7 +105,7 @@ let observer = {
try {
errorManager.on('error', observer);
} catch (paramError) {
console.log('error: ${paramError.code}, ${paramError.message}');
console.error('error: ${paramError.code}, ${paramError.message}');
}
```
......@@ -139,6 +139,6 @@ let observer = {
try {
errorManager.on('error', observer);
} catch (paramError) {
console.log('error: ${paramError.code}, ${paramError.message}');
console.error('error: ${paramError.code}, ${paramError.message}');
}
```
......@@ -33,7 +33,7 @@ import StartOptions from '@ohos.app.ability.StartOptions';
try {
missionManager.getMissionInfos('', 10, (error, missions) => {
if (error.code) {
console.log('getMissionInfos failed, error.code: ${JSON.stringify(error.code)}, error.message: ${JSON.stringify(error.message)}');
console.error('getMissionInfos failed, error.code: ${JSON.stringify(error.code)}, error.message: ${JSON.stringify(error.message)}');
return;
}
console.log('size = ${missions.length}');
......@@ -49,6 +49,6 @@ import StartOptions from '@ohos.app.ability.StartOptions';
});
});
} catch (paramError) {
console.log('error: ${paramError.code}, ${paramError.message}');
console.error('error: ${paramError.code}, ${paramError.message}');
}
```
......@@ -136,7 +136,7 @@ import Want from '@ohos.app.ability.Want';
try {
fd = fileio.openSync('/data/storage/el2/base/haps/pic.png');
} catch(e) {
console.log('openSync fail: ${JSON.stringify(e)}');
console.error('openSync fail: ${JSON.stringify(e)}');
}
let want = {
'deviceId': '', // An empty deviceId indicates the local device.
......
......@@ -59,6 +59,6 @@ try {
};
formBindingData.createFormBindingData(obj);
} catch (error) {
console.log(`catch error, code: ${error.code}, message: ${error.message}`);
console.error(`catch error, code: ${error.code}, message: ${error.message}`);
}
```
......@@ -46,13 +46,13 @@ try {
let formId = '12400633174999288';
formHost.deleteForm(formId, (error) => {
if (error) {
console.log(`error, code: ${error.code}, message: ${error.message}`);
console.error(`error, code: ${error.code}, message: ${error.message}`);
} else {
console.log('formHost deleteForm success');
}
});
} catch (error) {
console.log(`catch error, code: ${error.code}, message: ${error.message}`);
console.error(`catch error, code: ${error.code}, message: ${error.message}`);
}
```
......@@ -96,10 +96,10 @@ try {
formHost.deleteForm(formId).then(() => {
console.log('formHost deleteForm success');
}).catch((error) => {
console.log(`error, code: ${error.code}, message: ${error.message}`);
console.error(`error, code: ${error.code}, message: ${error.message}`);
});
} catch(error) {
console.log(`catch error, code: ${error.code}, message: ${error.message}`);
console.error(`catch error, code: ${error.code}, message: ${error.message}`);
}
```
......@@ -136,11 +136,11 @@ try {
let formId = '12400633174999288';
formHost.releaseForm(formId, (error) => {
if (error) {
console.log(`error, code: ${error.code}, message: ${error.message}`);
console.error(`error, code: ${error.code}, message: ${error.message}`);
}
});
} catch(error) {
console.log(`catch error, code: ${error.code}, message: ${error.message}`);
console.error(`catch error, code: ${error.code}, message: ${error.message}`);
}
```
......@@ -178,11 +178,11 @@ try {
let formId = '12400633174999288';
formHost.releaseForm(formId, true, (error) => {
if (error) {
console.log(`error, code: ${error.code}, message: ${error.message}`);
console.error(`error, code: ${error.code}, message: ${error.message}`);
}
});
} catch(error) {
console.log(`catch error, code: ${error.code}, message: ${error.message}`);
console.error(`catch error, code: ${error.code}, message: ${error.message}`);
}
```
......@@ -226,10 +226,10 @@ try {
formHost.releaseForm(formId, true).then(() => {
console.log('formHost releaseForm success');
}).catch((error) => {
console.log(`error, code: ${error.code}, message: ${error.message}`);
console.error(`error, code: ${error.code}, message: ${error.message}`);
});
} catch(error) {
console.log(`catch error, code: ${error.code}, message: ${error.message}`);
console.error(`catch error, code: ${error.code}, message: ${error.message}`);
}
```
......@@ -266,11 +266,11 @@ try {
let formId = '12400633174999288';
formHost.requestForm(formId, (error) => {
if (error) {
console.log(`error, code: ${error.code}, message: ${error.message}`);
console.error(`error, code: ${error.code}, message: ${error.message}`);
}
});
} catch(error) {
console.log(`catch error, code: ${error.code}, message: ${error.message}`);
console.error(`catch error, code: ${error.code}, message: ${error.message}`);
}
```
......@@ -313,10 +313,10 @@ try {
formHost.requestForm(formId).then(() => {
console.log('formHost requestForm success');
}).catch((error) => {
console.log(`error, code: ${error.code}, message: ${error.message}`);
console.error(`error, code: ${error.code}, message: ${error.message}`);
});
} catch(error) {
console.log(`catch error, code: ${error.code}, message: ${error.message}`);
console.error(`catch error, code: ${error.code}, message: ${error.message}`);
}
```
......@@ -354,11 +354,11 @@ try {
let formId = '12400633174999288';
formHost.castToNormalForm(formId, (error) => {
if (error) {
console.log(`error, code: ${error.code}, message: ${error.message}`);
console.error(`error, code: ${error.code}, message: ${error.message}`);
}
});
} catch(error) {
console.log(`catch error, code: ${error.code}, message: ${error.message}`);
console.error(`catch error, code: ${error.code}, message: ${error.message}`);
}
```
......@@ -401,10 +401,10 @@ try {
formHost.castToNormalForm(formId).then(() => {
console.log('formHost castTempForm success');
}).catch((error) => {
console.log(`error, code: ${error.code}, message: ${error.message}`);
console.error(`error, code: ${error.code}, message: ${error.message}`);
});
} catch(error) {
console.log(`catch error, code: ${error.code}, message: ${error.message}`);
console.error(`catch error, code: ${error.code}, message: ${error.message}`);
}
```
......@@ -441,11 +441,11 @@ try {
let formId = ['12400633174999288'];
formHost.notifyVisibleForms(formId, (error) => {
if (error) {
console.log(`error, code: ${error.code}, message: ${error.message}`);
console.error(`error, code: ${error.code}, message: ${error.message}`);
}
});
} catch(error) {
console.log(`catch error, code: ${error.code}, message: ${error.message}`);
console.error(`catch error, code: ${error.code}, message: ${error.message}`);
}
```
......@@ -488,10 +488,10 @@ try {
formHost.notifyVisibleForms(formId).then(() => {
console.log('formHost notifyVisibleForms success');
}).catch((error) => {
console.log(`error, code: ${error.code}, message: ${error.message}`);
console.error(`error, code: ${error.code}, message: ${error.message}`);
});
} catch(error) {
console.log(`catch error, code: ${error.code}, message: ${error.message}`);
console.error(`catch error, code: ${error.code}, message: ${error.message}`);
}
```
......@@ -528,11 +528,11 @@ try {
let formId = ['12400633174999288'];
formHost.notifyInvisibleForms(formId, (error) => {
if (error) {
console.log(`error, code: ${error.code}, message: ${error.message}`);
console.error(`error, code: ${error.code}, message: ${error.message}`);
}
});
} catch(error) {
console.log(`catch error, code: ${error.code}, message: ${error.message}`);
console.error(`catch error, code: ${error.code}, message: ${error.message}`);
}
```
......@@ -575,10 +575,10 @@ try {
formHost.notifyInvisibleForms(formId).then(() => {
console.log('formHost notifyInvisibleForms success');
}).catch((error) => {
console.log(`error, code: ${error.code}, message: ${error.message}`);
console.error(`error, code: ${error.code}, message: ${error.message}`);
});
} catch(error) {
console.log(`catch error, code: ${error.code}, message: ${error.message}`);
console.error(`catch error, code: ${error.code}, message: ${error.message}`);
}
```
......@@ -615,11 +615,11 @@ try {
let formId = ['12400633174999288'];
formHost.enableFormsUpdate(formId, (error) => {
if (error) {
console.log(`error, code: ${error.code}, message: ${error.message}`);
console.error(`error, code: ${error.code}, message: ${error.message}`);
}
});
} catch(error) {
console.log(`catch error, code: ${error.code}, message: ${error.message}`);
console.error(`catch error, code: ${error.code}, message: ${error.message}`);
}
```
......@@ -662,10 +662,10 @@ try {
formHost.enableFormsUpdate(formId).then(() => {
console.log('formHost enableFormsUpdate success');
}).catch((error) => {
console.log(`error, code: ${error.code}, message: ${error.message}`);
console.error(`error, code: ${error.code}, message: ${error.message}`);
});
} catch(error) {
console.log(`catch error, code: ${error.code}, message: ${error.message}`);
console.error(`catch error, code: ${error.code}, message: ${error.message}`);
}
```
......@@ -702,11 +702,11 @@ try {
let formId = ['12400633174999288'];
formHost.disableFormsUpdate(formId, (error) => {
if (error) {
console.log(`error, code: ${error.code}, message: ${error.message}`);
console.error(`error, code: ${error.code}, message: ${error.message}`);
}
});
} catch(error) {
console.log(`catch error, code: ${error.code}, message: ${error.message}`);
console.error(`catch error, code: ${error.code}, message: ${error.message}`);
}
```
......@@ -749,10 +749,10 @@ try {
formHost.disableFormsUpdate(formId).then(() => {
console.log('formHost disableFormsUpdate success');
}).catch((error) => {
console.log(`error, code: ${error.code}, message: ${error.message}`);
console.error(`error, code: ${error.code}, message: ${error.message}`);
});
} catch(error) {
console.log(`catch error, code: ${error.code}, message: ${error.message}`);
console.error(`catch error, code: ${error.code}, message: ${error.message}`);
}
```
......@@ -778,11 +778,11 @@ import formHost from '@ohos.app.form.formHost';
try {
formHost.isSystemReady((error, data) => {
if (error) {
console.log(`error, code: ${error.code}, message: ${error.message}`);
console.error(`error, code: ${error.code}, message: ${error.message}`);
}
});
} catch(error) {
console.log(`catch error, code: ${error.code}, message: ${error.message}`);
console.error(`catch error, code: ${error.code}, message: ${error.message}`);
}
```
......@@ -809,10 +809,10 @@ try {
formHost.isSystemReady().then(() => {
console.log('formHost isSystemReady success');
}).catch((error) => {
console.log(`error, code: ${error.code}, message: ${error.message}`);
console.error(`error, code: ${error.code}, message: ${error.message}`);
});
} catch(error) {
console.log(`catch error, code: ${error.code}, message: ${error.message}`);
console.error(`catch error, code: ${error.code}, message: ${error.message}`);
}
```
......@@ -840,13 +840,13 @@ import formHost from '@ohos.app.form.formHost';
try {
formHost.getAllFormsInfo((error, data) => {
if (error) {
console.log(`error, code: ${error.code}, message: ${error.message}`);
console.error(`error, code: ${error.code}, message: ${error.message}`);
} else {
console.log('formHost getAllFormsInfo, data: ${JSON.stringify(data)}');
}
});
} catch(error) {
console.log(`catch error, code: ${error.code}, message: ${error.message}`);
console.error(`catch error, code: ${error.code}, message: ${error.message}`);
}
```
......@@ -875,10 +875,10 @@ try {
formHost.getAllFormsInfo().then((data) => {
console.log('formHost getAllFormsInfo data: ${JSON.stringify(data)}');
}).catch((error) => {
console.log(`error, code: ${error.code}, message: ${error.message}`);
console.error(`error, code: ${error.code}, message: ${error.message}`);
});
} catch(error) {
console.log(`catch error, code: ${error.code}, message: ${error.message}`);
console.error(`catch error, code: ${error.code}, message: ${error.message}`);
}
```
......@@ -914,13 +914,13 @@ import formHost from '@ohos.app.form.formHost';
try {
formHost.getFormsInfo('com.example.ohos.formjsdemo', (error, data) => {
if (error) {
console.log(`error, code: ${error.code}, message: ${error.message}`);
console.error(`error, code: ${error.code}, message: ${error.message}`);
} else {
console.log('formHost getFormsInfo, data: ${JSON.stringify(data)}');
}
});
} catch(error) {
console.log(`catch error, code: ${error.code}, message: ${error.message}`);
console.error(`catch error, code: ${error.code}, message: ${error.message}`);
}
```
......@@ -957,13 +957,13 @@ import formHost from '@ohos.app.form.formHost';
try {
formHost.getFormsInfo('com.example.ohos.formjsdemo', 'entry', (error, data) => {
if (error) {
console.log(`error, code: ${error.code}, message: ${error.message}`);
console.error(`error, code: ${error.code}, message: ${error.message}`);
} else {
console.log('formHost getFormsInfo, data: ${JSON.stringify(data)}');
}
});
} catch(error) {
console.log(`catch error, code: ${error.code}, message: ${error.message}`);
console.error(`catch error, code: ${error.code}, message: ${error.message}`);
}
```
......@@ -1006,10 +1006,10 @@ try {
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}`);
console.error(`error, code: ${error.code}, message: ${error.message}`);
});
} catch(error) {
console.log(`catch error, code: ${error.code}, message: ${error.message}`);
console.error(`catch error, code: ${error.code}, message: ${error.message}`);
}
```
......@@ -1039,13 +1039,13 @@ try {
let formIds = new Array('12400633174999288', '12400633174999289');
formHost.deleteInvalidForms(formIds, (error, data) => {
if (error) {
console.log(`error, code: ${error.code}, message: ${error.message}`);
console.error(`error, code: ${error.code}, message: ${error.message}`);
} else {
console.log('formHost deleteInvalidForms, data: ${JSON.stringify(data)}');
}
});
} catch(error) {
console.log(`catch error, code: ${error.code}, message: ${error.message}`);
console.error(`catch error, code: ${error.code}, message: ${error.message}`);
}
```
......@@ -1081,10 +1081,10 @@ try {
formHost.deleteInvalidForms(formIds).then((data) => {
console.log('formHost deleteInvalidForms, data: ${JSON.stringify(data)}');
}).catch((error) => {
console.log(`error, code: ${error.code}, message: ${error.message}`);
console.error(`error, code: ${error.code}, message: ${error.message}`);
});
} catch(error) {
console.log(`catch error, code: ${error.code}, message: ${error.message}`);
console.error(`catch error, code: ${error.code}, message: ${error.message}`);
}
```
......@@ -1130,13 +1130,13 @@ let want = {
try {
formHost.acquireFormState(want, (error, data) => {
if (error) {
console.log(`error, code: ${error.code}, message: ${error.message}`);
console.error(`error, code: ${error.code}, message: ${error.message}`);
} else {
console.log('formHost acquireFormState, data: ${JSON.stringify(data)}');
}
});
} catch(error) {
console.log(`catch error, code: ${error.code}, message: ${error.message}`);
console.error(`catch error, code: ${error.code}, message: ${error.message}`);
}
```
......@@ -1188,10 +1188,10 @@ try {
formHost.acquireFormState(want).then((data) => {
console.log('formHost acquireFormState, data: ${JSON.stringify(data)}');
}).catch((error) => {
console.log(`error, code: ${error.code}, message: ${error.message}`);
console.error(`error, code: ${error.code}, message: ${error.message}`);
});
} catch(error) {
console.log(`catch error, code: ${error.code}, message: ${error.message}`);
console.error(`catch error, code: ${error.code}, message: ${error.message}`);
}
```
......@@ -1281,11 +1281,11 @@ let formIds = new Array('12400633174999288', '12400633174999289');
try {
formHost.notifyFormsVisible(formIds, true, (error) => {
if (error) {
console.log(`error, code: ${error.code}, message: ${error.message}`);
console.error(`error, code: ${error.code}, message: ${error.message}`);
}
});
} catch(error) {
console.log(`catch error, code: ${error.code}, message: ${error.message}`);
console.error(`catch error, code: ${error.code}, message: ${error.message}`);
}
```
......@@ -1329,10 +1329,10 @@ try {
formHost.notifyFormsVisible(formIds, true).then(() => {
console.log('formHost notifyFormsVisible success');
}).catch((error) => {
console.log(`error, code: ${error.code}, message: ${error.message}`);
console.error(`error, code: ${error.code}, message: ${error.message}`);
});
} catch(error) {
console.log(`catch error, code: ${error.code}, message: ${error.message}`);
console.error(`catch error, code: ${error.code}, message: ${error.message}`);
}
```
......@@ -1370,11 +1370,11 @@ let formIds = new Array('12400633174999288', '12400633174999289');
try {
formHost.notifyFormsEnableUpdate(formIds, true, (error) => {
if (error) {
console.log(`error, code: ${error.code}, message: ${error.message}`);
console.error(`error, code: ${error.code}, message: ${error.message}`);
}
});
} catch(error) {
console.log(`catch error, code: ${error.code}, message: ${error.message}`);
console.error(`catch error, code: ${error.code}, message: ${error.message}`);
}
```
......@@ -1418,10 +1418,10 @@ try {
formHost.notifyFormsEnableUpdate(formIds, true).then(() => {
console.log('formHost notifyFormsEnableUpdate success');
}).catch((error) => {
console.log(`error, code: ${error.code}, message: ${error.message}`);
console.error(`error, code: ${error.code}, message: ${error.message}`);
});
} catch(error) {
console.log(`catch error, code: ${error.code}, message: ${error.message}`);
console.error(`catch error, code: ${error.code}, message: ${error.message}`);
}
```
## shareForm
......@@ -1459,11 +1459,11 @@ let deviceId = 'EFC11C0C53628D8CC2F8CB5052477E130D075917034613B9884C55CD22B3DEF2
try {
formHost.shareForm(formId, deviceId, (error) => {
if (error) {
console.log(`error, code: ${error.code}, message: ${error.message}`);
console.error(`error, code: ${error.code}, message: ${error.message}`);
}
});
} catch(error) {
console.log(`catch error, code: ${error.code}, message: ${error.message}`);
console.error(`catch error, code: ${error.code}, message: ${error.message}`);
}
```
......@@ -1508,10 +1508,10 @@ try {
formHost.shareForm(formId, deviceId).then(() => {
console.log('formHost shareForm success');
}).catch((error) => {
console.log(`error, code: ${error.code}, message: ${error.message}`);
console.error(`error, code: ${error.code}, message: ${error.message}`);
});
} catch(error) {
console.log(`catch error, code: ${error.code}, message: ${error.message}`);
console.error(`catch error, code: ${error.code}, message: ${error.message}`);
}
```
......@@ -1549,11 +1549,11 @@ let formIds = new Array('12400633174999288', '12400633174999289');
try {
formHost.notifyFormsPrivacyProtected(formIds, true, (error) => {
if (error) {
console.log(`error, code: ${error.code}, message: ${error.message}`);
console.error(`error, code: ${error.code}, message: ${error.message}`);
}
});
} catch(error) {
console.log(`catch error, code: ${error.code}, message: ${error.message}`);
console.error(`catch error, code: ${error.code}, message: ${error.message}`);
}
```
......@@ -1595,9 +1595,9 @@ try {
formHost.notifyFormsPrivacyProtected(formIds, true).then(() => {
console.log('formHost notifyFormsPrivacyProtected success');
}).catch((error) => {
console.log(`error, code: ${error.code}, message: ${error.message}`);
console.error(`error, code: ${error.code}, message: ${error.message}`);
});
} catch(error) {
console.log(`catch error, code: ${error.code}, message: ${error.message}`);
console.error(`catch error, code: ${error.code}, message: ${error.message}`);
}
```
......@@ -43,13 +43,13 @@ let formId = '12400633174999288';
try {
formProvider.setFormNextRefreshTime(formId, 5, (error, data) => {
if (error) {
console.log(`callback error, code: ${error.code}, message: ${error.message})`);
console.error(`callback error, code: ${error.code}, message: ${error.message})`);
} else {
console.log(`formProvider setFormNextRefreshTime success`);
}
});
} catch (error) {
console.log(`catch error, code: ${error.code}, message: ${error.message})`);
console.error(`catch error, code: ${error.code}, message: ${error.message})`);
}
```
......@@ -91,10 +91,10 @@ try {
formProvider.setFormNextRefreshTime(formId, 5).then(() => {
console.log(`formProvider setFormNextRefreshTime success`);
}).catch((error) => {
console.log(`promise error, code: ${error.code}, message: ${error.message})`);
console.error(`promise error, code: ${error.code}, message: ${error.message})`);
});
} catch (error) {
console.log(`catch error, code: ${error.code}, message: ${error.message})`);
console.error(`catch error, code: ${error.code}, message: ${error.message})`);
}
```
......@@ -132,13 +132,13 @@ try {
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})`);
console.error(`callback error, code: ${error.code}, message: ${error.message})`);
} else {
console.log(`formProvider updateForm success`);
}
});
} catch (error) {
console.log(`catch error, code: ${error.code}, message: ${error.message})`);
console.error(`catch error, code: ${error.code}, message: ${error.message})`);
}
```
......@@ -182,10 +182,10 @@ try {
formProvider.updateForm(formId, obj).then(() => {
console.log(`formProvider updateForm success`);
}).catch((error) => {
console.log(`promise error, code: ${error.code}, message: ${error.message})`);
console.error(`promise error, code: ${error.code}, message: ${error.message})`);
});
} catch (error) {
console.log(`catch error, code: ${error.code}, message: ${error.message})`);
console.error(`catch error, code: ${error.code}, message: ${error.message})`);
}
```
......@@ -219,13 +219,13 @@ import formProvider from '@ohos.app.form.formProvider';
try {
formProvider.getFormsInfo((error, data) => {
if (error) {
console.log(`callback error, code: ${error.code}, message: ${error.message})`);
console.error(`callback error, code: ${error.code}, message: ${error.message})`);
} else {
console.log('formProvider getFormsInfo, data: ${JSON.stringify(data)}');
}
});
} catch (error) {
console.log(`catch error, code: ${error.code}, message: ${error.message})`);
console.error(`catch error, code: ${error.code}, message: ${error.message})`);
}
```
## getFormsInfo
......@@ -263,13 +263,13 @@ const filter: formInfo.FormInfoFilter = {
try {
formProvider.getFormsInfo(filter, (error, data) => {
if (error) {
console.log(`callback error, code: ${error.code}, message: ${error.message})`);
console.error(`callback error, code: ${error.code}, message: ${error.message})`);
} else {
console.log('formProvider getFormsInfo, data: ${JSON.stringify(data)}');
}
});
} catch (error) {
console.log(`catch error, code: ${error.code}, message: ${error.message})`);
console.error(`catch error, code: ${error.code}, message: ${error.message})`);
}
```
......@@ -314,10 +314,10 @@ try {
formProvider.getFormsInfo(filter).then((data) => {
console.log('formProvider getFormsInfo, data: ${JSON.stringify(data)}');
}).catch((error) => {
console.log(`promise error, code: ${error.code}, message: ${error.message})`);
console.error(`promise error, code: ${error.code}, message: ${error.message})`);
});
} catch (error) {
console.log(`catch error, code: ${error.code}, message: ${error.message})`);
console.error(`catch error, code: ${error.code}, message: ${error.message})`);
}
```
......@@ -364,13 +364,13 @@ try {
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})`);
console.error(`callback error, code: ${error.code}, message: ${error.message})`);
} else {
console.log('formProvider requestPublishForm, form ID is: ${JSON.stringify(data)}');
}
});
} catch (error) {
console.log(`catch error, code: ${error.code}, message: ${error.message})`);
console.error(`catch error, code: ${error.code}, message: ${error.message})`);
}
```
......@@ -414,13 +414,13 @@ let want = {
try {
formProvider.requestPublishForm(want, (error, data) => {
if (error) {
console.log(`callback error, code: ${error.code}, message: ${error.message})`);
console.error(`callback error, code: ${error.code}, message: ${error.message})`);
} else {
console.log('formProvider requestPublishForm, form ID is: ${JSON.stringify(data)}');
}
});
} catch (error) {
console.log(`catch error, code: ${error.code}, message: ${error.message})`);
console.error(`catch error, code: ${error.code}, message: ${error.message})`);
}
```
......@@ -471,10 +471,10 @@ try {
formProvider.requestPublishForm(want).then((data) => {
console.log('formProvider requestPublishForm success, form ID is : ${JSON.stringify(data)}');
}).catch((error) => {
console.log(`promise error, code: ${error.code}, message: ${error.message})`);
console.error(`promise error, code: ${error.code}, message: ${error.message})`);
});
} catch (error) {
console.log(`catch error, code: ${error.code}, message: ${error.message})`);
console.error(`catch error, code: ${error.code}, message: ${error.message})`);
}
```
......@@ -502,7 +502,7 @@ import formProvider from '@ohos.app.form.formProvider';
try {
formProvider.isRequestPublishFormSupported((error, isSupported) => {
if (error) {
console.log(`callback error, code: ${error.code}, message: ${error.message})`);
console.error(`callback error, code: ${error.code}, message: ${error.message})`);
} else {
if (isSupported) {
var want = {
......@@ -516,19 +516,19 @@ try {
try {
formProvider.requestPublishForm(want, (error, data) => {
if (error) {
console.log(`callback error, code: ${error.code}, message: ${error.message})`);
console.error(`callback error, code: ${error.code}, message: ${error.message})`);
} else {
console.log('formProvider requestPublishForm, form ID is: ${JSON.stringify(data)}');
}
});
} catch (error) {
console.log(`catch error, code: ${error.code}, message: ${error.message})`);
console.error(`catch error, code: ${error.code}, message: ${error.message})`);
}
}
}
});
} catch (error) {
console.log(`catch error, code: ${error.code}, message: ${error.message})`);
console.error(`catch error, code: ${error.code}, message: ${error.message})`);
}
```
......@@ -568,16 +568,16 @@ try {
formProvider.requestPublishForm(want).then((data) => {
console.log('formProvider requestPublishForm success, form ID is : ${JSON.stringify(data)}');
}).catch((error) => {
console.log(`promise error, code: ${error.code}, message: ${error.message})`);
console.error(`promise error, code: ${error.code}, message: ${error.message})`);
});
} catch (error) {
console.log(`catch error, code: ${error.code}, message: ${error.message})`);
console.error(`catch error, code: ${error.code}, message: ${error.message})`);
}
}
}).catch((error) => {
console.log(`promise error, code: ${error.code}, message: ${error.message})`);
console.error(`promise error, code: ${error.code}, message: ${error.message})`);
});
} catch (error) {
console.log(`catch error, code: ${error.code}, message: ${error.message})`);
console.error(`catch error, code: ${error.code}, message: ${error.message})`);
}
```
......@@ -90,7 +90,7 @@ let config = {
abilityManager.updateConfiguration(config).then(() => {
console.log('updateConfiguration success');
}).catch((err) => {
console.log('updateConfiguration fail');
console.error('updateConfiguration fail');
});
```
......@@ -140,6 +140,6 @@ Obtains the ability running information. This API uses a promise to return the r
abilityManager.getAbilityRunningInfos().then((data) => {
console.log('getAbilityRunningInfos data: ${JSON.stringify(data)}');
}).catch((err) => {
console.log('getAbilityRunningInfos err: ${JSON.stringify(err)}');
console.error('getAbilityRunningInfos err: ${JSON.stringify(err)}');
});
```
......@@ -59,6 +59,6 @@ try {
};
formBindingData.createFormBindingData(obj);
} catch (error) {
console.log('catch error, error: ${JSON.stringify(error)}');
console.error('catch error, error: ${JSON.stringify(error)}');
}
```
......@@ -36,7 +36,7 @@ Sets the next refresh time for a widget. This API uses an asynchronous callback
let formId = '12400633174999288';
formProvider.setFormNextRefreshTime(formId, 5, (error, data) => {
if (error.code) {
console.log('formProvider setFormNextRefreshTime, error: ${JSON.stringify(error)}');
console.error('formProvider setFormNextRefreshTime, error: ${JSON.stringify(error)}');
}
});
```
......@@ -71,7 +71,7 @@ Sets the next refresh time for a widget. This API uses a promise to return the r
formProvider.setFormNextRefreshTime(formId, 5).then(() => {
console.log('formProvider setFormNextRefreshTime success');
}).catch((error) => {
console.log('formProvider setFormNextRefreshTime, error: ${JSON.stringify(error)}');
console.error('formProvider setFormNextRefreshTime, error: ${JSON.stringify(error)}');
});
```
......@@ -101,7 +101,7 @@ Updates a widget. This API uses an asynchronous callback to return the result.
let obj = formBindingData.createFormBindingData({temperature:'22c', time:'22:00'});
formProvider.updateForm(formId, obj, (error, data) => {
if (error.code) {
console.log('formProvider updateForm, error: ${JSON.stringify(error)}');
console.error('formProvider updateForm, error: ${JSON.stringify(error)}');
}
});
```
......@@ -138,6 +138,6 @@ Updates a widget. This API uses a promise to return the result.
formProvider.updateForm(formId, obj).then(() => {
console.log('formProvider updateForm success');
}).catch((error) => {
console.log('formProvider updateForm, error: ${JSON.stringify(error)}');
console.error('formProvider updateForm, error: ${JSON.stringify(error)}');
});
```
......@@ -25,7 +25,7 @@ import Want from '@ohos.application.Want';
| 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.<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. |
| 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.|
......@@ -42,7 +42,7 @@ import Want from '@ohos.application.Want';
};
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.error('error.code = ${error.code}');
});
```
......@@ -114,7 +114,7 @@ import Want from '@ohos.application.Want';
try {
fd = fileio.openSync('/data/storage/el2/base/haps/pic.png');
} catch(e) {
console.log('openSync fail: ${JSON.stringify(e)}');
console.error('openSync fail: ${JSON.stringify(e)}');
}
let want = {
'deviceId': '', // An empty deviceId indicates the local device.
......@@ -127,7 +127,7 @@ import Want from '@ohos.application.Want';
};
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.error('error.code = ${error.code}');
});
```
......
......@@ -39,8 +39,12 @@ let DAHelper = featureAbility.acquireDataAbilityHelper(
'dataability:///com.example.DataAbility'
);
let mode = 'rw';
DAHelper.openFile('dataability:///com.example.DataAbility', mode, (err, data) => {
console.info('openFile err: ${JSON.stringify(err)}, data: ${JSON.stringify(data)}');
DAHelper.openFile('dataability:///com.example.DataAbility', mode, (error, data) => {
if (error && error.code !== 0) {
console.error('openFile fail, error: ${JSON.stringify(error)}');
} else {
console.log('openFile success, data: ${JSON.stringify(data)}');
}
});
```
......@@ -170,8 +174,12 @@ import featureAbility from '@ohos.ability.featureAbility';
let DAHelper = featureAbility.acquireDataAbilityHelper(
'dataability:///com.example.DataAbility'
);
DAHelper.getType('dataability:///com.example.DataAbility', (err, data) => {
console.info('getType err: ${JSON.stringify(err)}, data: ${JSON.stringify(data)}');
DAHelper.getType('dataability:///com.example.DataAbility', (error, data) => {
if (error && error.code !== 0) {
console.error('getType fail, error: ${JSON.stringify(error)}');
} else {
console.log('getType success, data: ${JSON.stringify(data)}');
}
});
```
......@@ -230,8 +238,12 @@ import featureAbility from '@ohos.ability.featureAbility';
let DAHelper = featureAbility.acquireDataAbilityHelper(
'dataability:///com.example.DataAbility'
);
DAHelper.getFileTypes( 'dataability:///com.example.DataAbility', 'image/*', (err, data) => {
console.info('getFileTypes err: ${JSON.stringify(err)}, data: ${JSON.stringify(data)}');
DAHelper.getFileTypes( 'dataability:///com.example.DataAbility', 'image/*', (error, data) => {
if (error && error.code !== 0) {
console.error('getFileTypes fail, error: ${JSON.stringify(error)}');
} else {
console.log('getFileTypes success, data: ${JSON.stringify(data)}');
}
});
```
......@@ -290,8 +302,12 @@ import featureAbility from '@ohos.ability.featureAbility';
let DAHelper = featureAbility.acquireDataAbilityHelper(
'dataability:///com.example.DataAbility'
);
DAHelper.normalizeUri('dataability:///com.example.DataAbility', (err, data) => {
console.info('normalizeUri err: ${JSON.stringify(err)}, data: ${JSON.stringify(data)}');
DAHelper.normalizeUri('dataability:///com.example.DataAbility', (error, data) => {
if (error && error.code !== 0) {
console.error('normalizeUri fail, error: ${JSON.stringify(error)}');
} else {
console.log('normalizeUri success, data: ${JSON.stringify(data)}');
}
});
```
......@@ -349,8 +365,12 @@ import featureAbility from '@ohos.ability.featureAbility';
let DAHelper = featureAbility.acquireDataAbilityHelper(
'dataability:///com.example.DataAbility'
);
DAHelper.denormalizeUri('dataability:///com.example.DataAbility', (err, data) => {
console.info('denormalizeUri err: ${JSON.stringify(err)}, data: ${JSON.stringify(data)}');
DAHelper.denormalizeUri('dataability:///com.example.DataAbility', (error, data) => {
if (error && error.code !== 0) {
console.error('denormalizeUri fail, error: ${JSON.stringify(error)}');
} else {
console.log('denormalizeUri success, data: ${JSON.stringify(data)}');
}
});
```
......@@ -408,8 +428,12 @@ import featureAbility from '@ohos.ability.featureAbility';
let DAHelper = featureAbility.acquireDataAbilityHelper(
'dataability:///com.example.DataAbility'
);
DAHelper.notifyChange('dataability:///com.example.DataAbility', (err) => {
console.info('==========================>Called=======================>');
DAHelper.notifyChange('dataability:///com.example.DataAbility', (error) => {
if (error && error.code !== 0) {
console.error('notifyChange fail, error: ${JSON.stringify(error)}');
} else {
console.log('notifyChange success');
}
});
```
......@@ -474,8 +498,12 @@ const valueBucket = {
'salary': 200.5,
'blobType': 'u8',
};
DAHelper.insert('dataability:///com.example.DataAbility', valueBucket, (err, data) => {
console.info('insert err: ${JSON.stringify(err)}, data: ${JSON.stringify(data)}');
DAHelper.insert('dataability:///com.example.DataAbility', valueBucket, (error, data) => {
if (error && error.code !== 0) {
console.error('insert fail, error: ${JSON.stringify(error)}');
} else {
console.log('insert success, data: ${JSON.stringify(data)}');
}
});
```
......@@ -544,8 +572,12 @@ let DAHelper = featureAbility.acquireDataAbilityHelper(
let cars = new Array({'name': 'roe11', 'age': 21, 'salary': 20.5, 'blobType': 'u8',},
{'name': 'roe12', 'age': 21, 'salary': 20.5, 'blobType': 'u8',},
{'name': 'roe13', 'age': 21, 'salary': 20.5, 'blobType': 'u8',});
DAHelper.batchInsert('dataability:///com.example.DataAbility', cars, (err, data) => {
console.info('batchInsert err: ${JSON.stringify(err)}, data: ${JSON.stringify(data)}');
DAHelper.batchInsert('dataability:///com.example.DataAbility', cars, (error, data) => {
if (error && error.code !== 0) {
console.error('batchInsert fail, error: ${JSON.stringify(error)}');
} else {
console.log('batchInsert success, data: ${JSON.stringify(data)}');
}
});
```
......@@ -610,8 +642,12 @@ let DAHelper = featureAbility.acquireDataAbilityHelper(
'dataability:///com.example.DataAbility'
);
let da = new ohos_data_ability.DataAbilityPredicates();
DAHelper.delete('dataability:///com.example.DataAbility', da, (err, data) => {
console.info('delete err: ${JSON.stringify(err)}, data: ${JSON.stringify(data)}');
DAHelper.delete('dataability:///com.example.DataAbility', da, (error, data) => {
if (error && error.code !== 0) {
console.error('delete fail, error: ${JSON.stringify(error)}');
} else {
console.log('delete success, data: ${JSON.stringify(data)}');
}
});
```
......@@ -682,8 +718,12 @@ const va = {
'blobType': 'u8',
};
let da = new ohos_data_ability.DataAbilityPredicates();
DAHelper.update('dataability:///com.example.DataAbility', va, da, (err, data) => {
console.info('update err: ${JSON.stringify(err)}, data: ${JSON.stringify(data)}');
DAHelper.update('dataability:///com.example.DataAbility', va, da, (error, data) => {
if (error && error.code !== 0) {
console.error('update fail, error: ${JSON.stringify(error)}');
} else {
console.log('update success, data: ${JSON.stringify(data)}');
}
});
```
......@@ -756,8 +796,12 @@ let DAHelper = featureAbility.acquireDataAbilityHelper(
);
let cars=new Array('value1', 'value2', 'value3', 'value4');
let da = new ohos_data_ability.DataAbilityPredicates();
DAHelper.query('dataability:///com.example.DataAbility', cars, da, (err, data) => {
console.info('query err: ${JSON.stringify(err)}, data: ${JSON.stringify(data)}');
DAHelper.query('dataability:///com.example.DataAbility', cars, da, (error, data) => {
if (error && error.code !== 0) {
console.error('query fail, error: ${JSON.stringify(error)}');
} else {
console.log('query success, data: ${JSON.stringify(data)}');
}
});
```
......@@ -827,12 +871,12 @@ let dataAbilityHelper = featureAbility.acquireDataAbilityHelper(
'dataability:///com.example.jsapidemo.UserDataAbility'
);
dataAbilityHelper.call('dataability:///com.example.jsapidemo.UserDataAbility',
'method', 'arg', {'key1':'value1'}, (err, data) => {
if (err) {
console.error('Operation failed. Cause: ${err}');
return;
'method', 'arg', {'key1':'value1'}, (error, data) => {
if (error && error.code !== 0) {
console.error('call fail, error: ${JSON.stringify(error)}');
} else {
console.log('call success, data: ${JSON.stringify(data)}');
}
console.info('Operation succeeded: ${data}');
});
```
......@@ -869,9 +913,9 @@ let dataAbilityHelper = featureAbility.acquireDataAbilityHelper(
);
dataAbilityHelper.call('dataability:///com.example.jsapidemo.UserDataAbility',
'method', 'arg', {'key1':'value1'}).then((data) => {
console.info('Operation succeeded: ${data}');
console.info('call success, data: ${data}');
}).catch((error) => {
console.error('Operation failed. Cause: ${error}');
console.error('call failed, error: ${error}');
});
```
......@@ -901,12 +945,12 @@ let op=new Array();
let dataAbilityHelper = featureAbility.acquireDataAbilityHelper(
'dataability:///com.example.jsapidemo.UserDataAbility'
);
dataAbilityHelper.executeBatch('dataability:///com.example.jsapidemo.UserDataAbility', op, (err, data) => {
if (err) {
console.error('Operation failed. Cause: ${err}');
return;
dataAbilityHelper.executeBatch('dataability:///com.example.jsapidemo.UserDataAbility', op, (error, data) => {
if (error && error.code !== 0) {
console.error('executeBatch fail, error: ${JSON.stringify(error)}');
} else {
console.log('executeBatch success, data: ${JSON.stringify(data)}');
}
console.info('Operation succeeded: ${data}');
});
```
......@@ -942,9 +986,9 @@ let dataAbilityHelper = featureAbility.acquireDataAbilityHelper(
'dataability:///com.example.jsapidemo.UserDataAbility'
);
dataAbilityHelper.executeBatch('dataability:///com.example.jsapidemo.UserDataAbility', op).then((data) => {
console.info('Operation succeeded: ${data}');
console.info('executeBatch success, data: ${data}');
}).catch((error) => {
console.error('Operation failed. Cause: ${error}');
console.error('executeBatch failed, error: ${error}');
});
```
......
......@@ -36,11 +36,14 @@ let startAbilityParameter = {
};
try {
featureAbility.startAbility(startAbilityParameter, (err, data) => {
console.log('errCode : ${JSON.stringify(err)}');
console.log('data : ${JSON.stringify(data)}');
featureAbility.startAbility(startAbilityParameter, (error, data) => {
if (error && error.code !== 0) {
console.error('startAbility fail, error: ${JSON.stringify(error)}');
} else {
console.log('startAbility success, data: ${JSON.stringify(data)}');
}
});
} catch(error) {
console.log('startAbility error: ${JSON.stringify(error)}');
console.error('startAbility error: ${JSON.stringify(error)}');
}
```
......@@ -41,8 +41,12 @@ If this API is called for the first time, a root directory will be created.
```ts
import featureAbility from '@ohos.ability.featureAbility';
let context = featureAbility.getContext();
context.getOrCreateLocalDir((err, data)=>{
console.info('getOrCreateLocalDir err: ${JSON.stringify(err)}, data: ${JSON.stringify(data)}');
context.getOrCreateLocalDir((error, data)=>{
if (error && error.code !== 0) {
console.error('getOrCreateLocalDir fail, error: ${JSON.stringify(error)}');
} else {
console.log('getOrCreateLocalDir success, data: ${JSON.stringify(data)}');
}
});
```
......@@ -97,8 +101,12 @@ import featureAbility from '@ohos.ability.featureAbility';
import bundle from '@ohos.bundle.bundleManager';
let context = featureAbility.getContext();
bundle.getBundleInfo('com.context.test', 1, (err, datainfo) =>{
context.verifyPermission('com.example.permission', {uid:datainfo.appInfo.uid}, (err, data) =>{
console.info('verifyPermission err: ${JSON.stringify(err)}, data: ${JSON.stringify(data)}');
context.verifyPermission('com.example.permission', {uid:datainfo.appInfo.uid}, (error, data) =>{
if (error && error.code !== 0) {
console.error('verifyPermission fail, error: ${JSON.stringify(error)}');
} else {
console.log('verifyPermission success, data: ${JSON.stringify(data)}');
}
});
});
```
......@@ -126,8 +134,12 @@ Verifies whether the current PID and UID have the given permission. This API use
```ts
import featureAbility from '@ohos.ability.featureAbility';
let context = featureAbility.getContext();
context.verifyPermission('com.example.permission', (err, data) =>{
console.info('verifyPermission err: ${JSON.stringify(err)}, data: ${JSON.stringify(data)}');
context.verifyPermission('com.example.permission', (error, data) =>{
if (error && error.code !== 0) {
console.error('verifyPermission fail, error: ${JSON.stringify(error)}');
} else {
console.log('verifyPermission success, data: ${JSON.stringify(data)}');
}
});
```
......@@ -193,8 +205,12 @@ context.requestPermissionsFromUser(
'com.example.permission4',
'com.example.permission5'],
1,
(err, data) => {
console.info('requestPermissionsFromUser err: ${JSON.stringify(err)}, data: ${JSON.stringify(data)}');
(error, data) => {
if (error && error.code !== 0) {
console.error('requestPermissionsFromUser fail, error: ${JSON.stringify(error)}');
} else {
console.log('requestPermissionsFromUser success, data: ${JSON.stringify(data)}');
}
}
);
```
......@@ -259,8 +275,12 @@ Obtains information about the current application. This API uses an asynchronous
```ts
import featureAbility from '@ohos.ability.featureAbility';
let context = featureAbility.getContext();
context.getApplicationInfo((err, data) => {
console.info('getApplicationInfo err: ${JSON.stringify(err)}, data: ${JSON.stringify(data)}');
context.getApplicationInfo((error, data) => {
if (error && error.code !== 0) {
console.error('getApplicationInfo fail, error: ${JSON.stringify(error)}');
} else {
console.log('getApplicationInfo success, data: ${JSON.stringify(data)}');
}
});
```
......@@ -311,8 +331,12 @@ Obtains the bundle name of this ability. This API uses an asynchronous callback
```ts
import featureAbility from '@ohos.ability.featureAbility';
let context = featureAbility.getContext();
context.getBundleName((err, data) => {
console.info('getBundleName err: ${JSON.stringify(err)}, data: ${JSON.stringify(data)}');
context.getBundleName((error, data) => {
if (error && error.code !== 0) {
console.error('getBundleName fail, error: ${JSON.stringify(error)}');
} else {
console.log('getBundleName success, data: ${JSON.stringify(data)}');
}
});
```
......@@ -361,8 +385,12 @@ Obtains the display orientation of this ability. This API uses an asynchronous c
```ts
import featureAbility from '@ohos.ability.featureAbility';
let context = featureAbility.getContext();
context.getDisplayOrientation((err, data) => {
console.info('getDisplayOrientation err: ${JSON.stringify(err)}, data: ${JSON.stringify(data)}');
context.getDisplayOrientation((error, data) => {
if (error && error.code !== 0) {
console.error('getDisplayOrientation fail, error: ${JSON.stringify(error)}');
} else {
console.log('getDisplayOrientation success, data: ${JSON.stringify(data)}');
}
});
```
......@@ -409,8 +437,12 @@ Obtains the external cache directory of the application. This API uses an asynch
```ts
import featureAbility from '@ohos.ability.featureAbility';
let context = featureAbility.getContext();
context.getExternalCacheDir((err, data) => {
console.info('getExternalCacheDir err: ${JSON.stringify(err)}, data: ${JSON.stringify(data)}');
context.getExternalCacheDir((error, data) => {
if (error && error.code !== 0) {
console.error('getExternalCacheDir fail, error: ${JSON.stringify(error)}');
} else {
console.log('getExternalCacheDir success, data: ${JSON.stringify(data)}');
}
});
```
......@@ -460,8 +492,8 @@ import featureAbility from '@ohos.ability.featureAbility';
import bundle from '@ohos.bundle';
let context = featureAbility.getContext();
let orientation = bundle.DisplayOrientation.UNSPECIFIED;
context.setDisplayOrientation(orientation, (err) => {
console.info('setDisplayOrientation err: ${JSON.stringify(err)}');
context.setDisplayOrientation(orientation, (error) => {
console.error('setDisplayOrientation fail, error: ${JSON.stringify(error)}');
});
```
......@@ -513,8 +545,8 @@ Sets whether to show this feature at the top of the lock screen so that the feat
import featureAbility from '@ohos.ability.featureAbility';
let context = featureAbility.getContext();
let show = true;
context.setShowOnLockScreen(show, (err) => {
console.info('setShowOnLockScreen err: ${JSON.stringify(err)}');
context.setShowOnLockScreen(show, (error) => {
console.error('setShowOnLockScreen fail, error: ${JSON.stringify(error)}');
});
```
......@@ -570,8 +602,8 @@ Sets whether to wake up the screen when this feature is restored. This API uses
import featureAbility from '@ohos.ability.featureAbility';
let context = featureAbility.getContext();
let wakeUp = true;
context.setWakeUpScreen(wakeUp, (err) => {
console.info('setWakeUpScreen err: ${JSON.stringify(err)}');
context.setWakeUpScreen(wakeUp, (error) => {
console.error('setWakeUpScreen fail, error: ${JSON.stringify(error)}');
});
```
......@@ -628,8 +660,12 @@ Obtains information about the current process, including the PID and process nam
```ts
import featureAbility from '@ohos.ability.featureAbility';
let context = featureAbility.getContext();
context.getProcessInfo((err, data) => {
console.info('getProcessInfo err: ${JSON.stringify(err)}, data: ${JSON.stringify(data)}');
context.getProcessInfo((error, data) => {
if (error && error.code !== 0) {
console.error('getProcessInfo fail, error: ${JSON.stringify(error)}');
} else {
console.log('getProcessInfo success, data: ${JSON.stringify(data)}');
}
});
```
......@@ -682,8 +718,12 @@ This API is available only to Page abilities.
```ts
import featureAbility from '@ohos.ability.featureAbility';
let context = featureAbility.getContext();
context.getElementName((err, data) => {
console.info('getElementName err: ${JSON.stringify(err)}, data: ${JSON.stringify(data)}');
context.getElementName((error, data) => {
if (error && error.code !== 0) {
console.error('getElementName fail, error: ${JSON.stringify(error)}');
} else {
console.log('getElementName success, data: ${JSON.stringify(data)}');
}
});
```
......@@ -734,8 +774,12 @@ Obtains the name of the current process. This API uses an asynchronous callback
```ts
import featureAbility from '@ohos.ability.featureAbility';
let context = featureAbility.getContext();
context.getProcessName((err, data) => {
console.info('getProcessName err: ${JSON.stringify(err)}, data: ${JSON.stringify(data)}');
context.getProcessName((error, data) => {
if (error && error.code !== 0) {
console.error('getProcessName fail, error: ${JSON.stringify(error)}');
} else {
console.log('getProcessName success, data: ${JSON.stringify(data)}');
}
});
```
......@@ -786,8 +830,12 @@ Obtains the bundle name of the caller ability. This API uses an asynchronous cal
```ts
import featureAbility from '@ohos.ability.featureAbility';
let context = featureAbility.getContext();
context.getCallingBundle((err, data) => {
console.info('getCallingBundle err: ${JSON.stringify(err)}, data: ${JSON.stringify(data)}');
context.getCallingBundle((error, data) => {
if (error && error.code !== 0) {
console.error('getCallingBundle fail, error: ${JSON.stringify(error)}');
} else {
console.log('getCallingBundle success, data: ${JSON.stringify(data)}');
}
});
```
......@@ -836,8 +884,12 @@ Obtains the cache directory of the application in the internal storage. This API
```ts
import featureAbility from '@ohos.ability.featureAbility';
let context = featureAbility.getContext();
context.getCacheDir((err, data) => {
console.info('getCacheDir err: ${JSON.stringify(err)}, data: ${JSON.stringify(data)}');
context.getCacheDir((error, data) => {
if (error && error.code !== 0) {
console.error('getCacheDir fail, error: ${JSON.stringify(error)}');
} else {
console.log('getCacheDir success, data: ${JSON.stringify(data)}');
}
});
```
......@@ -884,8 +936,12 @@ Obtains the file directory of the application in the internal storage. This API
```ts
import featureAbility from '@ohos.ability.featureAbility';
let context = featureAbility.getContext();
context.getFilesDir((err, data) => {
console.info('getFilesDir err: ${JSON.stringify(err)}, data: ${JSON.stringify(data)}');
context.getFilesDir((error, data) => {
if (error && error.code !== 0) {
console.error('getFilesDir fail, error: ${JSON.stringify(error)}');
} else {
console.log('getFilesDir success, data: ${JSON.stringify(data)}');
}
});
```
......@@ -934,8 +990,12 @@ If the distributed file path does not exist, the system will create one and retu
```ts
import featureAbility from '@ohos.ability.featureAbility';
let context = featureAbility.getContext();
context.getOrCreateDistributedDir((err, data) => {
console.info('getOrCreateDistributedDir err: ${JSON.stringify(err)}, data: ${JSON.stringify(data)}');
context.getOrCreateDistributedDir((error, data) => {
if (error && error.code !== 0) {
console.error('getOrCreateDistributedDir fail, error: ${JSON.stringify(error)}');
} else {
console.log('getOrCreateDistributedDir success, data: ${JSON.stringify(data)}');
}
});
```
......@@ -984,8 +1044,12 @@ Obtains the application type. This API uses an asynchronous callback to return t
```ts
import featureAbility from '@ohos.ability.featureAbility';
let context = featureAbility.getContext();
context.getAppType((err, data) => {
console.info('getAppType err: ${JSON.stringify(err)}, data: ${JSON.stringify(data)}');
context.getAppType((error, data) => {
if (error && error.code !== 0) {
console.error('getAppType fail, error: ${JSON.stringify(error)}');
} else {
console.log('getAppType success, data: ${JSON.stringify(data)}');
}
});
```
......@@ -1032,8 +1096,12 @@ Obtains the **ModuleInfo** object of the application. This API uses an asynchron
```ts
import featureAbility from '@ohos.ability.featureAbility';
let context = featureAbility.getContext();
context.getHapModuleInfo((err, data) => {
console.info('getHapModuleInfo err: ${JSON.stringify(err)}, data: ${JSON.stringify(data)}');
context.getHapModuleInfo((error, data) => {
if (error && error.code !== 0) {
console.error('getHapModuleInfo fail, error: ${JSON.stringify(error)}');
} else {
console.log('getHapModuleInfo success, data: ${JSON.stringify(data)}');
}
});
```
......@@ -1080,8 +1148,12 @@ Obtains the version information of the application. This API uses an asynchronou
```ts
import featureAbility from '@ohos.ability.featureAbility';
let context = featureAbility.getContext();
context.getAppVersionInfo((err, data) => {
console.info('getAppVersionInfo err: ${JSON.stringify(err)}, data: ${JSON.stringify(data)}');
context.getAppVersionInfo((error, data) => {
if (error && error.code !== 0) {
console.error('getAppVersionInfo fail, error: ${JSON.stringify(error)}');
} else {
console.log('getAppVersionInfo success, data: ${JSON.stringify(data)}');
}
});
```
......@@ -1128,8 +1200,12 @@ Obtains information about this ability. This API uses an asynchronous callback t
```ts
import featureAbility from '@ohos.ability.featureAbility';
let context = featureAbility.getContext();
context.getAbilityInfo((err, data) => {
console.info('getAbilityInfo err: ${JSON.stringify(err)}, data: ${JSON.stringify(data)}');
context.getAbilityInfo((error, data) => {
if (error && error.code !== 0) {
console.error('getAbilityInfo fail, error: ${JSON.stringify(error)}');
} else {
console.log('getAbilityInfo success, data: ${JSON.stringify(data)}');
}
});
```
......@@ -1197,8 +1273,12 @@ Checks whether the configuration of this ability is being updated. This API uses
```ts
import featureAbility from '@ohos.ability.featureAbility';
let context = featureAbility.getContext();
context.isUpdatingConfigurations((err, data) => {
console.info('isUpdatingConfigurations err: ${JSON.stringify(err)}, data: ${JSON.stringify(data)}');
context.isUpdatingConfigurations((error, data) => {
if (error && error.code !== 0) {
console.error('isUpdatingConfigurations fail, error: ${JSON.stringify(error)}');
} else {
console.log('isUpdatingConfigurations success, data: ${JSON.stringify(data)}');
}
});
```
......
......@@ -18,9 +18,11 @@ The **ProcessInfo** module defines process information. You can use [getProcessI
import featureAbility from '@ohos.ability.featureAbility';
let context = featureAbility.getContext();
context.getProcessInfo((err, data) => {
if (err.code !== 0) {
console.info('getProcessInfo err: ${JSON.stringify(err)}, data: ${JSON.stringify(data)}');
context.getProcessInfo((error, data) => {
if (error && error.code !== 0) {
console.error('getProcessInfo fail, error: ${JSON.stringify(error)}');
} else {
console.log('getProcessInfo success, data: ${JSON.stringify(data)}');
let pid = data.pid;
let processName = data.processName;
}
......
......@@ -34,7 +34,7 @@ Describes an ability monitor.
import AbilityDelegatorRegistry from '@ohos.app.ability.abilityDelegatorRegistry';
function onAbilityCreateCallback(data) {
console.info('onAbilityCreateCallback');
console.info('onAbilityCreateCallback, data: ${JSON.stringify(data)}');
}
let monitor = {
......@@ -44,7 +44,9 @@ let monitor = {
};
let abilityDelegator = AbilityDelegatorRegistry.getAbilityDelegator();
abilityDelegator.addAbilityMonitor(monitor, (err : any) => {
console.info('addAbilityMonitor callback');
abilityDelegator.addAbilityMonitor(monitor, (error : any) => {
if (error && error.code !== 0) {
console.error('addAbilityMonitor fail, error: ${JSON.stringify(error)}');
}
});
```
......@@ -30,16 +30,20 @@ The ability running information is obtained by calling [getAbilityRunningInfos](
```ts
import abilitymanager from '@ohos.app.ability.abilityManager';
abilitymanager.getAbilityRunningInfos((err,data) => {
console.log('getAbilityRunningInfos err: ${err}, data: ${JSON.stringify(data)}');
for (let i = 0; i < data.length; i++) {
let abilityinfo = data[i];
console.log('abilityinfo.ability: ${JSON.stringify(abilityinfo.ability)}');
console.log('abilityinfo.pid: ${JSON.stringify(abilityinfo.pid)}');
console.log('abilityinfo.uid: ${JSON.stringify(abilityinfo.uid)}');
console.log('abilityinfo.processName: ${JSON.stringify(abilityinfo.processName)}');
console.log('abilityinfo.startTime: ${JSON.stringify(abilityinfo.startTime)}');
console.log('abilityinfo.abilityState: ${JSON.stringify(abilityinfo.abilityState)}');
abilitymanager.getAbilityRunningInfos((error, data) => {
if (error && error.code !== 0) {
console.error('getAbilityRunningInfos fail, error: ${JSON.stringify(error)}');
} else {
console.log('getAbilityRunningInfos success, data: ${JSON.stringify(data)}');
for (let i = 0; i < data.length; i++) {
let abilityinfo = data[i];
console.log('abilityinfo.ability: ${JSON.stringify(abilityinfo.ability)}');
console.log('abilityinfo.pid: ${JSON.stringify(abilityinfo.pid)}');
console.log('abilityinfo.uid: ${JSON.stringify(abilityinfo.uid)}');
console.log('abilityinfo.processName: ${JSON.stringify(abilityinfo.processName)}');
console.log('abilityinfo.startTime: ${JSON.stringify(abilityinfo.startTime)}');
console.log('abilityinfo.abilityState: ${JSON.stringify(abilityinfo.abilityState)}');
}
}
});
```
......@@ -20,6 +20,10 @@ let monitor = {
let abilityDelegator = AbilityDelegatorRegistry.getAbilityDelegator();
abilityDelegator.waitAbilityStageMonitor(monitor, (error, data) => {
console.info('stageMonitor waitAbilityStageMonitor, abilityStage = ${JSON.stringify(data)}');
if (error && error.code !== 0) {
console.error('waitAbilityStageMonitor fail, error: ${JSON.stringify(error)}');
} else {
console.log('waitAbilityStageMonitor success, data: ${JSON.stringify(data)}');
}
});
```
......@@ -83,7 +83,7 @@ export default class EntryAbility extends UIAbility {
let applicationContext = this.context.getApplicationContext();
// 2. Use applicationContext to register a listener for the ability lifecycle in the application.
lifecycleId = applicationContext.on('abilityLifecycle', AbilityLifecycleCallback);
console.log('registerAbilityLifecycleCallback number: ' + JSON.stringify(lifecycleId));
console.log('registerAbilityLifecycleCallback lifecycleId: ${lifecycleId)}');
}
}
```
......@@ -114,9 +114,13 @@ let lifecycleId;
export default class EntryAbility extends UIAbility {
onDestroy() {
let applicationContext = this.context.getApplicationContext();
console.log('stage applicationContext: ' + applicationContext);
console.log('stage applicationContext: ${applicationContext}');
applicationContext.off(type: 'abilityLifecycle', lifecycleId, (error, data) => {
console.log('unregisterAbilityLifecycleCallback success, err: ' + JSON.stringify(error));
if (error && error.code !== 0) {
console.error('unregisterAbilityLifecycleCallback fail, err: ${JSON.stringify(error)}');
} else {
console.log('unregisterAbilityLifecycleCallback success, data: ${JSON.stringify(data)}');
}
});
}
}
......@@ -147,7 +151,7 @@ let lifecycleId;
export default class MyAbility extends Ability {
onDestroy() {
let applicationContext = this.context.getApplicationContext();
console.log('stage applicationContext: ' + applicationContext);
console.log('stage applicationContext: ${applicationContext}');
applicationContext.off(type: 'abilityLifecycle', lifecycleId);
}
}
......@@ -185,19 +189,19 @@ export default class EntryAbility extends UIAbility {
onCreate() {
console.log('MyAbility onCreate')
globalThis.applicationContext = this.context.getApplicationContext();
let EnvironmentCallback = {
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. Use applicationContext to register a listener for the ability lifecycle in the application.
callbackId = applicationContext.on('environment', EnvironmentCallback);
console.log('registerEnvironmentCallback number: ' + JSON.stringify(callbackId));
// 2. Use applicationContext to register a listener for system environment changes.
callbackId = applicationContext.on('environment', environmentCallback);
console.log('registerEnvironmentCallback callbackId: ${callbackId}');
}
}
```
......@@ -229,7 +233,11 @@ export default class EntryAbility extends UIAbility {
onDestroy() {
let applicationContext = this.context.getApplicationContext();
applicationContext.off('environment', callbackId, (error, data) => {
console.log('unregisterEnvironmentCallback success, err: ' + JSON.stringify(error));
if (error && error.code !== 0) {
console.error('unregisterEnvironmentCallback fail, err: ${JSON.stringify(error)}');
} else {
console.log('unregisterEnvironmentCallback success, data: ${JSON.stringify(data)}');
}
});
}
}
......@@ -290,7 +298,7 @@ let applicationContext = this.context.getApplicationContext();
applicationContext.getRunningProcessInformation().then((data) => {
console.log('The process running information is: ${JSON.stringify(data)}');
}).catch((error) => {
console.log('error: ${JSON.stringify(error)}');
console.error('error: ${JSON.stringify(error)}');
});
```
......@@ -364,7 +372,9 @@ Kills all the processes where the application is located. This API uses an async
```ts
let applicationContext = this.context.getApplicationContext();
applicationContext.killAllProcesses(err => {
console.error('killAllProcesses result: ${JSON.stringify(err)}');
applicationContext.killAllProcesses(error => {
if (error && error.code !== 0) {
console.error('killAllProcesses fail, error: ${JSON.stringify(error)}');
}
});
```
......@@ -62,7 +62,7 @@ let bundleContext;
try {
bundleContext = this.context.createBundleContext('com.example.test');
} catch (error) {
console.log('createBundleContext failed, error.code: ${JSON.stringify(error.code)}, error.message: ${JSON.stringify(error.message)}');
console.error('createBundleContext failed, error.code: ${JSON.stringify(error.code)}, error.message: ${JSON.stringify(error.message)}');
}
```
......@@ -101,7 +101,7 @@ let moduleContext;
try {
moduleContext = this.context.createModuleContext('entry');
} catch (error) {
console.log('createModuleContext failed, error.code: ${JSON.stringify(error.code)}, error.message: ${JSON.stringify(error.message)}');
console.error('createModuleContext failed, error.code: ${JSON.stringify(error.code)}, error.message: ${JSON.stringify(error.message)}');
}
```
......@@ -141,7 +141,7 @@ let moduleContext;
try {
moduleContext = this.context.createModuleContext('com.example.test', 'entry');
} catch (error) {
console.log('createModuleContext failed, error.code: ${JSON.stringify(error.code)}, error.message: ${JSON.stringify(error.message)}');
console.error('createModuleContext failed, error.code: ${JSON.stringify(error.code)}, error.message: ${JSON.stringify(error.message)}');
}
```
......@@ -166,6 +166,6 @@ let applicationContext;
try {
applicationContext = this.context.getApplicationContext();
} catch (error) {
console.log('getApplicationContext failed, error.code: ${JSON.stringify(error.code)}, error.message: ${JSON.stringify(error.message)}');
console.error('getApplicationContext failed, error.code: ${JSON.stringify(error.code)}, error.message: ${JSON.stringify(error.message)}');
}
```
......@@ -38,7 +38,7 @@ Called when the mission continuation is complete.
distributedMissionManager.continueMission(continueDeviceInfo, continueCallback, (error) => {
if (error && error.code) {
console.log('continueMission failed, error.code: ${JSON.stringify(error.code)}, error.message: ${JSON.stringify(error.message)}');
console.error('continueMission failed, error.code: ${JSON.stringify(error.code)}, error.message: ${JSON.stringify(error.message)}');
}
console.log('continueMission finished');
});
......
......@@ -33,7 +33,7 @@ The **ContinueDeviceInfo** module defines the parameters required for initiating
distributedMissionManager.continueMission(continueDeviceInfo, continueCallback, (error) => {
if (error && error.code) {
console.log('continueMission failed, error.code: ${JSON.stringify(error.code)}, error.message: ${JSON.stringify(error.message)}');
console.error('continueMission failed, error.code: ${JSON.stringify(error.code)}, error.message: ${JSON.stringify(error.message)}');
}
console.log('continueMission finished');
});
......
......@@ -23,13 +23,13 @@ import errorManager from '@ohos.app.ability.errorManager';
let observer = {
onUnhandledException(errorMsg) {
console.log('onUnhandledException, errorMsg: ', errorMsg);
console.error('onUnhandledException, errorMsg: ', errorMsg);
}
};
try {
errorManager.on('error', observer);
} catch (error) {
console.log('registerErrorObserver failed, error.code: ${JSON.stringify(error.code)}, error.message: ${JSON.stringify(error.message)}');
console.error('registerErrorObserver failed, error.code: ${JSON.stringify(error.code)}, error.message: ${JSON.stringify(error.message)}');
}
```
......@@ -33,7 +33,7 @@ let upperLimit = 1;
function getExtensionInfos() {
abilityManager.getExtensionRunningInfos(upperLimit, (error, data) => {
if (error && error.code) {
console.log('getForegroundApplications failed, error.code: ${JSON.stringify(error.code)}, error.message: ${JSON.stringify(error.message)}');
console.error('getForegroundApplications failed, error.code: ${JSON.stringify(error.code)}, error.message: ${JSON.stringify(error.message)}');
return;
}
......
......@@ -67,7 +67,7 @@ export default class MyFormExtensionAbility extends FormExtensionAbility {
};
this.context.startAbility(want, (error, data) => {
if (error) {
console.log('FormExtensionContext startAbility, error:${JSON.stringify(error)}');
console.error('FormExtensionContext startAbility, error:${JSON.stringify(error)}');
} else {
console.log('FormExtensionContext startAbility success');
}
......@@ -118,7 +118,7 @@ export default class MyFormExtensionAbility extends FormExtensionAbility {
this.context.startAbility(want).then(() => {
console.info('StartAbility Success');
}).catch((error) => {
console.info('StartAbility failed');
console.error('StartAbility failed');
});
}
};
......
......@@ -25,7 +25,7 @@ try {
missionManager.getMissionInfo('', 1, (error, data) => {
if (error.code) {
// Process service logic errors.
console.log('getMissionInfo failed, error.code: ${JSON.stringify(error.code)}, error.message: ${JSON.stringify(error.message)}');
console.error('getMissionInfo failed, error.code: ${JSON.stringify(error.code)}, error.message: ${JSON.stringify(error.message)}');
return;
}
......@@ -39,6 +39,6 @@ try {
console.log('getMissionInfo continuable is: ${JSON.stringify(data.continuable)}');
});
} catch (paramError) {
console.log('error: ${paramError.code}, ${paramError.message}');
console.error('error: ${paramError.code}, ${paramError.message}');
}
```
......@@ -42,6 +42,6 @@ let listener = {
try {
let listenerId = missionManager.on('mission', listener);
} catch (paramError) {
console.log('error: ${paramError.code}, ${paramError.message}');
console.error('error: ${paramError.code}, ${paramError.message}');
}
```
......@@ -21,8 +21,12 @@ let missionParameter = {
};
try {
distributedMissionManager.startSyncRemoteMissions(missionParameter,
(err, data) => {
console.log('startSyncRemoteMissions, data: ${JSON.stringify(data)}');
(error, data) => {
if (error && error.code !== 0) {
console.error('startSyncRemoteMissions fail, error: ${JSON.stringify(error)}');
} else {
console.log('startSyncRemoteMissions success, data: ${JSON.stringify(data)}');
}
}
);
} catch (err) {
......
......@@ -14,7 +14,11 @@ The process information is obtained by calling [getRunningProcessInformation](js
import appManager from '@ohos.app.ability.appManager';
appManager.getRunningProcessInformation((error, data) => {
console.log('error: ${error.code}, data: ${JSON.stringify(data)}');
if (error && error.code !== 0) {
console.error('getRunningProcessInformation fail, error: ${JSON.stringify(error)}');
} else {
console.log('getRunningProcessInformation success, data: ${JSON.stringify(data)}');
}
});
```
......
......@@ -28,6 +28,6 @@ import appManager from '@ohos.app.ability.appManager';
appManager.getProcessRunningInfos().then((data) => {
console.log('success: ${JSON.stringify(data)}');
}).catch((error) => {
console.log('failed: ${JSON.stringify(error)}');
console.error('failed: ${JSON.stringify(error)}');
});
```
......@@ -77,7 +77,7 @@ Starts an ability. This API uses an asynchronous callback to return the result.
this.context.startAbility(want, (error) => {
if (error.code) {
// Process service logic errors.
console.log('startAbility failed, error.code: ${JSON.stringify(error.code)}, error.message: ${JSON.stringify(error.message)}');
console.error('startAbility failed, error.code: ${JSON.stringify(error.code)}, error.message: ${JSON.stringify(error.message)}');
return;
}
// Carry out normal service processing.
......@@ -85,7 +85,7 @@ Starts an ability. This API uses an asynchronous callback to return the result.
});
} catch (paramError) {
// Process input parameter errors.
console.log('error.code: ${JSON.stringify(paramError.code)}, error.message: ${JSON.stringify(paramError.message)}');
console.error('error.code: ${JSON.stringify(paramError.code)}, error.message: ${JSON.stringify(paramError.message)}');
}
```
......@@ -155,11 +155,11 @@ Starts an ability. This API uses a promise to return the result.
})
.catch((error) => {
// Process service logic errors.
console.log('startAbility failed, error.code: ${JSON.stringify(error.code)}, error.message: ${JSON.stringify(error.message)}');
console.error('startAbility failed, error.code: ${JSON.stringify(error.code)}, error.message: ${JSON.stringify(error.message)}');
});
} catch (paramError) {
// Process input parameter errors.
console.log('error.code: ${JSON.stringify(paramError.code)}, error.message: ${JSON.stringify(paramError.message)}');
console.error('error.code: ${JSON.stringify(paramError.code)}, error.message: ${JSON.stringify(paramError.message)}');
}
```
......@@ -167,7 +167,7 @@ Starts an ability. This API uses a promise to return the result.
startAbility(want: Want, options: StartOptions, callback: AsyncCallback&lt;void&gt;): void
Starts an ability with the start options specified. This API uses an asynchronous callback to return the result.
Starts an ability. This API uses an asynchronous callback to return the result.
**System capability**: SystemCapability.Ability.AbilityRuntime.Core
......@@ -221,7 +221,7 @@ Starts an ability with the start options specified. This API uses an asynchronou
this.context.startAbility(want, options, (error) => {
if (error.code) {
// Process service logic errors.
console.log('startAbility failed, error.code: ${JSON.stringify(error.code)}, error.message: ${JSON.stringify(error.message)}');
console.error('startAbility failed, error.code: ${JSON.stringify(error.code)}, error.message: ${JSON.stringify(error.message)}');
return;
}
// Carry out normal service processing.
......@@ -229,7 +229,7 @@ Starts an ability with the start options specified. This API uses an asynchronou
});
} catch (paramError) {
// Process input parameter errors.
console.log('error.code: ${JSON.stringify(paramError.code)}, error.message: ${JSON.stringify(paramError.message)}');
console.error('error.code: ${JSON.stringify(paramError.code)}, error.message: ${JSON.stringify(paramError.message)}');
}
```
......@@ -295,7 +295,7 @@ Observe the following when using this API:
this.context.startAbilityWithAccount(want, accountId, (error) => {
if (error.code) {
// Process service logic errors.
console.log('startAbilityWithAccount failed, error.code: ${JSON.stringify(error.code)}, error.message: ${JSON.stringify(error.message)}');
console.error('startAbilityWithAccount failed, error.code: ${JSON.stringify(error.code)}, error.message: ${JSON.stringify(error.message)}');
return;
}
// Carry out normal service processing.
......@@ -303,7 +303,7 @@ Observe the following when using this API:
});
} catch (paramError) {
// Process input parameter errors.
console.log('error.code: ${JSON.stringify(paramError.code)}, error.message: ${JSON.stringify(paramError.message)}');
console.error('error.code: ${JSON.stringify(paramError.code)}, error.message: ${JSON.stringify(paramError.message)}');
}
```
......@@ -373,7 +373,7 @@ Observe the following when using this API:
this.context.startAbilityWithAccount(want, accountId, options, (error) => {
if (error.code) {
// Process service logic errors.
console.log('startAbilityWithAccount failed, error.code: ${JSON.stringify(error.code)}, error.message: ${JSON.stringify(error.message)}');
console.error('startAbilityWithAccount failed, error.code: ${JSON.stringify(error.code)}, error.message: ${JSON.stringify(error.message)}');
return;
}
// Carry out normal service processing.
......@@ -381,7 +381,7 @@ Observe the following when using this API:
});
} catch (paramError) {
// Process input parameter errors.
console.log('error.code: ${JSON.stringify(paramError.code)}, error.message: ${JSON.stringify(paramError.message)}');
console.error('error.code: ${JSON.stringify(paramError.code)}, error.message: ${JSON.stringify(paramError.message)}');
}
```
......@@ -461,11 +461,11 @@ Observe the following when using this API:
})
.catch((error) => {
// Process service logic errors.
console.log('startAbilityWithAccount failed, error.code: ${JSON.stringify(error.code)}, error.message: ${JSON.stringify(error.message)}');
console.error('startAbilityWithAccount failed, error.code: ${JSON.stringify(error.code)}, error.message: ${JSON.stringify(error.message)}');
});
} catch (paramError) {
// Process input parameter errors.
console.log('error.code: ${JSON.stringify(paramError.code)}, error.message: ${JSON.stringify(paramError.message)}');
console.error('error.code: ${JSON.stringify(paramError.code)}, error.message: ${JSON.stringify(paramError.message)}');
}
```
......@@ -516,7 +516,7 @@ Starts a new ServiceExtensionAbility. This API uses an asynchronous callback to
this.context.startServiceExtensionAbility(want, (error) => {
if (error.code) {
// Process service logic errors.
console.log('startServiceExtensionAbility failed, error.code: ${JSON.stringify(error.code)}, error.message: ${JSON.stringify(error.message)}');
console.error('startServiceExtensionAbility failed, error.code: ${JSON.stringify(error.code)}, error.message: ${JSON.stringify(error.message)}');
return;
}
// Carry out normal service processing.
......@@ -524,7 +524,7 @@ Starts a new ServiceExtensionAbility. This API uses an asynchronous callback to
});
} catch (paramError) {
// Process input parameter errors.
console.log('error.code: ${JSON.stringify(paramError.code)}, error.message: ${JSON.stringify(paramError.message)}');
console.error('error.code: ${JSON.stringify(paramError.code)}, error.message: ${JSON.stringify(paramError.message)}');
}
```
......@@ -584,11 +584,11 @@ Starts a new ServiceExtensionAbility. This API uses a promise to return the resu
})
.catch((error) => {
// Process service logic errors.
console.log('startServiceExtensionAbility failed, error.code: ${JSON.stringify(error.code)}, error.message: ${JSON.stringify(error.message)}');
console.error('startServiceExtensionAbility failed, error.code: ${JSON.stringify(error.code)}, error.message: ${JSON.stringify(error.message)}');
});
} catch (paramError) {
// Process input parameter errors.
console.log('error.code: ${JSON.stringify(paramError.code)}, error.message: ${JSON.stringify(paramError.message)}');
console.error('error.code: ${JSON.stringify(paramError.code)}, error.message: ${JSON.stringify(paramError.message)}');
}
```
......@@ -645,7 +645,7 @@ Starts a new ServiceExtensionAbility with the account ID specified. This API use
this.context.startServiceExtensionAbilityWithAccount(want, accountId, (error) => {
if (error.code) {
// Process service logic errors.
console.log('startServiceExtensionAbilityWithAccount failed, error.code: ${JSON.stringify(error.code)}, error.message: ${JSON.stringify(error.message)}');
console.error('startServiceExtensionAbilityWithAccount failed, error.code: ${JSON.stringify(error.code)}, error.message: ${JSON.stringify(error.message)}');
return;
}
// Carry out normal service processing.
......@@ -653,7 +653,7 @@ Starts a new ServiceExtensionAbility with the account ID specified. This API use
});
} catch (paramError) {
// Process input parameter errors.
console.log('error.code: ${JSON.stringify(paramError.code)}, error.message: ${JSON.stringify(paramError.message)}');
console.error('error.code: ${JSON.stringify(paramError.code)}, error.message: ${JSON.stringify(paramError.message)}');
}
```
......@@ -718,11 +718,11 @@ Starts a new ServiceExtensionAbility with the account ID specified. This API use
})
.catch((error) => {
// Process service logic errors.
console.log('startServiceExtensionAbilityWithAccount failed, error.code: ${JSON.stringify(error.code)}, error.message: ${JSON.stringify(error.message)}');
console.error('startServiceExtensionAbilityWithAccount failed, error.code: ${JSON.stringify(error.code)}, error.message: ${JSON.stringify(error.message)}');
});
} catch (paramError) {
// Process input parameter errors.
console.log('error.code: ${JSON.stringify(paramError.code)}, error.message: ${JSON.stringify(paramError.message)}');
console.error('error.code: ${JSON.stringify(paramError.code)}, error.message: ${JSON.stringify(paramError.message)}');
}
```
......@@ -770,7 +770,7 @@ Stops a ServiceExtensionAbility in the same application. This API uses an asynch
this.context.stopServiceExtensionAbility(want, (error) => {
if (error.code) {
// Process service logic errors.
console.log('stopServiceExtensionAbility failed, error.code: ${JSON.stringify(error.code)}, error.message: ${JSON.stringify(error.message)}');
console.error('stopServiceExtensionAbility failed, error.code: ${JSON.stringify(error.code)}, error.message: ${JSON.stringify(error.message)}');
return;
}
// Carry out normal service processing.
......@@ -778,7 +778,7 @@ Stops a ServiceExtensionAbility in the same application. This API uses an asynch
});
} catch (paramError) {
// Process input parameter errors.
console.log('error.code: ${JSON.stringify(paramError.code)}, error.message: ${JSON.stringify(paramError.message)}');
console.error('error.code: ${JSON.stringify(paramError.code)}, error.message: ${JSON.stringify(paramError.message)}');
}
```
......@@ -835,11 +835,11 @@ Stops a ServiceExtensionAbility in the same application. This API uses a promise
})
.catch((error) => {
// Process service logic errors.
console.log('stopServiceExtensionAbility failed, error.code: ${JSON.stringify(error.code)}, error.message: ${JSON.stringify(error.message)}');
console.error('stopServiceExtensionAbility failed, error.code: ${JSON.stringify(error.code)}, error.message: ${JSON.stringify(error.message)}');
});
} catch (paramError) {
// Process input parameter errors.
console.log('error.code: ${JSON.stringify(paramError.code)}, error.message: ${JSON.stringify(paramError.message)}');
console.error('error.code: ${JSON.stringify(paramError.code)}, error.message: ${JSON.stringify(paramError.message)}');
}
```
......@@ -892,7 +892,7 @@ Stops a ServiceExtensionAbility in the same application with the account ID spec
this.context.stopServiceExtensionAbilityWithAccount(want, accountId, (error) => {
if (error.code) {
// Process service logic errors.
console.log('stopServiceExtensionAbilityWithAccount failed, error.code: ${JSON.stringify(error.code), error.message: ${JSON.stringify(error.message)}');
console.error('stopServiceExtensionAbilityWithAccount failed, error.code: ${JSON.stringify(error.code), error.message: ${JSON.stringify(error.message)}');
return;
}
// Carry out normal service processing.
......@@ -900,7 +900,7 @@ Stops a ServiceExtensionAbility in the same application with the account ID spec
});
} catch (paramError) {
// Process input parameter errors.
console.log('error.code: ${JSON.stringify(paramError.code)}, error.message: ${JSON.stringify(paramError.message)}');
console.error('error.code: ${JSON.stringify(paramError.code)}, error.message: ${JSON.stringify(paramError.message)}');
}
```
......@@ -962,11 +962,11 @@ Stops a ServiceExtensionAbility in the same application with the account ID spec
})
.catch((error) => {
// Process service logic errors.
console.log('stopServiceExtensionAbilityWithAccount failed, error.code: ${JSON.stringify(error.code)}, error.message: ${JSON.stringify(error.message)}');
console.error('stopServiceExtensionAbilityWithAccount failed, error.code: ${JSON.stringify(error.code)}, error.message: ${JSON.stringify(error.message)}');
});
} catch (paramError) {
// Process input parameter errors.
console.log('error.code: ${JSON.stringify(paramError.code)}, error.message: ${JSON.stringify(paramError.message)}');
console.error('error.code: ${JSON.stringify(paramError.code)}, error.message: ${JSON.stringify(paramError.message)}');
}
```
......@@ -1003,7 +1003,7 @@ Terminates this ability. This API uses an asynchronous callback to return the re
this.context.terminateSelf((error) => {
if (error.code) {
// Process service logic errors.
console.log('terminateSelf failed, error.code: ${JSON.stringify(error.code)}, error.message: ${JSON.stringify(error.message)}');
console.error('terminateSelf failed, error.code: ${JSON.stringify(error.code)}, error.message: ${JSON.stringify(error.message)}');
return;
}
// Carry out normal service processing.
......@@ -1046,7 +1046,7 @@ Terminates this ability. This API uses a promise to return the result.
console.log('terminateSelf succeed');
}).catch((error) => {
// Process service logic errors.
console.log('terminateSelf failed, error.code: ${JSON.stringify(error.code)}, error.message: ${JSON.stringify(error.message)}');
console.error('terminateSelf failed, error.code: ${JSON.stringify(error.code)}, error.message: ${JSON.stringify(error.message)}');
});
```
......@@ -1095,7 +1095,7 @@ Connects this ability to a ServiceAbility.
let options = {
onConnect(elementName, remote) { console.log('----------- onConnect -----------') },
onDisconnect(elementName) { console.log('----------- onDisconnect -----------') },
onFailed(code) { console.log('----------- onFailed -----------') }
onFailed(code) { console.error('----------- onFailed -----------') }
};
let connection = null;
......@@ -1103,7 +1103,7 @@ Connects this ability to a ServiceAbility.
connection = this.context.connectServiceExtensionAbility(want, options);
} catch (paramError) {
// Process input parameter errors.
console.log('error.code: ${JSON.stringify(paramError.code)}, error.message: ${JSON.stringify(paramError.message)}');
console.error('error.code: ${JSON.stringify(paramError.code)}, error.message: ${JSON.stringify(paramError.message)}');
}
```
......@@ -1164,7 +1164,7 @@ Uses the **AbilityInfo.AbilityType.SERVICE** template and account ID to connect
connection = this.context.connectServiceExtensionAbilityWithAccount(want, accountId, options);
} catch (paramError) {
// Process input parameter errors.
console.log('error.code: ${JSON.stringify(paramError.code)}, error.message: ${JSON.stringify(paramError.message)}');
console.error('error.code: ${JSON.stringify(paramError.code)}, error.message: ${JSON.stringify(paramError.message)}');
}
```
......@@ -1206,7 +1206,7 @@ Disconnects this ability from the ServiceAbility. This API uses an asynchronous
this.context.disconnectServiceExtensionAbility(connection, (error) => {
if (error.code) {
// Process service logic errors.
console.log('disconnectServiceExtensionAbility failed, error.code: ${JSON.stringify(error.code)}, error.message: ${JSON.stringify(error.message)}');
console.error('disconnectServiceExtensionAbility failed, error.code: ${JSON.stringify(error.code)}, error.message: ${JSON.stringify(error.message)}');
return;
}
// Carry out normal service processing.
......@@ -1214,7 +1214,7 @@ Disconnects this ability from the ServiceAbility. This API uses an asynchronous
});
} catch (paramError) {
// Process input parameter errors.
console.log('error.code: ${JSON.stringify(paramError.code)}, error.message: ${JSON.stringify(paramError.message)}');
console.error('error.code: ${JSON.stringify(paramError.code)}, error.message: ${JSON.stringify(paramError.message)}');
}
```
......@@ -1265,11 +1265,11 @@ Disconnects this ability from the ServiceAbility. This API uses a promise to ret
})
.catch((error) => {
// Process service logic errors.
console.log('disconnectServiceExtensionAbility failed, error.code: ${JSON.stringify(error.code)}, error.message: ${JSON.stringify(error.message)}');
console.error('disconnectServiceExtensionAbility failed, error.code: ${JSON.stringify(error.code)}, error.message: ${JSON.stringify(error.message)}');
});
} catch (paramError) {
// Process input parameter errors.
console.log('error.code: ${JSON.stringify(paramError.code)}, error.message: ${JSON.stringify(paramError.message)}');
console.error('error.code: ${JSON.stringify(paramError.code)}, error.message: ${JSON.stringify(paramError.message)}');
}
```
......@@ -1337,11 +1337,11 @@ Observe the following when using this API:
console.log('startAbilityByCall succeed');
}).catch((error) => {
// Process service logic errors.
console.log('startAbilityByCall failed, error.code: ${JSON.stringify(error.code)}, error.message: ${JSON.stringify(error.message)}');
console.error('startAbilityByCall failed, error.code: ${JSON.stringify(error.code)}, error.message: ${JSON.stringify(error.message)}');
});
} catch (paramError) {
// Process input parameter errors.
console.log('error.code: ${JSON.stringify(paramError.code)}, error.message: ${JSON.stringify(paramError.message)}');
console.error('error.code: ${JSON.stringify(paramError.code)}, error.message: ${JSON.stringify(paramError.message)}');
}
```
......@@ -1369,10 +1369,10 @@ Observe the following when using this API:
console.log('startAbilityByCall succeed');
}).catch((error) => {
// Process service logic errors.
console.log('startAbilityByCall failed, error.code: ${JSON.stringify(error.code)}, error.message: ${JSON.stringify(error.message)}');
console.error('startAbilityByCall failed, error.code: ${JSON.stringify(error.code)}, error.message: ${JSON.stringify(error.message)}');
});
} catch (paramError) {
// Process input parameter errors.
console.log('error.code: ${JSON.stringify(paramError.code)}, error.message: ${JSON.stringify(paramError.message)}');
console.error('error.code: ${JSON.stringify(paramError.code)}, error.message: ${JSON.stringify(paramError.message)}');
}
```
......@@ -24,8 +24,11 @@ let abilityDelegator;
let cmd = 'cmd';
abilityDelegator = AbilityDelegatorRegistry.getAbilityDelegator();
abilityDelegator.executeShellCommand(cmd, (err: any, data: any) => {
console.info('executeShellCommand callback, result: ', err);
console.info('executeShellCommand callback, data: ', data);
abilityDelegator.executeShellCommand(cmd, (error: any, data: any) => {
if (error && error.code !== 0) {
console.error('executeShellCommand fail, error: ${JSON.stringify(error)}');
} else {
console.log('executeShellCommand success, data: ${JSON.stringify(data)}');
}
});
```
......@@ -1916,7 +1916,7 @@ Sets a label for this UIAbility in the mission. This API uses a promise to retur
setMissionIcon(icon: image.PixelMap, callback:AsyncCallback\<void>): void;
Sets an icon for this ability in the mission. This API uses an asynchronous callback to return the result.
Sets an icon for this ability in the mission. This API uses an asynchronous callback to return the result. The maximum size of the icon is 600 MB.
**System capability**: SystemCapability.Ability.AbilityRuntime.Core
......@@ -1966,7 +1966,7 @@ Sets an icon for this ability in the mission. This API uses an asynchronous call
setMissionIcon(icon: image.PixelMap): Promise\<void>;
Sets an icon for this ability in the mission. This API uses a promise to return the result.
Sets an icon for this ability in the mission. This API uses a promise to return the result. The maximum size of the icon is 600 MB.
**System capability**: SystemCapability.Ability.AbilityRuntime.Core
......@@ -2112,7 +2112,7 @@ try {
return;
}
// Carry out normal service processing.
console.info('requestDialogService succeed, result = ' + JSON.stringify(result));
console.info('requestDialogService succeed, result = ${JSON.stringify(result)}');
});
} catch (err) {
// Process input parameter errors.
......@@ -2160,7 +2160,7 @@ try {
this.context.requestDialogService(want)
.then((result) => {
// Carry out normal service processing.
console.info('requestDialogService succeed, result = ' + JSON.stringify(result));
console.info('requestDialogService succeed, result = ${JSON.stringify(result)}');
})
.catch((err) => {
// Process service logic errors.
......
......@@ -58,7 +58,7 @@ Starts an ability. This API uses an asynchronous callback to return the result.
this.context.startAbility(want, options, (error) => {
if (error.code) {
// Process service logic errors.
console.log('startAbility failed, error.code: ${JSON.stringify(error.code)}, error.message: ${JSON.stringify(error.message)}');
console.error('startAbility failed, error.code: ${JSON.stringify(error.code)}, error.message: ${JSON.stringify(error.message)}');
return;
}
// Carry out normal service processing.
......@@ -110,7 +110,7 @@ Starts an ability. This API uses a promise to return the result.
})
.catch((error) => {
// Process service logic errors.
console.log('startAbility failed, error.code: ${JSON.stringify(error.code)}, error.message: ${JSON.stringify(error.message)}');
console.error('startAbility failed, error.code: ${JSON.stringify(error.code)}, error.message: ${JSON.stringify(error.message)}');
});
} catch (paramError) {
// Process input parameter errors.
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册