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

!16075 翻译完成:15888 API扫描文档修改

Merge pull request !16075 from wusongqing/TR15888
...@@ -46,13 +46,6 @@ Enumerates the action constants of the **Want** object. **action** specifies the ...@@ -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. | | 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. | | 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_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. | | 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 ## wantConstant.Entity
...@@ -72,7 +65,7 @@ Enumerates the entity constants of the **Want** object. **entity** specifies add ...@@ -72,7 +65,7 @@ Enumerates the entity constants of the **Want** object. **entity** specifies add
## wantConstant.Flags ## 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 **System capability**: SystemCapability.Ability.AbilityBase
...@@ -91,6 +84,6 @@ Enumerates the flags that specify how the Want will be handled. ...@@ -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_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_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_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](js-apis-ability-featureAbility.md#startability) 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_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.| | 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'; ...@@ -99,7 +99,7 @@ import UIAbility from '@ohos.app.ability.UIAbility';
class MyAbility extends UIAbility { class MyAbility extends UIAbility {
onContinue(wantParam) { onContinue(wantParam) {
return AbilityConstant.OnConinueResult.AGREE; return AbilityConstant.OnContinueResult.AGREE;
} }
} }
``` ```
...@@ -132,7 +132,7 @@ let option = { ...@@ -132,7 +132,7 @@ let option = {
}; };
// Ensure that the context is obtained. // Ensure that the context is obtained.
this.context.startAbility(want, option).then(()={ this.context.startAbility(want, option).then(()=>{
console.log('Succeed to start ability.'); console.log('Succeed to start ability.');
}).catch((error)=>{ }).catch((error)=>{
console.error('Failed to start ability with error: ${JSON.stringify(error)}'); console.error('Failed to start ability with error: ${JSON.stringify(error)}');
......
...@@ -275,7 +275,7 @@ export default class MyFirstAbility extends UIAbility { ...@@ -275,7 +275,7 @@ export default class MyFirstAbility extends UIAbility {
// 2. Register the listener for the ability lifecycle changes through the applicationContext object. // 2. Register the listener for the ability lifecycle changes through the applicationContext object.
try { try {
globalThis.lifecycleId = applicationContext.on('abilityLifecycle', abilityLifecycleCallback); globalThis.lifecycleId = applicationContext.on('abilityLifecycle', abilityLifecycleCallback);
console.log('registerAbilityLifecycleCallback number: ${JSON.stringify(lifecycleId)}'); console.log('registerAbilityLifecycleCallback lifecycleId: ${globalThis.lifecycleId}');
} catch (paramError) { } catch (paramError) {
console.error('error: ${paramError.code}, ${paramError.message}'); console.error('error: ${paramError.code}, ${paramError.message}');
} }
...@@ -285,7 +285,7 @@ export default class MyFirstAbility extends UIAbility { ...@@ -285,7 +285,7 @@ export default class MyFirstAbility extends UIAbility {
MySecondAbility.ts MySecondAbility.ts
```ts ```ts
import UIAbility from 'ohos.app.ability.UIAbility'; import UIAbility from '@ohos.app.ability.UIAbility';
export default class MySecondAbility extends UIAbility { export default class MySecondAbility extends UIAbility {
onDestroy() { onDestroy() {
......
...@@ -59,12 +59,13 @@ For details about the error codes, see [Ability Error Codes](../errorcodes/error ...@@ -59,12 +59,13 @@ For details about the error codes, see [Ability Error Codes](../errorcodes/error
```ts ```ts
import abilityManager from '@ohos.app.ability.abilityManager'; import abilityManager from '@ohos.app.ability.abilityManager';
import ConfigurationConstant from '@ohos.app.ability.ConfigurationConstant';
const config = { const config = {
language: 'Zh-Hans', // Simplified Chinese. language: 'Zh-Hans', // Simplified Chinese.
colorMode: COLOR_MODE_LIGHT, // Light theme. colorMode: ConfigurationConstant.ColorMode.COLOR_MODE_LIGHT, // Light theme.
direction: DIRECTION_VERTICAL, // Vertical direction. direction: ConfigurationConstant.Direction.DIRECTION_VERTICAL, // Vertical direction.
screenDensity: SCREEN_DENSITY_SDPI, // The screen pixel density is 'sdpi'. screenDensity: ConfigurationConstant.ScreenDensity.SCREEN_DENSITY_SDPI, // The screen pixel density is 'sdpi'.
displayId: 1, // The application is displayed on the display with ID 1. displayId: 1, // The application is displayed on the display with ID 1.
hasPointerDevice: true, // A pointer device is connected. hasPointerDevice: true, // A pointer device is connected.
}; };
...@@ -116,12 +117,13 @@ For details about the error codes, see [Ability Error Codes](../errorcodes/error ...@@ -116,12 +117,13 @@ For details about the error codes, see [Ability Error Codes](../errorcodes/error
```ts ```ts
import abilityManager from '@ohos.app.ability.abilityManager'; import abilityManager from '@ohos.app.ability.abilityManager';
import ConfigurationConstant from '@ohos.app.ability.ConfigurationConstant';
const config = { const config = {
language: 'Zh-Hans', // Simplified Chinese. language: 'Zh-Hans', // Simplified Chinese.
colorMode: COLOR_MODE_LIGHT, // Light theme. colorMode: ConfigurationConstant.ColorMode.COLOR_MODE_LIGHT, // Light theme.
direction: DIRECTION_VERTICAL, // Vertical direction. direction: ConfigurationConstant.Direction.DIRECTION_VERTICAL, // Vertical direction.
screenDensity: SCREEN_DENSITY_SDPI, // The screen pixel density is 'sdpi'. screenDensity: ConfigurationConstant.ScreenDensity.SCREEN_DENSITY_SDPI, // The screen pixel density is 'sdpi'.
displayId: 1, // The application is displayed on the display with ID 1. displayId: 1, // The application is displayed on the display with ID 1.
hasPointerDevice: true, // A pointer device is connected. hasPointerDevice: true, // A pointer device is connected.
}; };
......
...@@ -459,7 +459,7 @@ For details about the error codes, see [Ability Error Codes](../errorcodes/error ...@@ -459,7 +459,7 @@ For details about the error codes, see [Ability Error Codes](../errorcodes/error
```ts ```ts
import appManager from '@ohos.app.ability.appManager'; import appManager from '@ohos.app.ability.appManager';
let observeId = 0; let observerId = 0;
// 1. Register an application state observer. // 1. Register an application state observer.
let applicationStateObserver = { let applicationStateObserver = {
...@@ -540,7 +540,7 @@ For details about the error codes, see [Ability Error Codes](../errorcodes/error ...@@ -540,7 +540,7 @@ For details about the error codes, see [Ability Error Codes](../errorcodes/error
```ts ```ts
import appManager from '@ohos.app.ability.appManager'; import appManager from '@ohos.app.ability.appManager';
let observeId = 0; let observerId = 0;
// 1. Register an application state observer. // 1. Register an application state observer.
let applicationStateObserver = { let applicationStateObserver = {
......
...@@ -72,9 +72,9 @@ import AbilityStage from '@ohos.app.ability.AbilityStage'; ...@@ -72,9 +72,9 @@ import AbilityStage from '@ohos.app.ability.AbilityStage';
export default class MyAbilityStage extends AbilityStage { export default class MyAbilityStage extends AbilityStage {
onCreate() { onCreate() {
appRecovery.enableAppRecovery( appRecovery.enableAppRecovery(
appRecovery.RestartFlag::ALWAYS_RESTART, appRecovery.RestartFlag.ALWAYS_RESTART,
appRecovery.SaveOccasionFlag::SAVE_WHEN_ERROR, appRecovery.SaveOccasionFlag.SAVE_WHEN_ERROR,
appRecovery.SaveModeFlag::SAVE_WITH_FILE appRecovery.SaveModeFlag.SAVE_WITH_FILE
); );
} }
} }
......
...@@ -127,6 +127,7 @@ Obtains the request callback from Want. ...@@ -127,6 +127,7 @@ Obtains the request callback from Want.
## RequestInfo ## RequestInfo
Defines the request information, which is used as an input parameter for binding the modal dialog box. Defines the request information, which is used as an input parameter for binding the modal dialog box.
**System capability**: SystemCapability.Ability.AbilityRuntime.AbilityCore **System capability**: SystemCapability.Ability.AbilityRuntime.AbilityCore
**Example** **Example**
......
...@@ -35,7 +35,7 @@ onMemoryLevel(level: AbilityConstant.MemoryLevel): void; ...@@ -35,7 +35,7 @@ onMemoryLevel(level: AbilityConstant.MemoryLevel): void;
Called when the system memory level changes. Called when the system memory level changes.
**System capability**: SystemCapability.Ability.AbilityRuntime.Core **System capability**: SystemCapability.Ability.AbilityRuntime.AbilityCore
**Parameters** **Parameters**
...@@ -55,7 +55,7 @@ export default class MyAbility extends UIAbility { ...@@ -55,7 +55,7 @@ export default class MyAbility extends UIAbility {
onCreate() { onCreate() {
console.log('MyAbility onCreate'); console.log('MyAbility onCreate');
globalThis.applicationContext = this.context.getApplicationContext(); globalThis.applicationContext = this.context.getApplicationContext();
let EnvironmentCallback = { let environmentCallback = {
onConfigurationUpdated(config){ onConfigurationUpdated(config){
console.log('onConfigurationUpdated config: ${JSON.stringify(config)}'); console.log('onConfigurationUpdated config: ${JSON.stringify(config)}');
} }
...@@ -67,7 +67,7 @@ export default class MyAbility extends UIAbility { ...@@ -67,7 +67,7 @@ export default class MyAbility extends UIAbility {
// 1. Obtain an applicationContext object. // 1. Obtain an applicationContext object.
let applicationContext = globalThis.applicationContext; let applicationContext = globalThis.applicationContext;
// 2. Register a listener for the environment changes through the applicationContext object. // 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)}'); console.log('registerEnvironmentCallback number: ${JSON.stringify(callbackId)}');
} }
onDestroy() { onDestroy() {
......
...@@ -106,7 +106,7 @@ Called following **onCreate()** when a ServiceExtensionAbility is started by cal ...@@ -106,7 +106,7 @@ Called following **onCreate()** when a ServiceExtensionAbility is started by cal
## ServiceExtensionAbility.onConnect ## 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. 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 ...@@ -148,7 +148,7 @@ Called following **onCreate()** when a ServiceExtensionAbility is started by cal
## ServiceExtensionAbility.onDisconnect ## ServiceExtensionAbility.onDisconnect
onDisconnect(want: Want): void; onDisconnect(want: Want): void | Promise<void>;
Called when a client is disconnected from this ServiceExtensionAbility. 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 ...@@ -124,7 +124,7 @@ Called when the **WindowStage** is restored during the migration of this UIAbili
## UIAbility.onDestroy ## UIAbility.onDestroy
onDestroy(): void; onDestroy(): void | Promise&lt;void&gt;;
Called when this UIAbility is destroyed to clear resources. 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. ...@@ -181,7 +181,7 @@ Called when this UIAbility is switched from the foreground to the background.
## UIAbility.onContinue ## 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. Called to save data during the ability migration preparation process.
...@@ -267,7 +267,7 @@ Dumps client information. ...@@ -267,7 +267,7 @@ Dumps client information.
## UIAbility.onSaveState ## 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. 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 ...@@ -308,7 +308,7 @@ Implements sending of sequenceable data to the target ability when the CallerAbi
## Caller.call ## 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. Sends sequenceable data to the target ability.
...@@ -319,7 +319,7 @@ Sends sequenceable data to the target ability. ...@@ -319,7 +319,7 @@ Sends sequenceable data to the target ability.
| Name| Type| Mandatory| Description| | 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.| | 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** **Return value**
...@@ -387,7 +387,7 @@ For details about the error codes, see [Ability Error Codes](../errorcodes/error ...@@ -387,7 +387,7 @@ For details about the error codes, see [Ability Error Codes](../errorcodes/error
## Caller.callWithResult ## 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. 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 ...@@ -398,7 +398,7 @@ Sends sequenceable data to the target ability and obtains the sequenceable data
| Name| Type| Mandatory| Description| | 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.| | 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** **Return value**
...@@ -509,7 +509,7 @@ Releases the caller interface of the target ability. ...@@ -509,7 +509,7 @@ Releases the caller interface of the target ability.
## Caller.onRelease ## 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. 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 ...@@ -519,7 +519,7 @@ Registers a callback that is invoked when the stub on the target ability is disc
| Name| Type| Mandatory| Description| | 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** **Example**
...@@ -560,7 +560,7 @@ Registers a callback that is invoked when the stub on the target ability is disc ...@@ -560,7 +560,7 @@ Registers a callback that is invoked when the stub on the target ability is disc
| Name| Type| Mandatory| Description| | Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
| type | string | Yes| Event type. The value is fixed at **release**.| | 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** **Error codes**
...@@ -609,7 +609,7 @@ Deregisters a callback that is invoked when the stub on the target ability is di ...@@ -609,7 +609,7 @@ Deregisters a callback that is invoked when the stub on the target ability is di
| Name| Type| Mandatory| Description| | Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
| type | string | Yes| Event type. The value is fixed at **release**.| | 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** **Error codes**
...@@ -816,10 +816,10 @@ For details about the error codes, see [Ability Error Codes](../errorcodes/error ...@@ -816,10 +816,10 @@ For details about the error codes, see [Ability Error Codes](../errorcodes/error
## CalleeCallback ## CalleeCallback
(indata: rpc.MessageParcel): rpc.Sequenceable; (indata: rpc.MessageParcel): rpc.Parcelable;
**System capability**: SystemCapability.Ability.AbilityRuntime.AbilityCore **System capability**: SystemCapability.Ability.AbilityRuntime.AbilityCore
| Name| Readable| Writable| Type| Description| | 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 { ...@@ -273,7 +273,7 @@ export default class MyFormExtensionAbility extends FormExtensionAbility {
## onShareForm ## onShareForm
onShareForm?(formId: string): { [key: string]: any } onShareForm?(formId: string): { [key: string]: Object }
Called by the widget provider to receive shared widget data. 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. ...@@ -263,49 +263,6 @@ Registers an observer to listen for the state changes of all applications.
console.log('-------- observerCode: ---------', observerCode); 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> ## appManager.unregisterApplicationStateObserver<sup>8+</sup>
unregisterApplicationStateObserver(observerId: number, callback: AsyncCallback\<void>): void; unregisterApplicationStateObserver(observerId: number, callback: AsyncCallback\<void>): void;
......
...@@ -33,11 +33,14 @@ export default class EntryAbility extends UIAbility { ...@@ -33,11 +33,14 @@ export default class EntryAbility extends UIAbility {
console.info(`envCallback onConfigurationUpdated success: ${JSON.stringify(config)}`); console.info(`envCallback onConfigurationUpdated success: ${JSON.stringify(config)}`);
let language = config.language; let language = config.language;
let colorMode = config.colorMode; let colorMode = config.colorMode;
},
onMemoryLevel(level){
console.log('onMemoryLevel level: ${JSON.stringify(level)}');
} }
}; };
let applicationContext = this.context.getApplicationContext(); let applicationContext = this.context.getApplicationContext();
applicationContext.registerEnvironmentCallback(envCallback); applicationContext.on('environment',envCallback);
windowStage.loadContent('pages/index', (err, data) => { windowStage.loadContent('pages/index', (err, data) => {
if (err.code) { if (err.code) {
......
...@@ -382,97 +382,6 @@ Obtains the snapshot of a given mission. This API uses a promise to return the r ...@@ -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 ## missionManager.lockMission
lockMission(missionId: number, callback: AsyncCallback&lt;void&gt;): void; lockMission(missionId: number, callback: AsyncCallback&lt;void&gt;): void;
......
...@@ -27,7 +27,6 @@ import Want from '@ohos.application.Want'; ...@@ -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). | | action | string | No | Action to take, such as viewing and sharing application details. In implicit **Want**, you can define this attribute and use it together with **uri** or **parameters** to specify the operation to be performed on the data. For details, see [action](js-apis-app-ability-wantConstant.md#wantConstant.Action). For details about the definition and matching rules of implicit Want, see [Matching Rules of Explicit Want and Implicit Want](application-models/explicit-implicit-want-mappings.md). |
| parameters | {[key: string]: any} | No | Want parameters in the form of custom key-value (KV) pairs. By default, the following keys are carried:<br>- **ohos.aafwk.callerPid**: PID of the caller.<br>- **ohos.aafwk.param.callerToken**: token of the caller.<br>- **ohos.aafwk.param.callerUid**: UID in [bundleInfo](js-apis-bundle-BundleInfo.md#bundleinfo-1), that is, the application UID in the bundle information.<br>- **component.startup.newRules**: whether to enable the new control rule.<br>- **moduleName**: module name of the caller. No matter what this field is set to, the correct module name will be sent to the peer.<br>- **ohos.dlp.params.sandbox**: available only for DLP files. | | parameters | {[key: string]: any} | No | Want parameters in the form of custom key-value (KV) pairs. By default, the following keys are carried:<br>- **ohos.aafwk.callerPid**: PID of the caller.<br>- **ohos.aafwk.param.callerToken**: token of the caller.<br>- **ohos.aafwk.param.callerUid**: UID in [bundleInfo](js-apis-bundle-BundleInfo.md#bundleinfo-1), that is, the application UID in the bundle information.<br>- **component.startup.newRules**: whether to enable the new control rule.<br>- **moduleName**: module name of the caller. No matter what this field is set to, the correct module name will be sent to the peer.<br>- **ohos.dlp.params.sandbox**: available only for DLP files. |
| entities | Array\<string> | No | Additional category information (such as browser and video player) of the ability. It is a supplement to the **action** field for implicit Want. and is used to filter ability types. For details, see [entity](js-apis-app-ability-wantConstant.md#wantConstant.Entity). | | 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** **Example**
......
...@@ -368,8 +368,8 @@ Continues a mission on a remote device. This API uses an asynchronous callback t ...@@ -368,8 +368,8 @@ Continues a mission on a remote device. This API uses an asynchronous callback t
| Name | Type | Mandatory | Description | | Name | Type | Mandatory | Description |
| --------- | --------------------------------------- | ---- | ----- | | --------- | --------------------------------------- | ---- | ----- |
| parameter | [ContinueDeviceInfo](#continuedeviceinfo) | Yes | Parameters required for mission continuation.| | parameter | [ContinueDeviceInfo](#js-apis-inner-application-continueDeviceInfo.md) | Yes | Parameters required for mission continuation.|
| options | [ContinueCallback](#continuecallback) | Yes | Callback invoked when the mission continuation is complete.| | 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.| | callback | AsyncCallback&lt;void&gt; | Yes | Callback used to return the result.|
**Error codes** **Error codes**
...@@ -426,8 +426,8 @@ Continues a mission on a remote device. This API uses a promise to return the re ...@@ -426,8 +426,8 @@ Continues a mission on a remote device. This API uses a promise to return the re
| Name | Type | Mandatory | Description | | Name | Type | Mandatory | Description |
| --------- | --------------------------------------- | ---- | ----- | | --------- | --------------------------------------- | ---- | ----- |
| parameter | [ContinueDeviceInfo](#continuedeviceinfo) | Yes | Parameters required for mission continuation.| | parameter | [ContinueDeviceInfo](#js-apis-inner-application-continueDeviceInfo.md) | Yes | Parameters required for mission continuation.|
| options | [ContinueCallback](#continuecallback) | Yes | Callback invoked when the mission continuation is complete.| | options | [ContinueCallback](#js-apis-inner-application-continueCallback.md) | Yes | Callback invoked when the mission continuation is complete.|
**Return value** **Return value**
...@@ -514,30 +514,3 @@ Defines the parameters required for registering a listener. ...@@ -514,30 +514,3 @@ Defines the parameters required for registering a listener.
| Name | Type | Readable | Writable | Description | | Name | Type | Readable | Writable | Description |
| -------- | ------ | ---- | ---- | ------- | | -------- | ------ | ---- | ---- | ------- |
| deviceId | string | Yes | Yes | Device ID.| | 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() { ...@@ -27,11 +27,9 @@ function executeBatchOperation() {
DAHelper = featureAbility.acquireDataAbilityHelper(dataAbilityUri); DAHelper = featureAbility.acquireDataAbilityHelper(dataAbilityUri);
if (DAHelper === null) { if (DAHelper === null) {
console.error('DAHelper is null'); console.error('DAHelper is null');
return;
} }
} catch (err) { } catch (err) {
console.error('acquireDataAbilityHelper fail, error: ${JSON.stringify(err)}'); console.error('acquireDataAbilityHelper fail, error: ${JSON.stringify(err)}');
return;
} }
let valueBucket = { let valueBucket = {
......
...@@ -11,8 +11,6 @@ The **AbilityDelegator** module provides APIs for managing **AbilityMonitor** in ...@@ -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**. An **AbilityDelegator** object is obtained by calling [getAbilityDelegator](js-apis-app-ability-abilityDelegatorRegistry.md#abilitydelegatorregistrygetabilitydelegator) in **AbilityDelegatorRegistry**.
```ts ```ts
import AbilityDelegatorRegistry from '@ohos.app.ability.abilityDelegatorRegistry'; import AbilityDelegatorRegistry from '@ohos.app.ability.abilityDelegatorRegistry';
let abilityDelegator = AbilityDelegatorRegistry.getAbilityDelegator();
``` ```
## AbilityDelegator ## AbilityDelegator
...@@ -492,8 +490,8 @@ abilityDelegator = AbilityDelegatorRegistry.getAbilityDelegator(); ...@@ -492,8 +490,8 @@ abilityDelegator = AbilityDelegatorRegistry.getAbilityDelegator();
abilityDelegator.getCurrentTopAbility((err : any, data : any) => { abilityDelegator.getCurrentTopAbility((err : any, data : any) => {
console.info('getCurrentTopAbility callback'); console.info('getCurrentTopAbility callback');
ability = data; ability = data;
abilityDelegator.doAbilityForeground(ability, (err : any, data : any) => { abilityDelegator.doAbilityForeground(ability, (err : any) => {
console.info('doAbilityForeground callback'); console.info("doAbilityForeground callback");
}); });
}); });
``` ```
...@@ -528,8 +526,8 @@ abilityDelegator = AbilityDelegatorRegistry.getAbilityDelegator(); ...@@ -528,8 +526,8 @@ abilityDelegator = AbilityDelegatorRegistry.getAbilityDelegator();
abilityDelegator.getCurrentTopAbility((err : any, data : any) => { abilityDelegator.getCurrentTopAbility((err : any, data : any) => {
console.info('getCurrentTopAbility callback'); console.info('getCurrentTopAbility callback');
ability = data; ability = data;
abilityDelegator.doAbilityForeground(ability).then((data : any) => { abilityDelegator.doAbilityForeground(ability).then(() => {
console.info('doAbilityForeground promise'); console.info("doAbilityForeground promise");
}); });
}); });
``` ```
...@@ -559,8 +557,8 @@ abilityDelegator = AbilityDelegatorRegistry.getAbilityDelegator(); ...@@ -559,8 +557,8 @@ abilityDelegator = AbilityDelegatorRegistry.getAbilityDelegator();
abilityDelegator.getCurrentTopAbility((err : any, data : any) => { abilityDelegator.getCurrentTopAbility((err : any, data : any) => {
console.info('getCurrentTopAbility callback'); console.info('getCurrentTopAbility callback');
ability = data; ability = data;
abilityDelegator.doAbilityBackground(ability, (err : any, data : any) => { abilityDelegator.doAbilityBackground(ability, (err : any) => {
console.info('doAbilityBackground callback'); console.info("doAbilityBackground callback");
}); });
}); });
``` ```
...@@ -595,8 +593,8 @@ abilityDelegator = AbilityDelegatorRegistry.getAbilityDelegator(); ...@@ -595,8 +593,8 @@ abilityDelegator = AbilityDelegatorRegistry.getAbilityDelegator();
abilityDelegator.getCurrentTopAbility((err : any, data : any) => { abilityDelegator.getCurrentTopAbility((err : any, data : any) => {
console.info('getCurrentTopAbility callback'); console.info('getCurrentTopAbility callback');
ability = data; ability = data;
abilityDelegator.doAbilityBackground(ability).then((data : any) => { abilityDelegator.doAbilityBackground(ability).then(() => {
console.info('doAbilityBackground promise'); console.info("doAbilityBackground promise");
}); });
}); });
``` ```
......
...@@ -115,7 +115,7 @@ export default class EntryAbility extends UIAbility { ...@@ -115,7 +115,7 @@ export default class EntryAbility extends UIAbility {
onDestroy() { onDestroy() {
let applicationContext = this.context.getApplicationContext(); let applicationContext = this.context.getApplicationContext();
console.log('stage applicationContext: ${applicationContext}'); console.log('stage applicationContext: ${applicationContext}');
applicationContext.off(type: 'abilityLifecycle', lifecycleId, (error, data) => { applicationContext.off('abilityLifecycle', lifecycleId, (error, data) => {
if (error && error.code !== 0) { if (error && error.code !== 0) {
console.error('unregisterAbilityLifecycleCallback fail, err: ${JSON.stringify(error)}'); console.error('unregisterAbilityLifecycleCallback fail, err: ${JSON.stringify(error)}');
} else { } else {
...@@ -152,7 +152,7 @@ export default class MyAbility extends Ability { ...@@ -152,7 +152,7 @@ export default class MyAbility extends Ability {
onDestroy() { onDestroy() {
let applicationContext = this.context.getApplicationContext(); let applicationContext = this.context.getApplicationContext();
console.log('stage applicationContext: ${applicationContext}'); console.log('stage applicationContext: ${applicationContext}');
applicationContext.off(type: 'abilityLifecycle', lifecycleId); applicationContext.off('abilityLifecycle', lifecycleId);
} }
} }
``` ```
......
...@@ -30,9 +30,13 @@ let listener = { ...@@ -30,9 +30,13 @@ let listener = {
}, },
onMissionMovedToFront: function (mission) { onMissionMovedToFront: function (mission) {
console.log('onMissionMovedToFront mission: ${JSON.stringify(mission)}'); console.log('onMissionMovedToFront mission: ${JSON.stringify(mission)}');
},
onMissionLabelUpdated: function (mission) {
console.log('onMissionLabelUpdated mission: ' + JSON.stringify(mission));
}, },
onMissionIconUpdated: function (mission, icon) { 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) { onMissionClosed: function (mission) {
console.log('onMissionClosed mission: ${JSON.stringify(mission)}'); console.log('onMissionClosed mission: ${JSON.stringify(mission)}');
......
...@@ -12,6 +12,145 @@ The **WantAgent** module provides APIs for creating and comparing **WantAgent** ...@@ -12,6 +12,145 @@ The **WantAgent** module provides APIs for creating and comparing **WantAgent**
import WantAgent from '@ohos.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 ## WantAgent.getWantAgent
getWantAgent(info: WantAgentInfo, callback: AsyncCallback\<WantAgent\>): void getWantAgent(info: WantAgentInfo, callback: AsyncCallback\<WantAgent\>): void
...@@ -786,135 +925,6 @@ WantAgent.equal(wantAgent1, wantAgent2).then((data) => { ...@@ -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 ## WantAgentFlags
**System capability**: SystemCapability.Ability.AbilityRuntime.Core **System capability**: SystemCapability.Ability.AbilityRuntime.Core
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册