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

!15042 翻译完成:14256 文档资料描述优化修改

Merge pull request !15042 from wusongqing/TR14256
......@@ -184,7 +184,7 @@
- [@ohos.i18n (Internationalization)](js-apis-i18n.md)
- [@ohos.intl (Internationalization)](js-apis-intl.md)
- [@ohos.resourceManager (Resource Manager)](js-apis-resource-manager.md)
- Resource Scheduling
- Background Tasks
- [@ohos.distributedMissionManager (Distributed Mission Management)](js-apis-distributedMissionManager.md)
- [@ohos.reminderAgentManager (Reminder Agent Management)](js-apis-reminderAgentManager.md)
- [@ohos.resourceschedule.backgroundTaskManager (Background Task Management)](js-apis-resourceschedule-backgroundTaskManager.md)
......@@ -210,10 +210,10 @@
- [@ohos.data.distributedDataObject (Distributed Data Object)](js-apis-data-distributedobject.md)
- [@ohos.data.distributedKVStore (Distributed KV Store)](js-apis-distributedKVStore.md)
- [@ohos.data.preferences (Preferences)](js-apis-data-preferences.md)
- [@ohos.data.relationalStore (ϵݿ)](js-apis-data-relationalStore.md)
- [@ohos.data.relationalStore (RDB Store)](js-apis-data-relationalStore.md)
- [@ohos.data.ValuesBucket (Value Bucket)](js-apis-data-valuesBucket.md)
- data/rdb
- [resultSet](js-apis-data-resultset.md)
- [resultSet (Result Set)](js-apis-data-resultset.md)
- File Management
- [@ohos.file.environment (Directory Environment Capability)](js-apis-file-environment.md)
- [@ohos.file.fileAccess (User File Access and Management)](js-apis-fileAccess.md)
......@@ -277,7 +277,7 @@
- [@ohos.InputMethodSubtype (Input Method Subtype)](js-apis-inputmethod-subtype.md)
- [@ohos.pasteboard (Pasteboard)](js-apis-pasteboard.md)
- [@ohos.screenLock (Screenlock)](js-apis-screen-lock.md)
- [@ohos.systemTime (System Time and Time Zone)](js-apis-system-time.md)
- [@ohos.systemDateTime (System Time and Time Zone)](js-apis-system-date-time.md)
- [@ohos.systemTimer (System Timer)](js-apis-system-timer.md)
- [@ohos.wallpaper (Wallpaper)](js-apis-wallpaper.md)
- [@ohos.web.webview (Webview)](js-apis-webview.md)
......@@ -369,6 +369,7 @@
- [@ohos.reminderAgent (Reminder Agent)](js-apis-reminderAgent.md)
- [@ohos.statfs (statfs)](js-apis-statfs.md)
- [@ohos.systemParameter (System Parameter)](js-apis-system-parameter.md)
- [@ohos.systemTime (System Time and Time Zone)](js-apis-system-time.md)
- [@ohos.usb (USB Management)](js-apis-usb-deprecated.md)
- [@system.app (Application Context)](js-apis-system-app.md)
- [@system.battery (Battery Information)](js-apis-system-battery.md)
......
......@@ -26,7 +26,7 @@ For details, see [Permission Levels](../../security/accesstoken-overview.md#perm
## distributedBundle.getRemoteAbilityInfo<sup>deprecated<sup>
> This API is deprecated since API version 9. You are advised to use [getRemoteAbilityInfo(@ohos.bundle.distributedBundle)](js-apis-distributedBundle.md) instead.
> This API is deprecated since API version 9. You are advised to use [getRemoteAbilityInfo(@ohos.bundle.distributedBundleManager)](js-apis-distributedBundleManager.md) instead.
getRemoteAbilityInfo(elementName: ElementName, callback: AsyncCallback&lt;RemoteAbilityInfo&gt;): void;
......@@ -55,7 +55,7 @@ This is a system API and cannot be called by third-party applications.
## distributedBundle.getRemoteAbilityInfo<sup>deprecated<sup>
> This API is deprecated since API version 9. You are advised to use [getRemoteAbilityInfo(@ohos.bundle.distributedBundle)](js-apis-distributedBundle.md) instead.
> This API is deprecated since API version 9. You are advised to use [getRemoteAbilityInfo(@ohos.bundle.distributedBundleManager)](js-apis-distributedBundleManager.md) instead.
getRemoteAbilityInfo(elementName: ElementName): Promise&lt;RemoteAbilityInfo&gt;
......@@ -87,7 +87,7 @@ This is a system API and cannot be called by third-party applications.
## distributedBundle.getRemoteAbilityInfos<sup>deprecated<sup>
> This API is deprecated since API version 9. You are advised to use [getRemoteAbilityInfo(@ohos.bundle.distributedBundle)](js-apis-distributedBundle.md) instead.
> This API is deprecated since API version 9. You are advised to use [getRemoteAbilityInfo(@ohos.bundle.distributedBundleManager)](js-apis-distributedBundleManager.md) instead.
getRemoteAbilityInfos(elementNames: Array&lt;ElementName&gt;, callback: AsyncCallback&lt;Array&lt;RemoteAbilityInfo&gt;&gt;): void;
......@@ -116,7 +116,7 @@ This is a system API and cannot be called by third-party applications.
## distributedBundle.getRemoteAbilityInfos<sup>deprecated<sup>
> This API is deprecated since API version 9. You are advised to use [getRemoteAbilityInfo(@ohos.bundle.distributedBundle)](js-apis-distributedBundle.md) instead.
> This API is deprecated since API version 9. You are advised to use [getRemoteAbilityInfo(@ohos.bundle.distributedBundleManager)](js-apis-distributedBundleManager.md) instead.
getRemoteAbilityInfos(elementNames: Array&lt;ElementName&gt;): Promise&lt;Array&lt;RemoteAbilityInfo&gt;&gt;
......
......@@ -48,7 +48,7 @@ import UIAbility from '@ohos.app.ability.UIAbility';
class MyAbility extends UIAbility {
onCreate(want, launchParam) {
if (launchParam.launchReason === AbilityConstant.LaunchReason.START_ABILITY) {
console.log("The ability has been started by the way of startAbility.");
console.log('The ability has been started by the way of startAbility.');
}
}
}
......@@ -74,7 +74,7 @@ import UIAbility from '@ohos.app.ability.UIAbility';
class MyAbility extends UIAbility {
onCreate(want, launchParam) {
if (launchParam.lastExitReason === AbilityConstant.LastExitReason.ABILITY_NOT_RESPONDING) {
console.log("The ability has exit last because the ability was not responding.");
console.log('The ability has exit last because the ability was not responding.');
}
}
}
......@@ -114,16 +114,16 @@ Enumerates the window modes in which an ability can be displayed at startup. It
| --- | --- | --- |
| WINDOW_MODE_UNDEFINED | 0 | Undefined window mode. |
| WINDOW_MODE_FULLSCREEN | 1 | The ability is displayed in full screen. |
| WINDOW_MODE_SPLIT_PRIMARY | 100 | The ability is displayed in the primary window in split-screen mode. |
| WINDOW_MODE_SPLIT_SECONDARY | 101 | The ability is displayed in the secondary window in split-screen mode. |
| WINDOW_MODE_SPLIT_PRIMARY | 100 | The left screen in horizontal direction or the upper screen in vertical direction is the primary window. |
| WINDOW_MODE_SPLIT_SECONDARY | 101 | The right screen in horizontal direction or the lower screen in vertical direction is the secondary window. |
| WINDOW_MODE_FLOATING | 102 | The ability is displayed in a floating window.|
**Example**
```ts
let want = {
bundleName: "com.example.myapplication",
abilityName: "EntryAbility"
bundleName: 'com.test.example',
abilityName: 'MainAbility'
};
let option = {
windowMode: AbilityConstant.WindowMode.WINDOW_MODE_FULLSCREEN
......@@ -131,9 +131,9 @@ let option = {
// Ensure that the context is obtained.
this.context.startAbility(want, option).then(()={
console.log("Succeed to start ability.");
console.log('Succeed to start ability.');
}).catch((error)=>{
console.log("Failed to start ability with error: " + JSON.stringify(error));
console.log('Failed to start ability with error: ' + JSON.stringify(error));
});
```
......@@ -157,7 +157,7 @@ import UIAbility from '@ohos.app.ability.UIAbility';
class MyAbility extends UIAbility {
onMemoryLevel(level) {
if (level === AbilityConstant.MemoryLevel.MEMORY_LEVEL_CRITICAL) {
console.log("The memory of device is critical, please release some memory.");
console.log('The memory of device is critical, please release some memory.');
}
}
}
......@@ -209,7 +209,7 @@ import UIAbility from '@ohos.app.ability.UIAbility';
class MyAbility extends UIAbility {
onSaveState(reason, wantParam) {
if (reason === AbilityConstant.StateType.CONTINUATION) {
console.log("Save the ability data when the ability continuation.");
console.log('Save the ability data when the ability continuation.');
}
return AbilityConstant.OnSaveResult.ALL_AGREE;
}
......
......@@ -49,14 +49,14 @@ import AbilityDelegatorRegistry from '@ohos.app.ability.abilityDelegatorRegistry
let abilityDelegator = AbilityDelegatorRegistry.getAbilityDelegator();
let want = {
bundleName: "com.example.myapplication",
abilityName: "EntryAbility"
bundleName: 'com.ohos.example',
abilityName: 'MainAbility'
};
abilityDelegator.startAbility(want, (err) => {
if (err.code !== 0) {
console.log("Success start ability.");
console.log('Success start ability.');
} else {
console.log("Failed start ability, error: " + JSON.stringify(err));
console.log('Failed start ability, error: ' + JSON.stringify(err));
}
})
```
......@@ -81,8 +81,8 @@ Obtains an [AbilityDelegatorArgs](js-apis-inner-application-abilityDelegatorArgs
import AbilityDelegatorRegistry from '@ohos.app.ability.abilityDelegatorRegistry';
let args = AbilityDelegatorRegistry.getArguments();
console.info("getArguments bundleName:" + args.bundleName);
console.info("getArguments parameters:" + JSON.stringify(args.parameters));
console.info("getArguments testCaseNames:" + args.testCaseNames);
console.info("getArguments testRunnerClassName:" + args.testRunnerClassName);
console.info('getArguments bundleName:' + args.bundleName);
console.info('getArguments parameters:' + JSON.stringify(args.parameters));
console.info('getArguments testCaseNames:' + args.testCaseNames);
console.info('getArguments testRunnerClassName:' + args.testRunnerClassName);
```
......@@ -11,7 +11,7 @@ The **AbilityLifecycleCallback** module defines the callbacks to receive lifecyc
## Modules to Import
```ts
import AbilityLifecycleCallback from "@ohos.app.ability.AbilityLifecycleCallback";
import AbilityLifecycleCallback from '@ohos.app.ability.AbilityLifecycleCallback';
```
......@@ -25,15 +25,15 @@ Called when an ability is created.
**Parameters**
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| ability | [UIAbility](js-apis-app-ability-uiAbility.md) | Yes| **Ability** object.|
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| ability | [UIAbility](js-apis-app-ability-uiAbility.md) | Yes| **Ability** object.|
**Example**
```ts
let abilityLifecycleCallback = {
onAbilityCreate(ability){
console.log("AbilityLifecycleCallback onAbilityCreate.");
console.log('AbilityLifecycleCallback onAbilityCreate.');
}
};
```
......@@ -48,16 +48,16 @@ Called when the window stage of an ability is created.
**Parameters**
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| ability | [UIAbility](js-apis-app-ability-uiAbility.md) | Yes| **Ability** object.|
| windowStage | [window.WindowStage](js-apis-window.md#windowstage9) | Yes| **WindowStage** object.|
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| ability | [UIAbility](js-apis-app-ability-uiAbility.md) | Yes| **Ability** object.|
| windowStage | [window.WindowStage](js-apis-window.md#windowstage9) | Yes| **WindowStage** object.|
**Example**
```ts
let abilityLifecycleCallback = {
onWindowStageCreate(ability, windowStage){
console.log("AbilityLifecycleCallback onWindowStageCreate.");
console.log('AbilityLifecycleCallback onWindowStageCreate.');
}
};
```
......@@ -72,16 +72,16 @@ Called when the window stage of an ability gains focus.
**Parameters**
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| ability | [UIAbility](js-apis-app-ability-uiAbility.md) | Yes| **Ability** object.|
| windowStage | [window.WindowStage](js-apis-window.md#windowstage9) | Yes| **WindowStage** object.|
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| ability | [UIAbility](js-apis-app-ability-uiAbility.md) | Yes| **Ability** object.|
| windowStage | [window.WindowStage](js-apis-window.md#windowstage9) | Yes| **WindowStage** object.|
**Example**
```ts
let abilityLifecycleCallback = {
onWindowStageActive(ability, windowStage){
console.log("AbilityLifecycleCallback onWindowStageActive.");
console.log('AbilityLifecycleCallback onWindowStageActive.');
}
};
```
......@@ -96,16 +96,16 @@ Called when the window stage of an ability loses focus.
**Parameters**
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| ability | [UIAbility](js-apis-app-ability-uiAbility.md) | Yes| **Ability** object.|
| windowStage | [window.WindowStage](js-apis-window.md#windowstage9) | Yes| **WindowStage** object.|
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| ability | [UIAbility](js-apis-app-ability-uiAbility.md) | Yes| **Ability** object.|
| windowStage | [window.WindowStage](js-apis-window.md#windowstage9) | Yes| **WindowStage** object.|
**Example**
```ts
let abilityLifecycleCallback = {
onWindowStageInactive(ability, windowStage){
console.log("AbilityLifecycleCallback onWindowStageInactive.");
console.log('AbilityLifecycleCallback onWindowStageInactive.');
}
};
```
......@@ -120,16 +120,16 @@ Called when the window stage of an ability is destroyed.
**Parameters**
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| ability | [UIAbility](js-apis-app-ability-uiAbility.md) | Yes| **Ability** object.|
| windowStage | [window.WindowStage](js-apis-window.md#windowstage9) | Yes| **WindowStage** object.|
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| ability | [UIAbility](js-apis-app-ability-uiAbility.md) | Yes| **Ability** object.|
| windowStage | [window.WindowStage](js-apis-window.md#windowstage9) | Yes| **WindowStage** object.|
**Example**
```ts
let abilityLifecycleCallback = {
onWindowStageDestroy(ability, windowStage){
console.log("AbilityLifecycleCallback onWindowStageDestroy.");
console.log('AbilityLifecycleCallback onWindowStageDestroy.');
}
};
```
......@@ -144,15 +144,15 @@ Called when an ability is destroyed.
**Parameters**
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| ability | [UIAbility](js-apis-app-ability-uiAbility.md) | Yes| **Ability** object.|
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| ability | [UIAbility](js-apis-app-ability-uiAbility.md) | Yes| **Ability** object.|
**Example**
```ts
let abilityLifecycleCallback = {
onAbilityDestroy(ability){
console.log("AbilityLifecycleCallback onAbilityDestroy.");
console.log('AbilityLifecycleCallback onAbilityDestroy.');
}
};
```
......@@ -167,15 +167,15 @@ Called when an ability is switched from the background to the foreground.
**Parameters**
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| ability | [UIAbility](js-apis-app-ability-uiAbility.md) | Yes| **Ability** object.|
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| ability | [UIAbility](js-apis-app-ability-uiAbility.md) | Yes| **Ability** object.|
**Example**
```ts
let abilityLifecycleCallback = {
onAbilityForeground(ability){
console.log("AbilityLifecycleCallback onAbilityForeground.");
console.log('AbilityLifecycleCallback onAbilityForeground.');
}
};
```
......@@ -190,15 +190,15 @@ Called when an ability is switched from the foreground to the background.
**Parameters**
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| ability | [UIAbility](js-apis-app-ability-uiAbility.md) | Yes| **Ability** object.|
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| ability | [UIAbility](js-apis-app-ability-uiAbility.md) | Yes| **Ability** object.|
**Example**
```ts
let abilityLifecycleCallback = {
onAbilityBackground(ability){
console.log("AbilityLifecycleCallback onAbilityBackground.");
console.log('AbilityLifecycleCallback onAbilityBackground.');
}
};
```
......@@ -213,15 +213,15 @@ Called when an ability is continued on another device.
**Parameters**
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| ability | [UIAbility](js-apis-app-ability-uiAbility.md) | Yes| **Ability** object.|
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| ability | [UIAbility](js-apis-app-ability-uiAbility.md) | Yes| **Ability** object.|
**Example**
```ts
let abilityLifecycleCallback = {
onAbilityContinue(ability){
console.log("AbilityLifecycleCallback onAbilityContinue.");
console.log('AbilityLifecycleCallback onAbilityContinue.');
}
};
```
......@@ -232,52 +232,52 @@ let abilityLifecycleCallback = {
MyFirstAbility.ts
```ts
import AbilityLifecycleCallback from "@ohos.app.ability.AbilityLifecycleCallback";
import AbilityStage from "@ohos.app.ability.AbilityStage";
import AbilityLifecycleCallback from '@ohos.app.ability.AbilityLifecycleCallback';
import AbilityStage from '@ohos.app.ability.AbilityStage';
import UIAbility from '@ohos.app.ability.UIAbility';
// Declare the ability lifecycle callbacks. A listener can be registered in applicationContext only after all the callbacks are configured.
let abilityLifecycleCallback = {
onAbilityCreate(ability){
console.log("AbilityLifecycleCallback onAbilityCreate.");
console.log('AbilityLifecycleCallback onAbilityCreate.');
},
onWindowStageCreate(ability, windowStage){
console.log("AbilityLifecycleCallback onWindowStageCreate.");
console.log('AbilityLifecycleCallback onWindowStageCreate.');
},
onWindowStageActive(ability, windowStage){
console.log("AbilityLifecycleCallback onWindowStageActive.");
console.log('AbilityLifecycleCallback onWindowStageActive.');
},
onWindowStageInactive(ability, windowStage){
console.log("AbilityLifecycleCallback onWindowStageInactive.");
console.log('AbilityLifecycleCallback onWindowStageInactive.');
},
onWindowStageDestroy(ability, windowStage){
console.log("AbilityLifecycleCallback onWindowStageDestroy.");
console.log('AbilityLifecycleCallback onWindowStageDestroy.');
},
onAbilityDestroy(ability){
console.log("AbilityLifecycleCallback onAbilityDestroy.");
console.log('AbilityLifecycleCallback onAbilityDestroy.');
},
onAbilityForeground(ability){
console.log("AbilityLifecycleCallback onAbilityForeground.");
console.log('AbilityLifecycleCallback onAbilityForeground.');
},
onAbilityBackground(ability){
console.log("AbilityLifecycleCallback onAbilityBackground.");
console.log('AbilityLifecycleCallback onAbilityBackground.');
},
onAbilityContinue(ability){
console.log("AbilityLifecycleCallback onAbilityContinue.");
console.log('AbilityLifecycleCallback onAbilityContinue.');
}
};
export default class MyFirstAbility extends UIAbility {
onCreate() {
console.log("MyAbilityStage onCreate");
console.log('MyAbilityStage onCreate');
// 1. Obtain applicationContext through the context attribute.
let applicationContext = this.context.getApplicationContext();
// 2. Register the listener for the ability lifecycle changes through the applicationContext object.
try {
globalThis.lifecycleId = applicationContext.on("abilityLifecycle", abilityLifecycleCallback);
console.log("registerAbilityLifecycleCallback number: " + JSON.stringify(lifecycleId));
globalThis.lifecycleId = applicationContext.on('abilityLifecycle', abilityLifecycleCallback);
console.log('registerAbilityLifecycleCallback number: ' + JSON.stringify(lifecycleId));
} catch (paramError) {
console.log("error: " + paramError.code + " ," + paramError.message);
console.log('error: ' + paramError.code + ' ,' + paramError.message);
}
}
}
......@@ -285,17 +285,17 @@ export default class MyFirstAbility extends UIAbility {
MySecondAbility.ts
```ts
import UIAbility from "ohos.app.ability.UIAbility";
import UIAbility from 'ohos.app.ability.UIAbility';
export default class MySecondAbility extends UIAbility {
onDestroy() {
let applicationContext = this.context.getApplicationContext();
// 3. Deregister the listener for the environment changes through the applicationContext object.
applicationContext.off("abilityLifecycle", globalThis.lifecycleId, (error) => {
// 3. Deregister the listener for the ability lifecycle changes through the applicationContext object.
applicationContext.off('abilityLifecycle', globalThis.lifecycleId, (error) => {
if (error.code != 0) {
console.log("unregisterAbilityLifecycleCallback failed, error: " + JSON.stringify(error));
console.log('unregisterAbilityLifecycleCallback failed, error: ' + JSON.stringify(error));
} else {
console.log("unregisterAbilityLifecycleCallback success.");
console.log('unregisterAbilityLifecycleCallback success.');
}
});
}
......
......@@ -71,9 +71,9 @@ const config = {
try {
abilityManager.updateConfiguration(config, (err) => {
if (err.code !== 0) {
console.log("updateConfiguration fail, err: " + JSON.stringify(err));
console.log('updateConfiguration fail, err: ' + JSON.stringify(err));
} else {
console.log("updateConfiguration success.");
console.log('updateConfiguration success.');
}
})
} catch (paramError) {
......@@ -170,9 +170,9 @@ import abilityManager from '@ohos.app.ability.abilityManager';
try {
abilityManager.getAbilityRunningInfos((err, data) => {
if (err.code !== 0) {
console.log("getAbilityRunningInfos fail, error: " + JSON.stringify(err));
console.log('getAbilityRunningInfos fail, error: ' + JSON.stringify(err));
} else {
console.log("getAbilityRunningInfos success, data: " + JSON.stringify(data));
console.log('getAbilityRunningInfos success, data: ' + JSON.stringify(data));
}
});
} catch (paramError) {
......@@ -195,7 +195,7 @@ Obtains the ability running information. This API uses a promise to return the r
| Type | Description |
| ---------------------------------------- | ------- |
| Promise\<Array\<[AbilityRunningInfo](js-apis-inner-application-abilityRunningInfo.md)>> | Callback used to return the API call result and the ability running information. You can perform error handling or custom processing in this callback.|
| Promise\<Array\<[AbilityRunningInfo](js-apis-inner-application-abilityRunningInfo.md)>> | Promise used to return the API call result and the ability running information. You can perform error handling or custom processing in this callback.|
**Error codes**
......@@ -212,9 +212,9 @@ import abilityManager from '@ohos.app.ability.abilityManager';
try {
abilityManager.getAbilityRunningInfos().then((data) => {
console.log("getAbilityRunningInfos success, data: " + JSON.stringify(data))
console.log('getAbilityRunningInfos success, data: ' + JSON.stringify(data));
}).catch((err) => {
console.log("getAbilityRunningInfos fail, err: " + JSON.stringify(err));
console.log('getAbilityRunningInfos fail, err: ' + JSON.stringify(err));
});
} catch (paramError) {
console.log('error.code: ' + JSON.stringify(paramError.code)
......@@ -257,9 +257,9 @@ let upperLimit = 10;
try {
abilityManager.getExtensionRunningInfos(upperLimit, (err, data) => {
if (err.code !== 0) {
console.log("getExtensionRunningInfos fail, err: " + JSON.stringify(err));
console.log('getExtensionRunningInfos fail, err: ' + JSON.stringify(err));
} else {
console.log("getExtensionRunningInfos success, data: " + JSON.stringify(data));
console.log('getExtensionRunningInfos success, data: ' + JSON.stringify(data));
}
});
} catch (paramError) {
......@@ -307,9 +307,9 @@ let upperLimit = 10;
try {
abilityManager.getExtensionRunningInfos(upperLimit).then((data) => {
console.log("getExtensionRunningInfos success, data: " + JSON.stringify(data));
console.log('getExtensionRunningInfos success, data: ' + JSON.stringify(data));
}).catch((err) => {
console.log("getExtensionRunningInfos fail, err: " + JSON.stringify(err));
console.log('getExtensionRunningInfos fail, err: ' + JSON.stringify(err));
})
} catch (paramError) {
console.log('error.code: ' + JSON.stringify(paramError.code)
......@@ -346,9 +346,9 @@ import abilityManager from '@ohos.app.ability.abilityManager';
abilityManager.getTopAbility((err, data) => {
if (err.code !== 0) {
console.log("getTopAbility fail, err: " + JSON.stringify(err));
console.log('getTopAbility fail, err: ' + JSON.stringify(err));
} else {
console.log("getTopAbility success, data: " + JSON.stringify(data));
console.log('getTopAbility success, data: ' + JSON.stringify(data));
}
});
```
......@@ -381,8 +381,8 @@ For details about the error codes, see [Ability Error Codes](../errorcodes/error
import abilityManager from '@ohos.app.ability.abilityManager';
abilityManager.getTopAbility().then((data) => {
console.log("getTopAbility success, data: " + JSON.stringify(data));
console.log('getTopAbility success, data: ' + JSON.stringify(data));
}).catch((err) => {
console.log("getTopAbility fail, err: " + JSON.stringify(err));
console.log('getTopAbility fail, err: ' + JSON.stringify(err));
})
```
......@@ -30,7 +30,7 @@ import AbilityStage from '@ohos.app.ability.AbilityStage';
class MyAbilityStage extends AbilityStage {
onCreate() {
console.log("MyAbilityStage.onCreate is called");
console.log('MyAbilityStage.onCreate is called');
}
}
```
......@@ -63,8 +63,8 @@ import AbilityStage from '@ohos.app.ability.AbilityStage';
class MyAbilityStage extends AbilityStage {
onAcceptWant(want) {
console.log("MyAbilityStage.onAcceptWant called");
return "com.example.test";
console.log('MyAbilityStage.onAcceptWant called');
return 'com.example.test';
}
}
```
......
......@@ -41,9 +41,9 @@ import appManager from '@ohos.app.ability.appManager';
appManager.isRunningInStabilityTest((err, flag) => {
if (err.code !== 0) {
console.log("isRunningInStabilityTest faile, err: " + JSON.stringify(err));
console.log('isRunningInStabilityTest faile, err: ' + JSON.stringify(err));
} else {
console.log("The result of isRunningInStabilityTest is:" + JSON.stringify(flag));
console.log('The result of isRunningInStabilityTest is:' + JSON.stringify(flag));
}
})
```
......@@ -77,9 +77,9 @@ For details about the error codes, see [Ability Error Codes](../errorcodes/error
import appManager from '@ohos.app.ability.appManager';
appManager.isRunningInStabilityTest().then((flag) => {
console.log("The result of isRunningInStabilityTest is:" + JSON.stringify(flag));
console.log('The result of isRunningInStabilityTest is:' + JSON.stringify(flag));
}).catch((error) => {
console.log("error:" + JSON.stringify(error));
console.log('error:' + JSON.stringify(error));
});
```
......@@ -112,9 +112,9 @@ For details about the error codes, see [Ability Error Codes](../errorcodes/error
import appManager from '@ohos.app.ability.appManager';
appManager.isRamConstrainedDevice().then((data) => {
console.log("The result of isRamConstrainedDevice is:" + JSON.stringify(data));
console.log('The result of isRamConstrainedDevice is:' + JSON.stringify(data));
}).catch((error) => {
console.log("error:" + JSON.stringify(error));
console.log('error:' + JSON.stringify(error));
});
```
......@@ -147,9 +147,9 @@ import appManager from '@ohos.app.ability.appManager';
appManager.isRamConstrainedDevice((err, data) => {
if (err.code !== 0) {
console.log("isRamConstrainedDevice faile, err: " + JSON.stringify(err));
console.log('isRamConstrainedDevice faile, err: ' + JSON.stringify(err));
} else {
console.log("The result of isRamConstrainedDevice is:" + JSON.stringify(data));
console.log('The result of isRamConstrainedDevice is:' + JSON.stringify(data));
}
})
```
......@@ -182,9 +182,9 @@ For details about the error codes, see [Ability Error Codes](../errorcodes/error
import appManager from '@ohos.app.ability.appManager';
appManager.getAppMemorySize().then((data) => {
console.log("The size of app memory is:" + JSON.stringify(data));
console.log('The size of app memory is:' + JSON.stringify(data));
}).catch((error) => {
console.log("error:" + JSON.stringify(error));
console.log('error:' + JSON.stringify(error));
});
```
......@@ -217,9 +217,9 @@ import appManager from '@ohos.app.ability.appManager';
appManager.getAppMemorySize((err, data) => {
if (err.code !== 0) {
console.log("getAppMemorySize faile, err: " + JSON.stringify(err));
console.log('getAppMemorySize faile, err: ' + JSON.stringify(err));
} else {
console.log("The size of app memory is:" + JSON.stringify(data));
console.log('The size of app memory is:' + JSON.stringify(data));
}
})
```
......@@ -256,9 +256,9 @@ For details about the error codes, see [Ability Error Codes](../errorcodes/error
import appManager from '@ohos.app.ability.appManager';
appManager.getProcessRunningInformation().then((data) => {
console.log("The process running information is:" + JSON.stringify(data));
console.log('The process running information is:' + JSON.stringify(data));
}).catch((error) => {
console.log("error:" + JSON.stringify(error));
console.log('error:' + JSON.stringify(error));
});
```
......@@ -295,16 +295,16 @@ import appManager from '@ohos.app.ability.appManager';
appManager.getProcessRunningInformation((err, data) => {
if (err.code !== 0) {
console.log("getProcessRunningInformation faile, err: " + JSON.stringify(err));
console.log('getProcessRunningInformation faile, err: ' + JSON.stringify(err));
} else {
console.log("The process running information is:" + JSON.stringify(data));
console.log('The process running information is:' + JSON.stringify(data));
}
})
```
## appManager.on
on(type: "applicationState", observer: ApplicationStateObserver): number;
on(type: 'applicationState', observer: ApplicationStateObserver): number;
Registers an observer to listen for the state changes of all applications.
......@@ -318,7 +318,7 @@ Registers an observer to listen for the state changes of all applications.
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| type | string | Yes| Type of the API to call. It is fixed at **"applicationState"**.|
| type | string | Yes| Type of the API to call. It is fixed at **'applicationState'**.|
| observer | [ApplicationStateObserver](./js-apis-inner-application-applicationStateObserver.md) | Yes| Application state observer, which is used to observe the lifecycle change of an application.|
**Return value**
......@@ -367,7 +367,7 @@ try {
## appManager.on
on(type: "applicationState", observer: ApplicationStateObserver, bundleNameList: Array\<string>): number;
on(type: 'applicationState', observer: ApplicationStateObserver, bundleNameList: Array\<string>): number;
Registers an observer to listen for the state changes of a specified application.
......@@ -381,7 +381,7 @@ Registers an observer to listen for the state changes of a specified application
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| type | string | Yes| Type of the API to call. It is fixed at **"applicationState"**.|
| type | string | Yes| Type of the API to call. It is fixed at **'applicationState'**.|
| observer | [ApplicationStateObserver](./js-apis-inner-application-applicationStateObserver.md) | Yes| Application state observer, which is used to observe the lifecycle change of an application.|
| bundleNameList | `Array<string>` | Yes| **bundleName** array of the application. A maximum of 128 bundle names can be passed.|
......@@ -423,7 +423,7 @@ let applicationStateObserver = {
}
let bundleNameList = ['bundleName1', 'bundleName2'];
try {
const observerId = appManager.on("applicationState", applicationStateObserver, bundleNameList);
const observerId = appManager.on('applicationState', applicationStateObserver, bundleNameList);
console.log(`[appManager] observerCode: ${observerId}`);
} catch (paramError) {
console.log(`[appManager] error: ${paramError.code}, ${paramError.message} `);
......@@ -432,7 +432,7 @@ try {
## appManager.off
off(type: "applicationState", observerId: number, callback: AsyncCallback\<void>): void;
off(type: 'applicationState', observerId: number, callback: AsyncCallback\<void>): void;
Deregisters the application state observer. This API uses an asynchronous callback to return the result.
......@@ -446,7 +446,7 @@ Deregisters the application state observer. This API uses an asynchronous callba
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| type | string | Yes| Type of the API to call. It is fixed at **"applicationState"**.|
| type | string | Yes| Type of the API to call. It is fixed at **'applicationState'**.|
| observerId | number | Yes| Digital code of the observer.|
| callback | AsyncCallback\<void> | Yes| Callback used to return the API call result. You can perform error handling or custom processing in this callback.|
......@@ -485,7 +485,7 @@ let applicationStateObserver = {
}
let bundleNameList = ['bundleName1', 'bundleName2'];
try {
observerId = appManager.on("applicationState", applicationStateObserver, bundleNameList);
observerId = appManager.on('applicationState', applicationStateObserver, bundleNameList);
console.log(`[appManager] observerCode: ${observerId}`);
} catch (paramError) {
console.log(`[appManager] error: ${paramError.code}, ${paramError.message} `);
......@@ -494,13 +494,13 @@ try {
// 2. Deregister the application state observer.
function unregisterApplicationStateObserverCallback(err) {
if (err.code !== 0) {
console.log("unregisterApplicationStateObserverCallback faile, err: " + JSON.stringify(err));
console.log('unregisterApplicationStateObserverCallback faile, err: ' + JSON.stringify(err));
} else {
console.log("unregisterApplicationStateObserverCallback success.");
console.log('unregisterApplicationStateObserverCallback success.');
}
}
try {
appManager.off("applicationState", observerId, unregisterApplicationStateObserverCallback);
appManager.off('applicationState', observerId, unregisterApplicationStateObserverCallback);
} catch (paramError) {
console.log('error: ' + paramError.code + ', ' + paramError.message);
}
......@@ -508,7 +508,7 @@ try {
## appManager.off
off(type: "applicationState", observerId: number): Promise\<void>;
off(type: 'applicationState', observerId: number): Promise\<void>;
Deregisters the application state observer. This API uses an asynchronous callback to return the result.
......@@ -522,7 +522,7 @@ Deregisters the application state observer. This API uses an asynchronous callba
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| type | string | Yes| Type of the API to call. It is fixed at **"applicationState"**.|
| type | string | Yes| Type of the API to call. It is fixed at **'applicationState'**.|
| observerId | number | Yes| Digital code of the observer.|
**Return value**
......@@ -566,7 +566,7 @@ let applicationStateObserver = {
}
let bundleNameList = ['bundleName1', 'bundleName2'];
try {
observerId = appManager.on("applicationState", applicationStateObserver, bundleNameList);
observerId = appManager.on('applicationState', applicationStateObserver, bundleNameList);
console.log(`[appManager] observerCode: ${observerId}`);
} catch (paramError) {
console.log(`[appManager] error: ${paramError.code}, ${paramError.message} `);
......@@ -574,10 +574,10 @@ try {
// 2. Deregister the application state observer.
try {
appManager.off("applicationState", observerId).then((data) => {
console.log("unregisterApplicationStateObserver success, data: " + JSON.stringify(data));
appManager.off('applicationState', observerId).then((data) => {
console.log('unregisterApplicationStateObserver success, data: ' + JSON.stringify(data));
}).catch((err) => {
console.log("unregisterApplicationStateObserver faile, err: " + JSON.stringify(err));
console.log('unregisterApplicationStateObserver faile, err: ' + JSON.stringify(err));
})
} catch (paramError) {
console.log('error: ' + paramError.code + ', ' + paramError.message);
......@@ -617,15 +617,15 @@ import appManager from '@ohos.app.ability.appManager';
function getForegroundApplicationsCallback(err, data) {
if (err.code !== 0) {
console.log("getForegroundApplicationsCallback fail, err: " + JSON.stringify(err));
console.log('getForegroundApplicationsCallback fail, err: ' + JSON.stringify(err));
} else {
console.log("getForegroundApplicationsCallback success, data: " + JSON.stringify(data));
console.log('getForegroundApplicationsCallback success, data: ' + JSON.stringify(data));
}
}
try {
appManager.getForegroundApplications(getForegroundApplicationsCallback);
} catch (paramError) {
console.log("error: " + paramError.code + ", " + paramError.message);
console.log('error: ' + paramError.code + ', ' + paramError.message);
}
```
......@@ -661,9 +661,9 @@ For details about the error codes, see [Ability Error Codes](../errorcodes/error
import appManager from '@ohos.app.ability.appManager';
appManager.getForegroundApplications().then((data) => {
console.log("getForegroundApplications success, data: " + JSON.stringify(data));
console.log('getForegroundApplications success, data: ' + JSON.stringify(data));
}).catch((err) => {
console.log("getForegroundApplications fail, err: " + JSON.stringify(err));
console.log('getForegroundApplications fail, err: ' + JSON.stringify(err));
})
```
......@@ -703,12 +703,12 @@ let bundleName = 'bundleName';
let accountId = 0;
try {
appManager.killProcessWithAccount(bundleName, accountId).then(() => {
console.log("killProcessWithAccount success");
console.log('killProcessWithAccount success');
}).catch((err) => {
console.log("killProcessWithAccount fail, err: " + JSON.stringify(err));
console.error('killProcessWithAccount fail, err: ' + JSON.stringify(err));
})
} catch (paramError) {
console.log("error: " + paramError.code + ", " + paramError.message);
console.error('error: ' + paramError.code + ', ' + paramError.message);
}
```
......@@ -750,9 +750,9 @@ let bundleName = 'bundleName';
let accountId = 0;
function killProcessWithAccountCallback(err, data) {
if (err.code !== 0) {
console.log("killProcessWithAccountCallback fail, err: " + JSON.stringify(err));
console.log('killProcessWithAccountCallback fail, err: ' + JSON.stringify(err));
} else {
console.log("killProcessWithAccountCallback success.");
console.log('killProcessWithAccountCallback success.');
}
}
appManager.killProcessWithAccount(bundleName, accountId, killProcessWithAccountCallback);
......@@ -793,15 +793,15 @@ import appManager from '@ohos.app.ability.appManager';
let bundleName = 'bundleName';
function killProcessesByBundleNameCallback(err, data) {
if (err.code !== 0) {
console.log("killProcessesByBundleNameCallback fail, err: " + JSON.stringify(err));
console.log('killProcessesByBundleNameCallback fail, err: ' + JSON.stringify(err));
} else {
console.log("killProcessesByBundleNameCallback success.");
console.log('killProcessesByBundleNameCallback success.');
}
}
try {
appManager.killProcessesByBundleName(bundleName, killProcessesByBundleNameCallback);
} catch (paramError) {
console.log("error: " + paramError.code + ", " + paramError.message);
console.log('error: ' + paramError.code + ', ' + paramError.message);
}
```
......@@ -845,12 +845,12 @@ import appManager from '@ohos.app.ability.appManager';
let bundleName = 'bundleName';
try {
appManager.killProcessesByBundleName(bundleName).then((data) => {
console.log("killProcessesByBundleName success.");
console.log('killProcessesByBundleName success.');
}).catch((err) => {
console.log("killProcessesByBundleName fail, err: " + JSON.stringify(err));
console.log('killProcessesByBundleName fail, err: ' + JSON.stringify(err));
})
} catch (paramError) {
console.log("error: " + paramError.code + ", " + paramError.message);
console.log('error: ' + paramError.code + ', ' + paramError.message);
}
```
......@@ -889,15 +889,15 @@ import appManager from '@ohos.app.ability.appManager';
let bundleName = 'bundleName';
function clearUpApplicationDataCallback(err, data) {
if (err) {
console.log("clearUpApplicationDataCallback fail, err: " + JSON.stringify(err));
console.log('clearUpApplicationDataCallback fail, err: ' + JSON.stringify(err));
} else {
console.log("clearUpApplicationDataCallback success.");
console.log('clearUpApplicationDataCallback success.');
}
}
try {
appManager.clearUpApplicationData(bundleName, clearUpApplicationDataCallback);
} catch (paramError) {
console.log("error: " + paramError.code + ", " + paramError.message);
console.log('error: ' + paramError.code + ', ' + paramError.message);
}
```
......@@ -941,12 +941,12 @@ import appManager from '@ohos.app.ability.appManager';
let bundleName = 'bundleName';
try {
appManager.clearUpApplicationData(bundleName).then((data) => {
console.log("clearUpApplicationData success.");
console.log('clearUpApplicationData success.');
}).catch((err) => {
console.log("clearUpApplicationData fail, err: " + JSON.stringify(err));
console.log('clearUpApplicationData fail, err: ' + JSON.stringify(err));
})
} catch (paramError) {
console.log("error: " + paramError.code + ", " + paramError.message);
console.log('error: ' + paramError.code + ', ' + paramError.message);
}
```
......
......@@ -18,13 +18,13 @@ Enumerates the application restart flags. This enum is used as an input paramete
**System capability**: SystemCapability.Ability.AbilityRuntime.Core
| Name | Value | Description |
| ----------------------------- | ---- | ------------------------------------------------------------ |
| ALWAYS_RESTART | 0 | The application is restarted in all cases.|
| CPP_CRASH_NO_RESTART | 0x0001 | The application is not restarted in the case of CPP_CRASH.|
| JS_CRASH_NO_RESTART | 0x0002 | The application is not restarted in the case of JS_CRASH.|
| APP_FREEZE_NO_RESTART | 0x0004 | The application is not restarted in the case of APP_FREEZE.|
| NO_RESTART | 0xFFFF | The application is not restarted in any case.|
| Name | Value | Description |
| ---------- | ---- | ---------- |
| ALWAYS_RESTART | 0 | The application is restarted in all cases.|
| CPP_CRASH_NO_RESTART | 0x0001 | The application is not restarted in the case of CPP_CRASH. |
| JS_CRASH_NO_RESTART | 0x0002 | The application is not restarted in the case of JS_CRASH. |
| APP_FREEZE_NO_RESTART | 0x0004 | The application is not restarted in the case of APP_FREEZE. |
| NO_RESTART | 0xFFFF | The application is not restarted in any case.|
## appRecovery.SaveOccasionFlag
......@@ -99,15 +99,15 @@ import errorManager from '@ohos.app.ability.errorManager';
let observer = {
onUnhandledException(errorMsg) {
console.log('onUnhandledException, errorMsg: ', errorMsg)
console.log('onUnhandledException, errorMsg: ', errorMsg);
appRecovery.restartApp();
}
};
try {
errorManager.on("error", observer);
errorManager.on('error', observer);
} catch (paramError) {
console.log("error: " + paramError.code + ", " + paramError.message);
console.log('error: ' + paramError.code + ', ' + paramError.message);
}
```
......@@ -133,14 +133,14 @@ import errorManager from '@ohos.app.ability.errorManager';
let observer = {
onUnhandledException(errorMsg) {
console.log('onUnhandledException, errorMsg: ', errorMsg)
console.log('onUnhandledException, errorMsg: ', errorMsg);
appRecovery.saveAppState();
}
};
try {
errorManager.on("error", observer);
errorManager.on('error', observer);
} catch (paramError) {
console.log("error: " + paramError.code + ", " + paramError.message);
console.log('error: ' + paramError.code + ', ' + paramError.message);
}
```
# @ohos.app.ability.StartOptions (StartOptions)
**StartOptions** is used as an input parameter of [startAbility()](js-apis-inner-application-uiAbilityContext.md#uiabilitycontextstartability-1) to specify the window mode of an ability.
The **StartOptions** module implements ability startup options.
> **NOTE**
>
......@@ -16,9 +16,38 @@ import StartOptions from '@ohos.app.ability.StartOptions';
## Attributes
**System capability**: SystemCapability.Ability.AbilityRuntime.Core
**System API**: This is a system API and cannot be called by third-party applications.
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| [windowMode](js-apis-application-abilityConstant.md#abilityconstantwindowmode) | number | No| Window mode.|
| displayId | number | No| Display ID. The default value is **0**, indicating the current display.|
| [windowMode](js-apis-app-ability-abilityConstant.md#abilityconstantwindowmode) | number | No| Window mode.|
| displayId | number | No| Display ID.|
**Example**
```ts
import missionManager from '@ohos.app.ability.missionManager';
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));
return;
}
console.log('size = ' + missions.length);
console.log('missions = ' + JSON.stringify(missions));
let id = missions[0].missionId;
let startOptions = {
windowMode : 101,
displayId: 0
};
missionManager.moveMissionToFront(id, startOptions).then(() => {
console.log('moveMissionToFront is called ');
});
});
} catch (paramError) {
console.log('error: ' + paramError.code + ', ' + paramError.message);
}
```
# @ohos.app.form.FormExtensionAbility (FormExtensionAbility)
The **FormExtensionAbility** module provides lifecycle callbacks invoked when a widget is created, destroyed, or updated.
The **FormExtensionAbility** module provides APIs related to FormExtensionAbilities.
> **NOTE**
>
......@@ -19,7 +19,7 @@ import FormExtensionAbility from '@ohos.app.form.FormExtensionAbility';
| Name | Type | Readable| Writable| Description |
| ------- | ------------------------------------------------------------ | ---- | ---- | ------------------------------------------------------------ |
| context | [FormExtensionContext](js-apis-inner-application-formExtensionContext.md) | Yes | No | Context of the FormExtensionAbility. This context is inherited from [ExtensionContext](js-apis-inner-application-extensionContext.md).|
| context | [FormExtensionContext](js-apis-inner-application-formExtensionContext.md) | Yes | No | Context of the FormExtensionAbility. This context is inherited from **ExtensionContext**.|
## onAddForm
......@@ -33,7 +33,7 @@ Called to notify the widget provider that a **Form** instance (widget) has been
| Name| Type | Mandatory| Description |
| ------ | -------------------------------------- | ---- | ------------------------------------------------------------ |
| want | [Want](js-apis-application-want.md) | Yes | Want information related to the FormExtensionAbility, including the widget ID, name, and style. The information must be managed as persistent data to facilitate subsequent widget update and deletion.|
| want | [Want](js-apis-application-want.md) | Yes | Want information related to the ExtensionAbility, including the widget ID, name, and style. The information must be managed as persistent data to facilitate subsequent widget update and deletion.|
**Return value**
......@@ -45,19 +45,17 @@ Called to notify the widget provider that a **Form** instance (widget) has been
```ts
import FormExtensionAbility from '@ohos.app.form.FormExtensionAbility';
import formBindingData from '@ohos.app.form.formBindingData';
export default class MyFormExtensionAbility extends FormExtensionAbility {
onAddForm(want) {
console.log('FormExtensionAbility onAddForm, want:' + want.abilityName);
let dataObj1 = {
temperature: "11c",
"time": "11:00"
temperature:'11c',
'time':'11:00'
};
let obj1 = formBindingData.createFormBindingData(dataObj1);
return obj1;
}
};
}
```
## onCastToNormalForm
......@@ -77,20 +75,18 @@ Called to notify the widget provider that a temporary widget has been converted
**Example**
```ts
import FormExtensionAbility from '@ohos.app.form.FormExtensionAbility';
export default class MyFormExtensionAbility extends FormExtensionAbility {
onCastToNormalForm(formId) {
console.log('FormExtensionAbility onCastToNormalForm, formId:' + formId);
}
};
}
```
## onUpdateForm
onUpdateForm(formId: string): void
Called to notify the widget provider that a widget has been updated. After obtaining the latest data, your application should call [updateForm](js-apis-app-form-formProvider.md#updateform) of **formProvider** to update the widget data.
Called to notify the widget provider that a widget has been updated. After obtaining the latest data, your application should call **updateForm** of [FormExtensionContext](js-apis-inner-application-formExtensionContext.md) to update the widget data.
**System capability**: SystemCapability.Ability.Form
......@@ -103,24 +99,17 @@ Called to notify the widget provider that a widget has been updated. After obtai
**Example**
```ts
import FormExtensionAbility from '@ohos.app.form.FormExtensionAbility';
import formBindingData from '@ohos.app.form.formBindingData';
import formProvider from '@ohos.app.form.formProvider';
export default class MyFormExtensionAbility extends FormExtensionAbility {
onUpdateForm(formId) {
console.log('FormExtensionAbility onUpdateForm, formId:' + formId);
let obj2 = formBindingData.createFormBindingData({
temperature: "22c",
time: "22:00"
});
formProvider.updateForm(formId, obj2).then((data) => {
let obj2 = formBindingData.createFormBindingData({temperature:'22c', time:'22:00'});
this.context.updateForm(formId, obj2).then((data)=>{
console.log('FormExtensionAbility context updateForm, data:' + data);
}).catch((error) => {
console.error('Operation updateForm failed. Cause: ' + error);
});
}
};
console.error('Operation updateForm failed. Cause: ' + error);});
}
}
```
## onChangeFormVisibility
......@@ -140,28 +129,21 @@ Called to notify the widget provider of the change of visibility.
**Example**
```ts
import FormExtensionAbility from '@ohos.app.form.FormExtensionAbility';
import formBindingData from '@ohos.app.form.formBindingData'
import formProvider from '@ohos.app.form.formProvider';
import formBindingData from '@ohos.app.form.formBindingData';
export default class MyFormExtensionAbility extends FormExtensionAbility {
onChangeFormVisibility(newStatus) {
console.log('FormExtensionAbility onChangeFormVisibility, newStatus:' + newStatus);
let obj2 = formBindingData.createFormBindingData({
temperature: "22c",
time: "22:00"
});
for (let key in newStatus) {
console.log('FormExtensionAbility onChangeFormVisibility, key:' + key + ", value=" + newStatus[key]);
formProvider.updateForm(key, obj2).then((data) => {
console.log('FormExtensionAbility onChangeFormVisibility, newStatus:' + newStatus);
let obj2 = formBindingData.createFormBindingData({temperature:'22c', time:'22:00'});
for (let key in newStatus) {
console.log('FormExtensionAbility onChangeFormVisibility, key:' + key + ', value=' + newStatus[key]);
this.context.updateForm(key, obj2).then((data)=>{
console.log('FormExtensionAbility context updateForm, data:' + data);
}).catch((error) => {
console.error('Operation updateForm failed. Cause: ' + error);
});
}).catch((error) => {
console.error('Operation updateForm failed. Cause: ' + error);});
}
}
};
}
```
## onFormEvent
......@@ -182,13 +164,11 @@ Called to instruct the widget provider to receive and process the widget event.
**Example**
```ts
import FormExtensionAbility from '@ohos.app.form.FormExtensionAbility';
export default class MyFormExtensionAbility extends FormExtensionAbility {
export default class MyFormExtension extends FormExtensionAbility {
onFormEvent(formId, message) {
console.log('FormExtensionAbility onFormEvent, formId:' + formId + ", message:" + message);
console.log('FormExtensionAbility onFormEvent, formId:' + formId + ', message:' + message);
}
};
}
```
## onRemoveForm
......@@ -208,13 +188,11 @@ Called to notify the widget provider that a **Form** instance (widget) has been
**Example**
```ts
import FormExtensionAbility from '@ohos.app.form.FormExtensionAbility';
export default class MyFormExtensionAbility extends FormExtensionAbility {
onRemoveForm(formId) {
console.log('FormExtensionAbility onRemoveForm, formId:' + formId);
}
};
}
```
## onConfigurationUpdate
......@@ -234,13 +212,11 @@ Called when the configuration of the environment where the ability is running is
**Example**
```ts
import FormExtensionAbility from '@ohos.app.form.FormExtensionAbility';
export default class MyFormExtensionAbility extends FormExtensionAbility {
class MyFormExtensionAbility extends FormExtensionAbility {
onConfigurationUpdate(config) {
console.log('onConfigurationUpdate, config:' + JSON.stringify(config));
}
};
}
```
## onAcquireFormState
......@@ -260,15 +236,13 @@ Called when the widget provider receives the status query result of a widget. By
**Example**
```ts
import FormExtensionAbility from '@ohos.app.form.FormExtensionAbility';
import formInfo from '@ohos.app.form.formInfo';
export default class MyFormExtensionAbility extends FormExtensionAbility {
class MyFormExtensionAbility extends FormExtensionAbility {
onAcquireFormState(want) {
console.log('FormExtensionAbility onAcquireFormState, want:' + want);
return formInfo.FormState.UNKNOWN;
}
};
}
```
## onShareForm
......@@ -296,16 +270,14 @@ Called by the widget provider to receive shared widget data.
**Example**
```ts
import FormExtensionAbility from '@ohos.app.form.FormExtensionAbility';
export default class MyFormExtensionAbility extends FormExtensionAbility {
class MyFormExtensionAbility extends FormExtensionAbility {
onShareForm(formId) {
console.log('FormExtensionAbility onShareForm, formId:' + formId);
let wantParams = {
"temperature": "20",
"time": "2022-8-8 09:59",
'temperature':'20',
'time':'2022-8-8 09:59',
};
return wantParams;
}
};
}
```
......@@ -45,7 +45,7 @@ For details about the error codes, see [Bundle Error Codes](../errorcodes/errorc
| ID| Error Message |
| ------ | -------------------------------------- |
| 17700005 | The specified app ID is not found. |
| 17700005 | The specified app ID is empty string. |
**Example**
......@@ -91,7 +91,7 @@ For details about the error codes, see [Bundle Error Codes](../errorcodes/errorc
| ID| Error Message |
| ------ | -------------------------------------- |
| 17700005 | The specified app ID is not found. |
| 17700005 | The specified app ID is empty string. |
**Example**
......@@ -142,7 +142,7 @@ For details about the error codes, see [Bundle Error Codes](../errorcodes/errorc
| ID| Error Message |
| ------ | -------------------------------------- |
| 17700005 | The specified app ID is not found. |
| 17700005 | The specified app ID is empty string. |
**Example**
......@@ -186,7 +186,7 @@ For details about the error codes, see [Bundle Error Codes](../errorcodes/errorc
| ID| Error Message |
| ------ | -------------------------------------- |
| 17700005 | The specified app ID is not found. |
| 17700005 | The specified app ID is empty string. |
**Example**
......@@ -236,7 +236,7 @@ For details about the error codes, see [Bundle Error Codes](../errorcodes/errorc
| ID| Error Message |
| ------ | -------------------------------------- |
| 17700005 | The specified app ID is not found. |
| 17700005 | The specified app ID is empty string. |
**Example**
......@@ -280,7 +280,7 @@ For details about the error codes, see [Bundle Error Codes](../errorcodes/errorc
| ID| Error Message |
| ------ | -------------------------------------- |
| 17700005 | The specified app ID is not found. |
| 17700005 | The specified app ID is empty string. |
**Example**
......
# AbilityMonitor
The **AbilityMonitor** module provides monitors for abilities that meet specified conditions. The latest matched abilities are stored in an **AbilityMonitor** object.
> **NOTE**
>
> The initial APIs of this module are supported since API version 9. Newly added APIs will be marked with a superscript to indicate their earliest API version.
## Usage
The ability monitor is set by calling **addAbilityMonitor** in **abilityDelegator**.
```js
import AbilityDelegatorRegistry from '@ohos.application.abilityDelegatorRegistry'
var abilityDelegator;
function onAbilityCreateCallback(data) {
console.info("onAbilityCreateCallback");
}
var monitor = {
abilityName: "abilityname",
onAbilityCreate: onAbilityCreateCallback
}
abilityDelegator = AbilityDelegatorRegistry.getAbilityDelegator();
abilityDelegator.addAbilityMonitor(monitor, (err : any) => {
console.info("addAbilityMonitor callback");
});
```
## AbilityMonitor
Describes an ability monitor.
**System capability**: SystemCapability.Ability.AbilityRuntime.Core
| Name | Type | Readable| Writable| Description |
| ------------------------------------------------------------ | -------- | ---- | ---- | ------------------------------------------------------------ |
| abilityName | string | Yes | Yes | Name of the ability bound to the ability monitor. |
| onAbilityCreate?:(data: [Ability](js-apis-application-ability.md#Ability)) | function | Yes | Yes | Called when the ability is created.<br>If this attribute is not set, the corresponding lifecycle callback cannot be received. |
| onAbilityForeground?:(data: [Ability](js-apis-application-ability.md#Ability)) | function | Yes | Yes | Called when the ability starts to run in the foreground.<br>If this attribute is not set, the corresponding lifecycle callback cannot be received. |
| onAbilityBackground?:(data: [Ability](js-apis-application-ability.md#Ability)) | function | Yes | Yes | Called when the ability starts to run in the background.<br>If this attribute is not set, the corresponding lifecycle callback cannot be received. |
| onAbilityDestroy?:(data: [Ability](js-apis-application-ability.md#Ability)) | function | Yes | Yes | Called when the ability is destroyed.<br>If this attribute is not set, the corresponding lifecycle callback cannot be received. |
| onWindowStageCreate?:(data: [Ability](js-apis-application-ability.md#Ability)) | function | Yes | Yes | Called when the window stage is created.<br>If this attribute is not set, the corresponding lifecycle callback cannot be received. |
| onWindowStageRestore?:(data: [Ability](js-apis-application-ability.md#Ability)) | function | Yes | Yes | Called when the window stage is restored.<br>If this attribute is not set, the corresponding lifecycle callback cannot be received. |
| onWindowStageDestroy?:(data: [Ability](js-apis-application-ability.md#Ability)) | function | Yes | Yes | Called when the window stage is destroyed.<br>If this attribute is not set, the corresponding lifecycle callback cannot be received. |
......@@ -9,7 +9,7 @@ The **appManager** module implements application management. You can use the API
## Modules to Import
```ts
import appManager from '@ohos.application.appManager';
import app from '@ohos.application.appManager';
```
## appManager.isRunningInStabilityTest<sup>8+</sup>
......@@ -29,10 +29,10 @@ Checks whether this application is undergoing a stability test. This API uses an
**Example**
```ts
appManager.isRunningInStabilityTest((err, flag) => {
console.log('error:' + JSON.stringfy(err));
console.log('The result of isRunningInStabilityTest is:' + JSON.stringify(flag));
})
import app from '@ohos.application.appManager';
app.isRunningInStabilityTest((err, flag) => {
console.log('startAbility result:' + JSON.stringify(err));
});
```
......@@ -53,10 +53,11 @@ Checks whether this application is undergoing a stability test. This API uses a
**Example**
```ts
appManager.isRunningInStabilityTest().then((flag) => {
console.log('The result of isRunningInStabilityTest is:' + JSON.stringify(flag));
import app from '@ohos.application.appManager';
app.isRunningInStabilityTest().then((flag) => {
console.log('success:' + JSON.stringify(flag));
}).catch((error) => {
console.log('error:' + JSON.stringify(error));
console.log('failed:' + JSON.stringify(error));
});
```
......@@ -78,10 +79,10 @@ Checks whether this application is running on a RAM constrained device. This API
**Example**
```ts
appManager.isRamConstrainedDevice().then((data) => {
console.log('The result of isRamConstrainedDevice is:' + JSON.stringify(data));
app.isRamConstrainedDevice().then((data) => {
console.log('success:' + JSON.stringify(data));
}).catch((error) => {
console.log('error:' + JSON.stringify(error));
console.log('failed:' + JSON.stringify(error));
});
```
......@@ -102,10 +103,10 @@ Checks whether this application is running on a RAM constrained device. This API
**Example**
```ts
appManager.isRamConstrainedDevice((err, data) => {
console.log('error:' + JSON.stringify(err));
console.log('The result of isRamConstrainedDevice is:' + JSON.stringify(data));
})
app.isRamConstrainedDevice((err, data) => {
console.log('startAbility result failed:' + JSON.stringify(err));
console.log('startAbility result success:' + JSON.stringify(data));
});
```
## appManager.getAppMemorySize
......@@ -120,15 +121,15 @@ Obtains the memory size of this application. This API uses a promise to return t
| Type| Description|
| -------- | -------- |
| Promise&lt;number&gt; | Size of the application memory.|
| Promise&lt;number&gt; | Promise used to return the memory size, in MB.|
**Example**
```ts
appManager.getAppMemorySize().then((data) => {
console.log('The size of app memory is:' + JSON.stringify(data));
app.getAppMemorySize().then((data) => {
console.log('success:' + JSON.stringify(data));
}).catch((error) => {
console.log('error:' + JSON.stringify(error));
console.log('failed:' + JSON.stringify(error));
});
```
......@@ -144,15 +145,15 @@ Obtains the memory size of this application. This API uses an asynchronous callb
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| callback | AsyncCallback&lt;number&gt; | Yes| Size of the application memory.|
| callback | AsyncCallback&lt;number&gt; | Yes| Callback used to return the memory size, in MB.|
**Example**
```ts
appManager.getAppMemorySize((err, data) => {
console.log('error:' + JSON.stringify(err));
console.log('The size of app memory is:' + JSON.stringify(data));
})
app.getAppMemorySize((err, data) => {
console.log('startAbility result failed :' + JSON.stringify(err));
console.log('startAbility result success:' + JSON.stringify(data));
});
```
## appManager.getProcessRunningInfos<sup>(deprecated)</sup>
......@@ -160,7 +161,7 @@ getProcessRunningInfos(): Promise\<Array\<ProcessRunningInfo>>;
Obtains information about the running processes. This API uses a promise to return the result.
> This API is deprecated since API version 9. You are advised to use [appManager.getProcessRunningInformation<sup>9+</sup>](#appmanagergetprocessrunninginformation9) instead.
> This API is deprecated since API Version 9. You are advised to use [appManager.getProcessRunningInformation<sup>9+</sup>](js-apis-app-ability-appManager.md#appmanagergetprocessrunninginformation9) instead.
**Required permissions**: ohos.permission.GET_RUNNING_INFO
......@@ -175,10 +176,10 @@ Obtains information about the running processes. This API uses a promise to retu
**Example**
```ts
appManager.getProcessRunningInfos().then((data) => {
console.log('The process running infos is:' + JSON.stringify(data));
app.getProcessRunningInfos().then((data) => {
console.log('success:' + JSON.stringify(data));
}).catch((error) => {
console.log('error:' + JSON.stringify(error));
console.log('failed:' + JSON.stringify(error));
});
```
......@@ -188,7 +189,7 @@ getProcessRunningInfos(callback: AsyncCallback\<Array\<ProcessRunningInfo>>): vo
Obtains information about the running processes. This API uses an asynchronous callback to return the result.
> This API is deprecated since API version 9. You are advised to use [appManager.getProcessRunningInformation<sup>9+</sup>](#appmanagergetprocessrunninginformation9-1) instead.
> This API is deprecated since API Version 9. You are advised to use [appManager.getProcessRunningInformation<sup>9+</sup>](js-apis-app-ability-appManager.md#appmanagergetprocessrunninginformation9-1) instead.
**Required permissions**: ohos.permission.GET_RUNNING_INFO
......@@ -203,9 +204,9 @@ Obtains information about the running processes. This API uses an asynchronous c
**Example**
```ts
appManager.getProcessRunningInfos((err, data) => {
console.log('error:' + JSON.stringify(err));
console.log('The process running infos is:' + JSON.stringify(data));
app.getProcessRunningInfos((err, data) => {
console.log('startAbility result failed :' + JSON.stringify(err));
console.log('startAbility result success:' + JSON.stringify(data));
})
```
......@@ -223,15 +224,15 @@ Obtains information about the running processes. This API uses a promise to retu
| Type| Description|
| -------- | -------- |
| Promise\<Array\<[ProcessRunningInformation](js-apis-inner-application-processRunningInformation.md)>> | Obtains information about the running processes. This API uses a promise to return the result.|
| Promise\<Array\<[ProcessRunningInformation](js-apis-inner-application-processRunningInformation.md)>> | Promise used to return the running processes.|
**Example**
```ts
appManager.getProcessRunningInformation().then((data) => {
console.log('The process running info is:' + JSON.stringify(data));
app.getProcessRunningInformation().then((data) => {
console.log('success:' + JSON.stringify(data));
}).catch((error) => {
console.log('error:' + JSON.stringify(error));
console.log('failed:' + JSON.stringify(error));
});
```
......@@ -249,15 +250,15 @@ Obtains information about the running processes. This API uses an asynchronous c
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| callback | AsyncCallback\<Array\<[ProcessRunningInformation](js-apis-inner-application-processRunningInformation.md)>> | Yes| Obtains information about the running processes. This API uses a promise to return the result.|
| callback | AsyncCallback\<Array\<[ProcessRunningInformation](js-apis-inner-application-processRunningInformation.md)>> | Yes| Callback used to return the running processes.|
**Example**
```ts
appManager.getProcessRunningInformation((err, data) => {
console.log('error:' + JSON.stringify(err));
console.log('The process running info is:' + JSON.stringify(data));
})
app.getProcessRunningInformation((err, data) => {
console.log('startAbility result failed :' + JSON.stringify(err));
console.log('startAbility result success:' + JSON.stringify(data));
});
```
## appManager.registerApplicationStateObserver<sup>8+</sup>
......@@ -281,7 +282,7 @@ Registers an observer to listen for the state changes of all applications.
**Example**
```ts
var applicationStateObserver = {
let applicationStateObserver = {
onForegroundApplicationChanged(appStateData) {
console.log('------------ onForegroundApplicationChanged -----------', appStateData);
},
......@@ -297,8 +298,8 @@ Registers an observer to listen for the state changes of all applications.
onProcessStateChanged(processData) {
console.log('------------ onProcessStateChanged -----------', processData);
}
}
const observerCode = appManager.registerApplicationStateObserver(applicationStateObserver);
};
const observerCode = app.registerApplicationStateObserver(applicationStateObserver);
console.log('-------- observerCode: ---------', observerCode);
```
......@@ -324,7 +325,7 @@ Registers an observer to listen for the state changes of a specified application
**Example**
```ts
var applicationStateObserver = {
let applicationStateObserver = {
onForegroundApplicationChanged(appStateData) {
console.log('------------ onForegroundApplicationChanged -----------', appStateData);
},
......@@ -340,9 +341,9 @@ Registers an observer to listen for the state changes of a specified application
onProcessStateChanged(processData) {
console.log('------------ onProcessStateChanged -----------', processData);
}
}
var bundleNameList = ['bundleName1', 'bundleName2'];
const observerCode = appManager.registerApplicationStateObserver(applicationStateObserver, bundleNameList);
};
let bundleNameList = ['bundleName1', 'bundleName2'];
const observerCode = app.registerApplicationStateObserver(applicationStateObserver, bundleNameList);
console.log('-------- observerCode: ---------', observerCode);
```
## appManager.unregisterApplicationStateObserver<sup>8+</sup>
......@@ -358,7 +359,7 @@ Deregisters the application state observer. This API uses an asynchronous callba
**System API**: This is a system API and cannot be called by third-party applications.
**Parameters**
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| observerId | number | Yes| Numeric code of the observer.|
......@@ -367,14 +368,14 @@ Deregisters the application state observer. This API uses an asynchronous callba
**Example**
```ts
var observerId = 100;
let observerId = 100;
function unregisterApplicationStateObserverCallback(err) {
if (err) {
console.log('------------ unregisterApplicationStateObserverCallback ------------', err);
}
}
appManager.unregisterApplicationStateObserver(observerId, unregisterApplicationStateObserverCallback);
app.unregisterApplicationStateObserver(observerId, unregisterApplicationStateObserverCallback);
```
## appManager.unregisterApplicationStateObserver<sup>8+</sup>
......@@ -404,15 +405,15 @@ Deregisters the application state observer. This API uses a promise to return th
**Example**
```ts
var observerId = 100;
let observerId = 100;
appManager.unregisterApplicationStateObserver(observerId)
app.unregisterApplicationStateObserver(observerId)
.then((data) => {
console.log('----------- unregisterApplicationStateObserver success ----------', data);
})
.catch((err) => {
console.log('----------- unregisterApplicationStateObserver fail ----------', err);
})
});
```
## appManager.getForegroundApplications<sup>8+</sup>
......@@ -443,7 +444,7 @@ Obtains information about the applications that are running in the foreground. T
console.log('--------- getForegroundApplicationsCallback success ---------', data)
}
}
appManager.getForegroundApplications(getForegroundApplicationsCallback);
app.getForegroundApplications(getForegroundApplicationsCallback);
```
## appManager.getForegroundApplications<sup>8+</sup>
......@@ -467,13 +468,13 @@ Obtains information about the applications that are running in the foreground. T
**Example**
```ts
appManager.getForegroundApplications()
app.getForegroundApplications()
.then((data) => {
console.log('--------- getForegroundApplications success -------', data);
})
.catch((err) => {
console.log('--------- getForegroundApplications fail -------', err);
})
});
```
## appManager.killProcessWithAccount<sup>8+</sup>
......@@ -482,7 +483,7 @@ killProcessWithAccount(bundleName: string, accountId: number): Promise\<void\>
Kills a process by bundle name and account ID. This API uses a promise to return the result.
**Required permissions**: ohos.permission.INTERACT_ACROSS_LOCAL_ACCOUNTS (required only when the account ID is not the current user) and ohos.permission.CLEAN_BACKGROUND_PROCESSES
**Required permissions**: ohos.permission.INTERACT_ACROSS_LOCAL_ACCOUNTS and ohos.permission.CLEAN_BACKGROUND_PROCESSES
**System capability**: SystemCapability.Ability.AbilityRuntime.Core
......@@ -498,15 +499,15 @@ Kills a process by bundle name and account ID. This API uses a promise to return
**Example**
```ts
var bundleName = 'bundleName';
var accountId = 0;
appManager.killProcessWithAccount(bundleName, accountId)
let bundleName = 'bundleName';
let accountId = 0;
app.killProcessWithAccount(bundleName, accountId)
.then((data) => {
console.log('------------ killProcessWithAccount success ------------', data);
})
.catch((err) => {
console.log('------------ killProcessWithAccount fail ------------', err);
})
});
```
......@@ -520,7 +521,7 @@ Kills a process by bundle name and account ID. This API uses an asynchronous cal
**System API**: This is a system API and cannot be called by third-party applications.
**Required permissions**: ohos.permission.INTERACT_ACROSS_LOCAL_ACCOUNTS (required only when the account ID is not the current user) and ohos.permission.CLEAN_BACKGROUND_PROCESSES
**Required permissions**: ohos.permission.INTERACT_ACROSS_LOCAL_ACCOUNTS and ohos.permission.CLEAN_BACKGROUND_PROCESSES
**Parameters**
......@@ -533,8 +534,8 @@ Kills a process by bundle name and account ID. This API uses an asynchronous cal
**Example**
```ts
var bundleName = 'bundleName';
var accountId = 0;
let bundleName = 'bundleName';
let accountId = 0;
function killProcessWithAccountCallback(err, data) {
if (err) {
console.log('------------- killProcessWithAccountCallback fail, err: --------------', err);
......@@ -542,7 +543,7 @@ function killProcessWithAccountCallback(err, data) {
console.log('------------- killProcessWithAccountCallback success, data: --------------', data);
}
}
appManager.killProcessWithAccount(bundleName, accountId, killProcessWithAccountCallback);
app.killProcessWithAccount(bundleName, accountId, killProcessWithAccountCallback);
```
## appManager.killProcessesByBundleName<sup>8+</sup>
......@@ -567,7 +568,7 @@ Kills a process by bundle name. This API uses an asynchronous callback to return
**Example**
```ts
var bundleName = 'bundleName';
let bundleName = 'bundleName';
function killProcessesByBundleNameCallback(err, data) {
if (err) {
console.log('------------- killProcessesByBundleNameCallback fail, err: --------------', err);
......@@ -575,7 +576,7 @@ Kills a process by bundle name. This API uses an asynchronous callback to return
console.log('------------- killProcessesByBundleNameCallback success, data: --------------', data);
}
}
appManager.killProcessesByBundleName(bundleName, killProcessesByBundleNameCallback);
app.killProcessesByBundleName(bundleName, killProcessesByBundleNameCallback);
```
## appManager.killProcessesByBundleName<sup>8+</sup>
......@@ -603,16 +604,16 @@ Kills a process by bundle name. This API uses a promise to return the result.
| Promise\<void> | Promise used to return the result.|
**Example**
```ts
var bundleName = 'com.example.myapplication';
appManager.killProcessesByBundleName(bundleName)
let bundleName = 'bundleName';
app.killProcessesByBundleName(bundleName)
.then((data) => {
console.log('------------ killProcessesByBundleName success ------------', data);
})
.catch((err) => {
console.log('------------ killProcessesByBundleName fail ------------', err);
})
});
```
## appManager.clearUpApplicationData<sup>8+</sup>
......@@ -637,7 +638,7 @@ Clears application data by bundle name. This API uses an asynchronous callback t
**Example**
```ts
var bundleName = 'bundleName';
let bundleName = 'bundleName';
function clearUpApplicationDataCallback(err, data) {
if (err) {
console.log('------------- clearUpApplicationDataCallback fail, err: --------------', err);
......@@ -645,7 +646,7 @@ Clears application data by bundle name. This API uses an asynchronous callback t
console.log('------------- clearUpApplicationDataCallback success, data: --------------', data);
}
}
appManager.clearUpApplicationData(bundleName, clearUpApplicationDataCallback);
app.clearUpApplicationData(bundleName, clearUpApplicationDataCallback);
```
## appManager.clearUpApplicationData<sup>8+</sup>
......@@ -675,40 +676,12 @@ Clears application data by bundle name. This API uses a promise to return the re
**Example**
```ts
var bundleName = 'bundleName';
appManager.clearUpApplicationData(bundleName)
let bundleName = 'bundleName';
app.clearUpApplicationData(bundleName)
.then((data) => {
console.log('------------ clearUpApplicationData success ------------', data);
})
.catch((err) => {
console.log('------------ clearUpApplicationData fail ------------', err);
})
});
```
## ApplicationState<sup>9+</sup>
**System capability**: SystemCapability.Ability.AbilityRuntime.Core
**System API**: This is a system API and cannot be called by third-party applications.
| Name | Value | Description |
| -------------------- | --- | --------------------------------- |
| STATE_CREATE | 1 | State indicating that the application is being created. |
| STATE_FOREGROUND | 2 | State indicating that the application is running in the foreground. |
| STATE_ACTIVE | 3 | State indicating that the application is active. |
| STATE_BACKGROUND | 4 | State indicating that the application is running in the background. |
| STATE_DESTROY | 5 | State indicating that the application is destroyed. |
## ProcessState<sup>9+</sup>
**System capability**: SystemCapability.Ability.AbilityRuntime.Core
**System API**: This is a system API and cannot be called by third-party applications.
| Name | Value | Description |
| -------------------- | --- | --------------------------------- |
| STATE_CREATE | 1 | State indicating that the process is being created. |
| STATE_FOREGROUND | 2 | State indicating that the process is running in the foreground. |
| STATE_ACTIVE | 3 | State indicating that the process is active. |
| STATE_BACKGROUND | 4 | State indicating that the process is running in the background. |
| STATE_DESTROY | 5 | State indicating that the process is destroyed. |
......@@ -21,9 +21,9 @@ The **ApplicationInfo** module defines the application information. A system app
| icon | string | Yes | No | Application icon. |
| iconId | number | Yes | No | ID of the application icon. |
| process | string | Yes | No | Process in which the application runs. If this parameter is not set, the bundle name is used. |
| permissions | Array\<string> | Yes | No | Permissions required for accessing the application. The permissions can be obtained by passing in **GET_APPLICATION_INFO_WITH_PERMISSION** to the **appFlags** parameter of [bundleManager.getApplicationInfo](js-apis-bundleManager.md#bundlemanagergetapplicationinfo).|
| permissions | Array\<string> | Yes | No | Permissions required for accessing the application. The permissions can be obtained by passing in **GET_APPLICATION_INFO_WITH_PERMISSION** to [bundleManager.getApplicationInfo](js-apis-bundleManager.md#bundlemanagergetapplicationinfo).|
| codePath | string | Yes | No | Installation directory of the application. |
| metadata | Map\<string, Array\<[Metadata](js-apis-bundleManager-metadata.md)>> | Yes | No | Metadata of the application. The information can be obtained by passing in **GET_APPLICATION_INFO_WITH_METADATA** to the **appFlags** parameter of [bundleManager.getApplicationInfo](js-apis-bundleManager.md#bundlemanagergetapplicationinfo).|
| metadata | Map\<string, Array\<[Metadata](js-apis-bundleManager-metadata.md)>> | Yes | No | Metadata of the application. The information can be obtained by passing in **GET_APPLICATION_INFO_WITH_METADATA** to [bundleManager.getApplicationInfo](js-apis-bundleManager.md#bundlemanagergetapplicationinfo).|
| removable | boolean | Yes | No | Whether the application is removable. |
| accessTokenId | number | Yes | No | Access token ID of the application. |
| uid | number | Yes | No | UID of the application. |
......@@ -32,3 +32,4 @@ The **ApplicationInfo** module defines the application information. A system app
| descriptionResource | [Resource](js-apis-resource-manager.md#resource9) | Yes| No| Description resource of the application. |
| appDistributionType | string | Yes | No | Distribution type of the application signing certificate. The options are **app_gallery**, **enterprise**, **os_integration**, and **crowdtesting**. |
| appProvisionType | string | Yes | No | Type of the application signing certificate file. The options are **debug** and **release**. |
| systemApp | boolean | Yes | No | Whether the application is a system application. |
......@@ -6,8 +6,6 @@ The **BundleInfo** module defines the bundle information. A system application c
>
> The initial APIs of this module are supported since API version 9. Newly added APIs will be marked with a superscript to indicate their earliest API version.
## BundleInfo
**System capability**: SystemCapability.BundleManager.BundleFramework.Core
......
# ExtensionAbilityInfo
The **ExtensionAbilityInfo** module defines the ExtensionAbility information. A system application can obtain its own or others' ExtensionAbility information through [bundleManager.getBundleInfo](js-apis-bundleManager.md#bundlemanagergetbundleinfo). A third-party application can obtain its own ExtensionAbility information through [getBundleInfoForSelf](js-apis-bundleManager.md#bundlemanagergetbundleinfoforself). **GET_BUNDLE_INFO_WITH_EXTENSION_ABILITY** must be passed in to the input parameter [bundleFlags](js-apis-bundleManager.md#bundleflag) to obtain the information.
The **ExtensionAbilityInfo** module defines the ExtensionAbility information. A system application can obtain its own or others' ExtensionAbility information through [bundleManager.getBundleInfo](js-apis-bundleManager.md#bundlemanagergetbundleinfo). A third-party application can obtain its own ExtensionAbility information through [getBundleInfoForSelf](js-apis-bundleManager.md#bundlemanagergetbundleinfoforself). The input parameter [bundleFlags](js-apis-bundleManager.md#bundleflag) must be set to **GET_BUNDLE_INFO_WITH_EXTENSION_ABILITY**.
> **NOTE**
>
......@@ -18,7 +18,7 @@ The **ExtensionAbilityInfo** module defines the ExtensionAbility information. A
| labelId | number | Yes | No | ID of the ExtensionAbility label. |
| descriptionId | number | Yes | No | ID of the ExtensionAbility description. |
| iconId | number | Yes | No | ID of the ExtensionAbility icon. |
| isVisible | boolean | Yes | No | Whether the ExtensionAbility can be called by other bundles. |
| isVisible | boolean | Yes | No | Whether the ExtensionAbility can be called by other bundles. |
| extensionAbilityType | [ExtensionAbilityType](js-apis-bundleManager.md#extensionabilitytype) | Yes | No | Type of the ExtensionAbility. |
| permissions | Array\<string> | Yes | No | Permissions required for other bundles to call the ExtensionAbility.|
| applicationInfo | [ApplicationInfo](js-apis-bundleManager-applicationInfo.md) | Yes | No | Application information. |
......
# HapModuleInfo
The **HapModuleInfo** module defines the HAP module information. A system application can obtain its own or others' HAP module information through [bundleManager.getBundleInfo](js-apis-bundleManager.md#bundlemanagergetbundleinfo). A third-party application can obtain its own HAP module information through [getBundleInfoForSelf](js-apis-bundleManager.md#bundlemanagergetbundleinfoforself). **GET_BUNDLE_INFO_WITH_HAP_MODULE** must be passed in to the input parameter [bundleFlags](js-apis-bundleManager.md#bundleflag) to obtain the information.
The **HapModuleInfo** module defines the HAP module information. A system application can obtain its own or others' HAP module information through [bundleManager.getBundleInfo](js-apis-bundleManager.md#bundlemanagergetbundleinfo). A third-party application can obtain its own HAP module information through [getBundleInfoForSelf](js-apis-bundleManager.md#bundlemanagergetbundleinfoforself). The input parameter [bundleFlags](js-apis-bundleManager.md#bundleflag) must be set to **GET_BUNDLE_INFO_WITH_HAP_MODULE**.
> **NOTE**
>
......
......@@ -2236,8 +2236,8 @@ For details about the error codes, see [Bundle Error Codes](../errorcodes/errorc
| ID| Error Message |
| -------- | ------------------------------------------------------------ |
| 17700002 | The specified moduleName does not exist. |
| 17700003 | The specified abilityName does not exist. |
| 17700002 | The specified moduleName is not existed. |
| 17700003 | The specified abilityName is not existed. |
| 17700024 | Failed to get the profile because there is no profile in the HAP. |
| 17700026 | The specified bundle is disabled. |
| 17700029 | The specified ability is disabled. |
......@@ -2292,8 +2292,8 @@ For details about the error codes, see [Bundle Error Codes](../errorcodes/errorc
| ID| Error Message |
| -------- | ------------------------------------------------------------ |
| 17700002 | The specified moduleName does not exist. |
| 17700003 | The specified abilityName does not exist. |
| 17700002 | The specified moduleName is not existed. |
| 17700003 | The specified abilityName is not existed. |
| 17700024 | Failed to get the profile because there is no profile in the HAP. |
| 17700026 | The specified bundle is disabled. |
| 17700029 | The specified ability is disabled. |
......@@ -2357,7 +2357,7 @@ For details about the error codes, see [Bundle Error Codes](../errorcodes/errorc
| ID| Error Message |
| -------- | ------------------------------------------------------------ |
| 17700002 | The specified moduleName does not exist. |
| 17700002 | The specified moduleName is not existed. |
| 17700003 | The specified extensionAbilityName not existed. |
| 17700024 | Failed to get the profile because there is no profile in the HAP. |
| 17700026 | The specified bundle is disabled. |
......@@ -2412,7 +2412,7 @@ For details about the error codes, see [Bundle Error Codes](../errorcodes/errorc
| ID| Error Message |
| -------- | ------------------------------------------------------------ |
| 17700002 | The specified moduleName does not exist. |
| 17700002 | The specified moduleName is not existed. |
| 17700003 | The specified extensionAbilityName not existed. |
| 17700024 | Failed to get the profile because there is no profile in the HAP. |
| 17700026 | The specified bundle is disabled. |
......
# Configuration
The **Configuration** module provides environment configuration information.
> **NOTE**
>
> The initial APIs of this module are supported since API version 8. Newly added APIs will be marked with a superscript to indicate their earliest API version.
## Modules to Import
```js
import Configuration from '@ohos.application.Configuration';
```
## Attributes
**System capability**: SystemCapability.Ability.AbilityBase
| Name| Type| Readable| Writable| Description|
| -------- | -------- | -------- | -------- | -------- |
| language | string | Yes| Yes| Language of the application.|
| colorMode | [ColorMode](js-apis-configurationconstant.md) | Yes| Yes| Color mode, which can be **COLOR_MODE_LIGHT** or **COLOR_MODE_DARK**. The default value is **COLOR_MODE_LIGHT**.|
| direction<sup>9+</sup> | Direction | Yes| No| Screen orientation, which can be **DIRECTION_HORIZONTAL** or **DIRECTION_VERTICAL**.|
| screenDensity<sup>9+</sup> | ScreenDensity | Yes| No| Screen resolution, which can be **SCREEN_DENSITY_SDPI** (120), **SCREEN_DENSITY_MDPI** (160), **SCREEN_DENSITY_LDPI** (240), **SCREEN_DENSITY_XLDPI** (320), **SCREEN_DENSITY_XXLDPI** (480), or **SCREEN_DENSITY_XXXLDPI** (640).|
| displayId<sup>9+</sup> | number | Yes| No| ID of the display where the application is located.|
| hasPointerDevice<sup>9+</sup> | boolean | Yes| No| Whether a pointer device, such as a keyboard, mouse, or touchpad, is connected.|
......@@ -116,8 +116,7 @@ For details about the error codes, see [Bundle Error Codes](../errorcodes/errorc
| 17700015 | Failed to install the HAPs because they have different configuration information. |
| 17700016 | Failed to install the HAP because of insufficient system disk space. |
| 17700017 | Failed to install the HAP since the version of the HAP to install is too early. |
| 17700101 | The system service is excepted. |
| 17700103 | I/O operation is failed. |
| 17700018 | Failed to install because the dependent module does not exist. |
**Example**
......
......@@ -19,11 +19,11 @@ import package from '@system.package';
## package.hasInstalled<sup>(deprecated)</sup>
> This API is deprecated since API version 9. You are advised to use [@ohos.bundle.bundleManager](js-apis-bundleManager.md) instead.
hasInstalled(Object): void
hasInstalled(options: CheckPackageHasInstalledOptions): void
Checks whether an application exists, or whether a native application has been installed.
**Required permissions**: ohos.permission.GET_BUNDLE_INFO
**Required permissions**: none
**System capability**: SystemCapability.BundleManager.BundleFramework
......@@ -65,9 +65,9 @@ Checks whether a bundle has been installed.
**System capability**: SystemCapability.BundleManager.BundleFramework
| Name| Type| Description|
| --- | --- | ---- |
| result | boolean | The value **true** means that the bundle has been installed, and **false** means the opposite.|
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
|result | boolean | Yes| The value **true** means that the bundle has been installed, and **false** means the opposite.|
## CheckPackageHasInstalledOptions
......@@ -75,6 +75,8 @@ Checks whether a bundle has been installed.
Defines the options used for checking whether a bundle has been installed.
**System capability**: SystemCapability.BundleManager.BundleFramework
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| bundleName | string | Yes| Bundle name.|
......
......@@ -26,7 +26,7 @@
- Resource Management
- [I18N Error Codes](errorcode-i18n.md)
- [Resource Manager Error Codes](errorcode-resource-manager.md)
- Resource Scheduling
- Background Tasks
- [backgroundTaskManager Error Codes](errorcode-backgroundTaskMgr.md)
- [reminderAgentManager Error Codes](errorcode-reminderAgentManager.md)
- [workScheduler Error Codes](errorcode-workScheduler.md)
......@@ -79,7 +79,7 @@
- [DeviceUsageStatistics Error Codes](errorcode-DeviceUsageStatistics.md)
- Customization Management
- [Enterprise Device Management Error Codes](errorcode-enterpriseDeviceManager.md)
- Language Base Class Library
- Utils
- [Utils Error Codes](errorcode-utils.md)
- Test
- [UiTest Error Codes](errorcode-uitest.md)
......@@ -3,8 +3,8 @@
- Access Control
- [Access Control (Permission) Overview](accesstoken-overview.md)
- [Permission Application Guide](accesstoken-guidelines.md)
- [Permission Verification Guide](permission-verify-guidelines.md)
- [App Permission List](permission-list.md)
- [API Access Permission Verification](permission-verify-guidelines.md)
- [Application Permission List](permission-list.md)
- User Authentication
- [User Authentication Overview](userauth-overview.md)
- [User Authentication Development](userauth-guidelines.md)
......@@ -17,7 +17,7 @@
- Certificate
- [Certificate Overview](cert-overview.md)
- [Certificate Development](cert-guidelines.md)
- hapsigner
- hapsigner
- [hapsigner Overview](hapsigntool-overview.md)
- [hapsigner Guide](hapsigntool-guidelines.md)
- [HarmonyAppProvision Configuration File](app-provision-structure.md)
\ No newline at end of file
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册