提交 97bd69b6 编写于 作者: G Gloria

Update docs against 15888+13227

Signed-off-by: wusongqing<wusongqing@huawei.com>
上级 874ddfa3
......@@ -46,13 +46,6 @@ Enumerates the action constants of the **Want** object. **action** specifies the
| ACTION_FILE_SELECT<sup>7+</sup> | ohos.action.fileSelect | Action of selecting a file. |
| PARAMS_STREAM<sup>7+</sup> | ability.params.stream | URI of the data stream associated with the target when the data is sent. The value must be an array of the string type. |
| ACTION_APP_ACCOUNT_OAUTH <sup>8+</sup> | ohos.account.appAccount.action.oauth | Action of providing the OAuth service. |
| ACTION_APP_ACCOUNT_AUTH <sup>9+</sup> | account.appAccount.action.auth | Action of providing the authentication service. |
| ACTION_MARKET_DOWNLOAD <sup>9+</sup> | ohos.want.action.marketDownload | Action of downloading an application from the application market.<br>**System API**: This is a system API and cannot be called by third-party applications. |
| ACTION_MARKET_CROWDTEST <sup>9+</sup> | ohos.want.action.marketCrowdTest | Action of crowdtesting an application from the application market.<br>**System API**: This is a system API and cannot be called by third-party applications. |
| DLP_PARAMS_SANDBOX<sup>9+</sup> |ohos.dlp.params.sandbox | Action of obtaining the sandbox flag.<br>**System API**: This is a system API and cannot be called by third-party applications. |
| DLP_PARAMS_BUNDLE_NAME<sup>9+</sup> |ohos.dlp.params.bundleName |Action of obtaining the DLP bundle name.<br>**System API**: This is a system API and cannot be called by third-party applications. |
| DLP_PARAMS_MODULE_NAME<sup>9+</sup> |ohos.dlp.params.moduleName |Action of obtaining the DLP module name.<br>**System API**: This is a system API and cannot be called by third-party applications. |
| DLP_PARAMS_ABILITY_NAME<sup>9+</sup> |ohos.dlp.params.abilityName |Action of obtaining the DLP ability name.<br>**System API**: This is a system API and cannot be called by third-party applications. |
| DLP_PARAMS_INDEX<sup>9+</sup> |ohos.dlp.params.index |Action of obtaining the DLP index.<br>**System API**: This is a system API and cannot be called by third-party applications. |
## wantConstant.Entity
......@@ -72,7 +65,7 @@ Enumerates the entity constants of the **Want** object. **entity** specifies add
## wantConstant.Flags
Enumerates the flags that specify how the Want will be handled.
Enumerates the flags that specify how the Want will be handled.
**System capability**: SystemCapability.Ability.AbilityBase
......@@ -91,6 +84,6 @@ Enumerates the flags that specify how the Want will be handled.
| FLAG_ABILITY_CONTINUATION_REVERSIBLE | 0x00000400 | Indicates that ability continuation is reversible.<br>**System API**: This is a system API and cannot be called by third-party applications. |
| 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** in the [startAbility](#featureabilitystartability) API passed to the FeatureAbility module. It must be used together with **flag_ABILITY_NEW_MISSION**.|
| FLAG_ABILITY_NEW_MISSION | 0x10000000 | Creates a mission on the history 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.|
......@@ -99,7 +99,7 @@ import UIAbility from '@ohos.app.ability.UIAbility';
class MyAbility extends UIAbility {
onContinue(wantParam) {
return AbilityConstant.OnConinueResult.AGREE;
return AbilityConstant.OnContinueResult.AGREE;
}
}
```
......@@ -132,7 +132,7 @@ let option = {
};
// Ensure that the context is obtained.
this.context.startAbility(want, option).then(()={
this.context.startAbility(want, option).then(()=>{
console.log('Succeed to start ability.');
}).catch((error)=>{
console.error('Failed to start ability with error: ${JSON.stringify(error)}');
......
......@@ -275,7 +275,7 @@ export default class MyFirstAbility extends UIAbility {
// 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)}');
console.log('registerAbilityLifecycleCallback lifecycleId: ${globalThis.lifecycleId}');
} catch (paramError) {
console.error('error: ${paramError.code}, ${paramError.message}');
}
......@@ -285,7 +285,7 @@ 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() {
......
......@@ -59,12 +59,13 @@ For details about the error codes, see [Ability Error Codes](../errorcodes/error
```ts
import abilityManager from '@ohos.app.ability.abilityManager';
import ConfigurationConstant from '@ohos.app.ability.ConfigurationConstant';
const config = {
language: 'Zh-Hans', // Simplified Chinese.
colorMode: COLOR_MODE_LIGHT, // Light theme.
direction: DIRECTION_VERTICAL, // Vertical direction.
screenDensity: SCREEN_DENSITY_SDPI, // The screen pixel density is 'sdpi'.
colorMode: ConfigurationConstant.ColorMode.COLOR_MODE_LIGHT, // Light theme.
direction: ConfigurationConstant.Direction.DIRECTION_VERTICAL, // Vertical direction.
screenDensity: ConfigurationConstant.ScreenDensity.SCREEN_DENSITY_SDPI, // The screen pixel density is 'sdpi'.
displayId: 1, // The application is displayed on the display with ID 1.
hasPointerDevice: true, // A pointer device is connected.
};
......@@ -116,12 +117,13 @@ For details about the error codes, see [Ability Error Codes](../errorcodes/error
```ts
import abilityManager from '@ohos.app.ability.abilityManager';
import ConfigurationConstant from '@ohos.app.ability.ConfigurationConstant';
const config = {
language: 'Zh-Hans', // Simplified Chinese.
colorMode: COLOR_MODE_LIGHT, // Light theme.
direction: DIRECTION_VERTICAL, // Vertical direction.
screenDensity: SCREEN_DENSITY_SDPI, // The screen pixel density is 'sdpi'.
colorMode: ConfigurationConstant.ColorMode.COLOR_MODE_LIGHT, // Light theme.
direction: ConfigurationConstant.Direction.DIRECTION_VERTICAL, // Vertical direction.
screenDensity: ConfigurationConstant.ScreenDensity.SCREEN_DENSITY_SDPI, // The screen pixel density is 'sdpi'.
displayId: 1, // The application is displayed on the display with ID 1.
hasPointerDevice: true, // A pointer device is connected.
};
......
......@@ -459,7 +459,7 @@ For details about the error codes, see [Ability Error Codes](../errorcodes/error
```ts
import appManager from '@ohos.app.ability.appManager';
let observeId = 0;
let observerId = 0;
// 1. Register an application state observer.
let applicationStateObserver = {
......@@ -540,7 +540,7 @@ For details about the error codes, see [Ability Error Codes](../errorcodes/error
```ts
import appManager from '@ohos.app.ability.appManager';
let observeId = 0;
let observerId = 0;
// 1. Register an application state observer.
let applicationStateObserver = {
......
......@@ -72,9 +72,9 @@ import AbilityStage from '@ohos.app.ability.AbilityStage';
export default class MyAbilityStage extends AbilityStage {
onCreate() {
appRecovery.enableAppRecovery(
appRecovery.RestartFlag::ALWAYS_RESTART,
appRecovery.SaveOccasionFlag::SAVE_WHEN_ERROR,
appRecovery.SaveModeFlag::SAVE_WITH_FILE
appRecovery.RestartFlag.ALWAYS_RESTART,
appRecovery.SaveOccasionFlag.SAVE_WHEN_ERROR,
appRecovery.SaveModeFlag.SAVE_WITH_FILE
);
}
}
......
......@@ -35,7 +35,7 @@ onMemoryLevel(level: AbilityConstant.MemoryLevel): void;
Called when the system memory level changes.
**System capability**: SystemCapability.Ability.AbilityRuntime.Core
**System capability**: SystemCapability.Ability.AbilityRuntime.AbilityCore
**Parameters**
......@@ -55,7 +55,7 @@ export default class MyAbility 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)}');
}
......@@ -67,7 +67,7 @@ export default class MyAbility extends UIAbility {
// 1. Obtain an applicationContext object.
let applicationContext = globalThis.applicationContext;
// 2. Register a listener for the environment changes through the applicationContext object.
callbackId = applicationContext.registerEnvironmentCallback(EnvironmentCallback);
callbackId = applicationContext.registerEnvironmentCallback(environmentCallback);
console.log('registerEnvironmentCallback number: ${JSON.stringify(callbackId)}');
}
onDestroy() {
......
......@@ -106,7 +106,7 @@ Called following **onCreate()** when a ServiceExtensionAbility is started by cal
## ServiceExtensionAbility.onConnect
onConnect(want: Want): rpc.RemoteObject;
onConnect(want: Want): rpc.RemoteObject | Promise<rpc.RemoteObject>;
Called following **onCreate()** when a ServiceExtensionAbility is started by calling **connectAbility()**. A **RemoteObject** object is returned for communication between the server and client.
......@@ -148,7 +148,7 @@ Called following **onCreate()** when a ServiceExtensionAbility is started by cal
## ServiceExtensionAbility.onDisconnect
onDisconnect(want: Want): void;
onDisconnect(want: Want): void | Promise<void>;
Called when a client is disconnected from this ServiceExtensionAbility.
......
......@@ -124,7 +124,7 @@ Called when the **WindowStage** is restored during the migration of this UIAbili
## UIAbility.onDestroy
onDestroy(): void;
onDestroy(): void | Promise&lt;void&gt;;
Called when this UIAbility is destroyed to clear resources.
......@@ -181,7 +181,7 @@ Called when this UIAbility is switched from the foreground to the background.
## UIAbility.onContinue
onContinue(wantParam : {[key: string]: any}): AbilityConstant.OnContinueResult;
onContinue(wantParam: { [key: string]: Object }): AbilityConstant.OnContinueResult;
Called to save data during the ability migration preparation process.
......@@ -267,7 +267,7 @@ Dumps client information.
## UIAbility.onSaveState
onSaveState(reason: AbilityConstant.StateType, wantParam : {[key: string]: any}): AbilityConstant.OnSaveResult;
onSaveState(reason: AbilityConstant.StateType, wantParam : {[key: string]: Object}): AbilityConstant.OnSaveResult;
Called when the framework automatically saves the UIAbility state in the case of an application fault. This API is used together with [appRecovery](js-apis-app-ability-appRecovery.md). If automatic state saving is enabled, **onSaveState** is called to save the state of this UIAbility.
......@@ -308,7 +308,7 @@ Implements sending of sequenceable data to the target ability when the CallerAbi
## Caller.call
call(method: string, data: rpc.Sequenceable): Promise&lt;void&gt;;
call(method: string, data: rpc.Parcelable): Promise&lt;void&gt;;
Sends sequenceable data to the target ability.
......@@ -319,7 +319,7 @@ Sends sequenceable data to the target ability.
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| method | string | Yes| Notification message string negotiated between the two abilities. The message is used to instruct the callee to register a function to receive the sequenceable data.|
| data | [rpc.Sequenceable](js-apis-rpc.md#sequenceabledeprecated) | Yes| Sequenceable data. You need to customize the data.|
| data | [rpc.Parcelable](js-apis-rpc.md#parcelable9) | Yes| Sequenceable data. You need to customize the data.|
**Return value**
......@@ -387,7 +387,7 @@ For details about the error codes, see [Ability Error Codes](../errorcodes/error
## Caller.callWithResult
callWithResult(method: string, data: rpc.Sequenceable): Promise&lt;rpc.MessageParcel&gt;;
callWithResult(method: string, data: rpc.Parcelable): Promise&lt;rpc.MessageParcel&gt;;
Sends sequenceable data to the target ability and obtains the sequenceable data returned by the target ability.
......@@ -398,7 +398,7 @@ Sends sequenceable data to the target ability and obtains the sequenceable data
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| method | string | Yes| Notification message string negotiated between the two abilities. The message is used to instruct the callee to register a function to receive the sequenceable data.|
| data | [rpc.Sequenceable](js-apis-rpc.md#sequenceabledeprecated) | Yes| Sequenceable data. You need to customize the data.|
| data | [rpc.Parcelable](js-apis-rpc.md#parcelable9) | Yes| Sequenceable data. You need to customize the data.|
**Return value**
......@@ -509,7 +509,7 @@ Releases the caller interface of the target ability.
## Caller.onRelease
onRelease(callback: OnReleaseCallBack): void;
onRelease(callback: OnReleaseCallback): void;
Registers a callback that is invoked when the stub on the target ability is disconnected.
......@@ -519,7 +519,7 @@ Registers a callback that is invoked when the stub on the target ability is disc
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| callback | [OnReleaseCallBack](#onreleasecallback) | Yes| Callback used to return the result.|
| callback | [OnReleaseCallback](#onreleasecallback) | Yes| Callback used to return the result.|
**Example**
......@@ -560,7 +560,7 @@ Registers a callback that is invoked when the stub on the target ability is disc
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| type | string | Yes| Event type. The value is fixed at **release**.|
| callback | [OnReleaseCallBack](#onreleasecallback) | Yes| Callback used to return the result.|
| callback | [OnReleaseCallback](#onreleasecallback) | Yes| Callback used to return the result.|
**Error codes**
......@@ -609,7 +609,7 @@ Deregisters a callback that is invoked when the stub on the target ability is di
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| type | string | Yes| Event type. The value is fixed at **release**.|
| callback | [OnReleaseCallBack](#onreleasecallback) | Yes| Callback used to return the result.|
| callback | [OnReleaseCallback](#onreleasecallback) | Yes| Callback used to return the result.|
**Error codes**
......@@ -816,10 +816,10 @@ For details about the error codes, see [Ability Error Codes](../errorcodes/error
## CalleeCallback
(indata: rpc.MessageParcel): rpc.Sequenceable;
(indata: rpc.MessageParcel): rpc.Parcelable;
**System capability**: SystemCapability.Ability.AbilityRuntime.AbilityCore
| Name| Readable| Writable| Type| Description|
| -------- | -------- | -------- | -------- | -------- |
| (indata: [rpc.MessageParcel](js-apis-rpc.md#messageparceldeprecated)) | Yes| No| [rpc.Sequenceable](js-apis-rpc.md#sequenceabledeprecated) | Prototype of the listener function registered by the callee.|
| (indata: [rpc.MessageParcel](js-apis-rpc.md#sequenceabledeprecated)) | Yes| No| [rpc.Parcelable](js-apis-rpc.md#parcelable9) | Prototype of the listener function registered by the callee.|
......@@ -273,7 +273,7 @@ export default class MyFormExtensionAbility extends FormExtensionAbility {
## onShareForm
onShareForm?(formId: string): { [key: string]: any }
onShareForm?(formId: string): { [key: string]: Object }
Called by the widget provider to receive shared widget data.
......
......@@ -263,49 +263,6 @@ Registers an observer to listen for the state changes of all applications.
console.log('-------- observerCode: ---------', observerCode);
```
## appManager.registerApplicationStateObserver<sup>9+</sup>
registerApplicationStateObserver(observer: ApplicationStateObserver, bundleNameList: Array\<string>): number;
Registers an observer to listen for the state changes of a specified application.
**Required permissions**: ohos.permission.RUNNING_STATE_OBSERVER
**System capability**: SystemCapability.Ability.AbilityRuntime.Core
**System API**: This is a system API and cannot be called by third-party applications.
**Parameters**
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| observer | [ApplicationStateObserver](js-apis-inner-application-applicationStateObserver.md) | Yes| Numeric code of the observer.|
| bundleNameList | Array<string> | Yes| **bundleName** array of the application. A maximum of 128 bundle names can be passed.|
**Example**
```ts
let applicationStateObserver = {
onForegroundApplicationChanged(appStateData) {
console.log('------------ onForegroundApplicationChanged -----------', appStateData);
},
onAbilityStateChanged(abilityStateData) {
console.log('------------ onAbilityStateChanged -----------', abilityStateData);
},
onProcessCreated(processData) {
console.log('------------ onProcessCreated -----------', processData);
},
onProcessDied(processData) {
console.log('------------ onProcessDied -----------', processData);
},
onProcessStateChanged(processData) {
console.log('------------ onProcessStateChanged -----------', processData);
}
};
let bundleNameList = ['bundleName1', 'bundleName2'];
const observerCode = appManager.registerApplicationStateObserver(applicationStateObserver, bundleNameList);
console.log('-------- observerCode: ---------', observerCode);
```
## appManager.unregisterApplicationStateObserver<sup>8+</sup>
unregisterApplicationStateObserver(observerId: number, callback: AsyncCallback\<void>): void;
......
......@@ -33,11 +33,14 @@ export default class EntryAbility extends UIAbility {
console.info(`envCallback onConfigurationUpdated success: ${JSON.stringify(config)}`);
let language = config.language;
let colorMode = config.colorMode;
},
onMemoryLevel(level){
console.log('onMemoryLevel level: ${JSON.stringify(level)}');
}
};
let applicationContext = this.context.getApplicationContext();
applicationContext.registerEnvironmentCallback(envCallback);
applicationContext.on('environment',envCallback);
windowStage.loadContent('pages/index', (err, data) => {
if (err.code) {
......
......@@ -382,97 +382,6 @@ Obtains the snapshot of a given mission. This API uses a promise to return the r
});
```
## missionManager.getLowResolutionMissionSnapShot<sup>9+</sup>
getLowResolutionMissionSnapShot(deviceId: string, missionId: number, callback: AsyncCallback\<MissionSnapshot>): void;
Obtains the low-resolution snapshot of a given mission. This API uses an asynchronous callback to return the result.
**Required permissions**: ohos.permission.MANAGE_MISSIONS
**System capability**: SystemCapability.Ability.AbilityRuntime.Mission
**System API**: This is a system API and cannot be called by third-party applications.
**Parameters**
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| deviceId | string | Yes| Device ID. It is a null string by default for the local device.|
| missionId | number | Yes| Mission ID.|
| callback | AsyncCallback&lt;[MissionSnapshot](js-apis-inner-application-missionSnapshot.md)&gt; | Yes| Callback used to return the snapshot information obtained.|
**Example**
```ts
import missionManager from '@ohos.application.missionManager';
missionManager.getMissionInfos('', 10, (error, missions) => {
if (error.code) {
console.error('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;
missionManager.getLowResolutionMissionSnapShot('', id, (error, snapshot) => {
if (error.code) {
console.error('getLowResolutionMissionSnapShot failed, error.code: ${JSON.stringify(error.code)}, error.message: ${JSON.stringify(error.message)}');
return;
}
console.log('bundleName = ${snapshot.ability.bundleName}');
});
});
```
## missionManager.getLowResolutionMissionSnapShot<sup>9+</sup>
getLowResolutionMissionSnapShot(deviceId: string, missionId: number): Promise\<MissionSnapshot>;
Obtains the low-resolution snapshot of a given mission. This API uses a promise to return the result.
**Required permissions**: ohos.permission.MANAGE_MISSIONS
**System capability**: SystemCapability.Ability.AbilityRuntime.Mission
**System API**: This is a system API and cannot be called by third-party applications.
**Parameters**
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| deviceId | string | Yes| Device ID. It is a null string by default for the local device.|
| missionId | number | Yes| Mission ID.|
**Return value**
| Type| Description|
| -------- | -------- |
| Promise&lt;[MissionSnapshot](js-apis-inner-application-missionSnapshot.md)&gt; | Promise used to return the snapshot information obtained.|
**Example**
```ts
import missionManager from '@ohos.application.missionManager';
let allMissions;
missionManager.getMissionInfos('',10).then(function(res){
allMissions=res;
}).catch(function(error) {
console.error('getMissionInfos fail, error: ${error}');
});
console.log('size = ${allMissions.length}');
console.log('missions = ${JSON.stringify(allMissions)}');
let id = allMissions[0].missionId;
let snapshot = missionManager.getLowResolutionMissionSnapShot('', id).catch(function (error){
console.error('getLowResolutionMissionSnapShot fail, error: ${error}');
});
```
## missionManager.lockMission
lockMission(missionId: number, callback: AsyncCallback&lt;void&gt;): void;
......
......@@ -27,7 +27,6 @@ import Want from '@ohos.application.Want';
| 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. |
| 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.|
**Example**
......
......@@ -368,8 +368,8 @@ Continues a mission on a remote device. This API uses an asynchronous callback t
| Name | Type | Mandatory | Description |
| --------- | --------------------------------------- | ---- | ----- |
| parameter | [ContinueDeviceInfo](#continuedeviceinfo) | Yes | Parameters required for mission continuation.|
| options | [ContinueCallback](#continuecallback) | Yes | Callback invoked when the mission continuation is complete.|
| parameter | [ContinueDeviceInfo](#js-apis-inner-application-continueDeviceInfo.md) | Yes | Parameters required for mission continuation.|
| options | [ContinueCallback](#js-apis-inner-application-continueCallback.md) | Yes | Callback invoked when the mission continuation is complete.|
| callback | AsyncCallback&lt;void&gt; | Yes | Callback used to return the result.|
**Error codes**
......@@ -426,8 +426,8 @@ Continues a mission on a remote device. This API uses a promise to return the re
| Name | Type | Mandatory | Description |
| --------- | --------------------------------------- | ---- | ----- |
| parameter | [ContinueDeviceInfo](#continuedeviceinfo) | Yes | Parameters required for mission continuation.|
| options | [ContinueCallback](#continuecallback) | Yes | Callback invoked when the mission continuation is complete.|
| parameter | [ContinueDeviceInfo](#js-apis-inner-application-continueDeviceInfo.md) | Yes | Parameters required for mission continuation.|
| options | [ContinueCallback](#js-apis-inner-application-continueCallback.md) | Yes | Callback invoked when the mission continuation is complete.|
**Return value**
......@@ -514,30 +514,3 @@ Defines the parameters required for registering a listener.
| Name | Type | Readable | Writable | Description |
| -------- | ------ | ---- | ---- | ------- |
| deviceId | string | Yes | Yes | Device ID.|
## ContinueDeviceInfo
Defines the parameters required for mission continuation.
**Required permissions**: ohos.permission.MANAGE_MISSIONS
**System capability**: SystemCapability.Ability.AbilityRuntime.Mission
| Name | Type | Readable | Writable | Description |
| -------- | ------ | ---- | ---- | ------- |
| srcDeviceId | string | Yes | Yes | ID of the source device.|
| dstDeviceId | string | Yes | Yes | ID of the target device.|
| missionId | number | Yes | Yes | Mission ID.|
| wantParam | {[key: string]: any} | Yes | Yes | Extended parameters.|
## ContinueCallback
Defines the callback invoked when the mission continuation is complete.
**Required permissions**: ohos.permission.MANAGE_MISSIONS
**System capability**: SystemCapability.Ability.AbilityRuntime.Mission
| Name | Type | Readable | Writable | Description |
| --------------------- | -------- | ---- | ---- | ------------------ |
| onContinueDone | function | Yes | No | Callback used to notify the user that the mission continuation is complete and return the continuation result. |
......@@ -27,11 +27,9 @@ function executeBatchOperation() {
DAHelper = featureAbility.acquireDataAbilityHelper(dataAbilityUri);
if (DAHelper === null) {
console.error('DAHelper is null');
return;
}
} catch (err) {
console.error('acquireDataAbilityHelper fail, error: ${JSON.stringify(err)}');
return;
}
let valueBucket = {
......
......@@ -11,8 +11,6 @@ The **AbilityDelegator** module provides APIs for managing **AbilityMonitor** in
An **AbilityDelegator** object is obtained by calling [getAbilityDelegator](js-apis-app-ability-abilityDelegatorRegistry.md#abilitydelegatorregistrygetabilitydelegator) in **AbilityDelegatorRegistry**.
```ts
import AbilityDelegatorRegistry from '@ohos.app.ability.abilityDelegatorRegistry';
let abilityDelegator = AbilityDelegatorRegistry.getAbilityDelegator();
```
## AbilityDelegator
......@@ -492,8 +490,8 @@ abilityDelegator = AbilityDelegatorRegistry.getAbilityDelegator();
abilityDelegator.getCurrentTopAbility((err : any, data : any) => {
console.info('getCurrentTopAbility callback');
ability = data;
abilityDelegator.doAbilityForeground(ability, (err : any, data : any) => {
console.info('doAbilityForeground callback');
abilityDelegator.doAbilityForeground(ability, (err : any) => {
console.info("doAbilityForeground callback");
});
});
```
......@@ -528,8 +526,8 @@ abilityDelegator = AbilityDelegatorRegistry.getAbilityDelegator();
abilityDelegator.getCurrentTopAbility((err : any, data : any) => {
console.info('getCurrentTopAbility callback');
ability = data;
abilityDelegator.doAbilityForeground(ability).then((data : any) => {
console.info('doAbilityForeground promise');
abilityDelegator.doAbilityForeground(ability).then(() => {
console.info("doAbilityForeground promise");
});
});
```
......@@ -559,8 +557,8 @@ abilityDelegator = AbilityDelegatorRegistry.getAbilityDelegator();
abilityDelegator.getCurrentTopAbility((err : any, data : any) => {
console.info('getCurrentTopAbility callback');
ability = data;
abilityDelegator.doAbilityBackground(ability, (err : any, data : any) => {
console.info('doAbilityBackground callback');
abilityDelegator.doAbilityBackground(ability, (err : any) => {
console.info("doAbilityBackground callback");
});
});
```
......@@ -595,8 +593,8 @@ abilityDelegator = AbilityDelegatorRegistry.getAbilityDelegator();
abilityDelegator.getCurrentTopAbility((err : any, data : any) => {
console.info('getCurrentTopAbility callback');
ability = data;
abilityDelegator.doAbilityBackground(ability).then((data : any) => {
console.info('doAbilityBackground promise');
abilityDelegator.doAbilityBackground(ability).then(() => {
console.info("doAbilityBackground promise");
});
});
```
......
......@@ -115,7 +115,7 @@ export default class EntryAbility extends UIAbility {
onDestroy() {
let applicationContext = this.context.getApplicationContext();
console.log('stage applicationContext: ${applicationContext}');
applicationContext.off(type: 'abilityLifecycle', lifecycleId, (error, data) => {
applicationContext.off('abilityLifecycle', lifecycleId, (error, data) => {
if (error && error.code !== 0) {
console.error('unregisterAbilityLifecycleCallback fail, err: ${JSON.stringify(error)}');
} else {
......@@ -152,7 +152,7 @@ export default class MyAbility extends Ability {
onDestroy() {
let applicationContext = this.context.getApplicationContext();
console.log('stage applicationContext: ${applicationContext}');
applicationContext.off(type: 'abilityLifecycle', lifecycleId);
applicationContext.off('abilityLifecycle', lifecycleId);
}
}
```
......
......@@ -30,9 +30,13 @@ let listener = {
},
onMissionMovedToFront: function (mission) {
console.log('onMissionMovedToFront mission: ${JSON.stringify(mission)}');
},
onMissionLabelUpdated: function (mission) {
console.log('onMissionLabelUpdated mission: ' + JSON.stringify(mission));
},
onMissionIconUpdated: function (mission, icon) {
console.log('onMissionIconUpdated mission: ${JSON.stringify(mission)}');
console.log('onMissionIconUpdated mission: ' + JSON.stringify(mission));
console.log('onMissionIconUpdated icon: ' + JSON.stringify(icon));
},
onMissionClosed: function (mission) {
console.log('onMissionClosed mission: ${JSON.stringify(mission)}');
......
......@@ -12,6 +12,145 @@ The **WantAgent** module provides APIs for creating and comparing **WantAgent**
import WantAgent from '@ohos.wantAgent';
```
## WantAgent.getWant
getWant(agent: WantAgent, callback: AsyncCallback\<Want\>): void
Obtains the Want in a **WantAgent** object. This API uses an asynchronous callback to return the result.
**System capability**: SystemCapability.Ability.AbilityRuntime.Core
**Parameters**
| Name | Type | Mandatory| Description |
| -------- | -------------------------- | ---- | ----------------------- |
| agent | [WantAgent](js-apis-wantAgent.md) | Yes | **WantAgent** object. |
| callback | AsyncCallback\<Want\> | Yes | Callback used to return the Want.|
**Example**
```ts
import WantAgent from '@ohos.wantAgent';
// WantAgent object
let wantAgent;
// getWantAgent callback
function getWantAgentCallback(err, data) {
console.info('==========================>getWantAgentCallback=======================>');
if (err.code == 0) {
wantAgent = data;
} else {
console.error('getWantAgent failed, error: ' + JSON.stringify(err));
return;
}
// getWant callback
function getWantCallback(err, data) {
console.info('==========================>getWantCallback=======================>');
}
WantAgent.getWant(wantAgent, getWantCallback);
}
// WantAgentInfo object
let wantAgentInfo = {
wants: [
{
deviceId: 'deviceId',
bundleName: 'com.neu.setResultOnAbilityResultTest1',
abilityName: 'com.example.test.EntryAbility',
action: 'action1',
entities: ['entity1'],
type: 'MIMETYPE',
uri: 'key={true,true,false}',
parameters:
{
mykey0: 2222,
mykey1: [1, 2, 3],
mykey2: '[1, 2, 3]',
mykey3: 'ssssssssssssssssssssssssss',
mykey4: [false, true, false],
mykey5: ['qqqqq', 'wwwwww', 'aaaaaaaaaaaaaaaaa'],
mykey6: true,
}
}
],
operationType: WantAgent.OperationType.START_ABILITIES,
requestCode: 0,
wantAgentFlags:[WantAgent.WantAgentFlags.UPDATE_PRESENT_FLAG]
};
WantAgent.getWantAgent(wantAgentInfo, getWantAgentCallback);
```
## WantAgent.getWant
getWant(agent: WantAgent): Promise\<Want\>
Obtains the Want in a **WantAgent** object. This API uses a promise to return the result.
**System capability**: SystemCapability.Ability.AbilityRuntime.Core
**Parameters**
| Name| Type | Mandatory| Description |
| ---- | ------------- | ---- | ------------- |
| agent | [WantAgent](js-apis-wantAgent.md) | Yes | **WantAgent** object.|
**Return value**
| Type | Description |
| ----------------------------------------------------------- | ------------------------------------------------------------ |
| Promise\<Want\> | Promise used to return the Want.|
**Example**
```ts
import WantAgent from '@ohos.wantAgent';
// WantAgent object
let wantAgent;
// WantAgentInfo object
let wantAgentInfo = {
wants: [
{
deviceId: 'deviceId',
bundleName: 'com.neu.setResultOnAbilityResultTest1',
abilityName: 'com.example.test.EntryAbility',
action: 'action1',
entities: ['entity1'],
type: 'MIMETYPE',
uri: 'key={true,true,false}',
parameters:
{
mykey0: 2222,
mykey1: [1, 2, 3],
mykey2: '[1, 2, 3]',
mykey3: 'ssssssssssssssssssssssssss',
mykey4: [false, true, false],
mykey5: ['qqqqq', 'wwwwww', 'aaaaaaaaaaaaaaaaa'],
mykey6: true,
}
}
],
operationType: WantAgent.OperationType.START_ABILITIES,
requestCode: 0,
wantAgentFlags:[WantAgent.WantAgentFlags.UPDATE_PRESENT_FLAG]
}
WantAgent.getWantAgent(wantAgentInfo).then((data) => {
console.info('==========================>getWantAgentCallback=======================>');
wantAgent = data;
if (wantAgent) {
WantAgent.getWant(wantAgent).then((data) => {
console.info('==========================>getWantCallback=======================>');
});
}
});
```
## WantAgent.getWantAgent
getWantAgent(info: WantAgentInfo, callback: AsyncCallback\<WantAgent\>): void
......@@ -786,135 +925,6 @@ WantAgent.equal(wantAgent1, wantAgent2).then((data) => {
});
```
## WantAgent.getOperationType<sup>9+</sup>
getOperationType(agent: WantAgent, callback: AsyncCallback\<number>): void;
Obtains the operation type of a **WantAgent** object. This API uses an asynchronous callback to return the result.
**System capability**: SystemCapability.Ability.AbilityRuntime.Core
**Parameters**
| Name | Type | Mandatory| Description |
| ---------- | ------------------------ | ---- | --------------------------------------- |
| agent | WantAgent | Yes | Target **WantAgent** object. |
| callback | AsyncCallback\<number> | Yes | Callback used to return the operation type.|
**Example**
```ts
import WantAgent from '@ohos.wantAgent';
// WantAgent object
let wantAgent;
// WantAgentInfo object
let wantAgentInfo = {
wants: [
{
deviceId: 'deviceId',
bundleName: 'com.neu.setResultOnAbilityResultTest1',
abilityName: 'com.example.test.EntryAbility',
action: 'action1',
entities: ['entity1'],
type: 'MIMETYPE',
uri: 'key={true,true,false}',
parameters:
{
mykey0: 2222,
mykey1: [1, 2, 3],
mykey2: '[1, 2, 3]',
mykey3: 'ssssssssssssssssssssssssss',
mykey4: [false, true, false],
mykey5: ['qqqqq', 'wwwwww', 'aaaaaaaaaaaaaaaaa'],
mykey6: true,
}
}
],
operationType: WantAgent.OperationType.START_ABILITIES,
requestCode: 0,
wantAgentFlags:[WantAgent.WantAgentFlags.UPDATE_PRESENT_FLAG]
}
WantAgent.getWantAgent(wantAgentInfo).then((data) => {
console.info('==========================>getWantAgentCallback=======================>');
wantAgent = data;
if (data) {
WantAgent.getOperationType(wantAgent, (OperationType) => {
console.log('----------- getOperationType ----------, OperationType: ' + OperationType);
})
}
});
```
## WantAgent.getOperationType<sup>9+</sup>
getOperationType(agent: WantAgent): Promise\<number>;
Obtains the operation type of a **WantAgent** object. This API uses a promise to return the result.
**System capability**: SystemCapability.Ability.AbilityRuntime.Core
**Parameters**
| Name | Type | Mandatory| Description |
| ---------- | --------- | ---- | ------------- |
| agent | WantAgent | Yes | Target **WantAgent** object.|
**Return value**
| Type | Description |
| ----------------------------------------------------------- | ------------------------------------------------------------ |
| Promise\<number> | Promise used to return the operation type.|
**Example**
```ts
import WantAgent from '@ohos.wantAgent';
// WantAgent object
let wantAgent;
// WantAgentInfo object
let wantAgentInfo = {
wants: [
{
deviceId: 'deviceId',
bundleName: 'com.neu.setResultOnAbilityResultTest1',
abilityName: 'com.example.test.EntryAbility',
action: 'action1',
entities: ['entity1'],
type: 'MIMETYPE',
uri: 'key={true,true,false}',
parameters:
{
mykey0: 2222,
mykey1: [1, 2, 3],
mykey2: '[1, 2, 3]',
mykey3: 'ssssssssssssssssssssssssss',
mykey4: [false, true, false],
mykey5: ['qqqqq', 'wwwwww', 'aaaaaaaaaaaaaaaaa'],
mykey6: true,
}
}
],
operationType: WantAgent.OperationType.START_ABILITIES,
requestCode: 0,
wantAgentFlags:[WantAgent.WantAgentFlags.UPDATE_PRESENT_FLAG]
}
WantAgent.getWantAgent(wantAgentInfo).then((data) => {
console.info('==========================>getWantAgentCallback=======================>');
wantAgent = data;
WantAgent.getOperationType(wantAgent).then((OperationType) => {
console.log('getOperationType success, OperationType: ' + OperationType);
}).catch((err) => {
console.log('getOperationType fail, err: ' + err);
})
});
```
## WantAgentFlags
**System capability**: SystemCapability.Ability.AbilityRuntime.Core
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册