提交 0832dd17 编写于 作者: G Gloria

Update docs against multiple PRs targeting the Ability framework APIs

Signed-off-by: wusongqing<wusongqing@huawei.com>
上级 bdf44d42
# APIs
- [API Reference Document Description](development-intro.md)
- Ability Framework
- FA Model
- [@ohos.ability.featureAbility](js-apis-featureAbility.md)
- [@ohos.ability.particleAbility](js-apis-particleAbility.md)
- ability/[dataAbilityHelper](js-apis-dataAbilityHelper.md)
- app/[context](js-apis-Context.md)
- Stage Model
- [@ohos.application.Ability](js-apis-application-ability.md)
- [@ohos.application.AbilityConstant](js-apis-application-abilityConstant.md)
- [@ohos.application.AbilityStage](js-apis-application-abilitystage.md)
- [@ohos.application.abilityLifecycleCallback](js-apis-application-abilityLifecycleCallback.md)
- Stage Model (Recommended)
- [@ohos.app.ability.Ability](js-apis-app-ability-ability.md)
- [@ohos.app.ability.AbilityConstant](js-apis-app-ability-abilityConstant.md)
- [@ohos.app.ability.abilityLifecycleCallback](js-apis-app-ability-abilityLifecycleCallback.md)
- [@ohos.app.ability.AbilityStage](js-apis-app-ability-abilityStage.md)
- [@ohos.app.ability.common](js-apis-app-ability-common.md)
- [@ohos.app.ability.contextConstant](js-apis-app-ability-contextConstant.md)
- [@ohos.app.ability.EnvironmentCallback](js-apis-app-ability-environmentCallback.md)
- [@ohos.app.ability.ExtensionAbility](js-apis-app-ability-extensionAbility.md)
- [@ohos.app.ability.ServiceExtensionAbility](js-apis-app-ability-serviceExtensionAbility.md)
- [@ohos.app.ability.StartOptions](js-apis-app-ability-startOptions.md)
- [@ohos.app.ability.UIAbility](js-apis-app-ability-uiAbility.md)
- [@ohos.app.form.FormExtensionAbility](js-apis-app-form-formExtensionAbility.md)
- [@ohos.application.DataShareExtensionAbility](js-apis-application-DataShareExtensionAbility.md)
- [@ohos.application.EnvironmentCallback](js-apis-application-EnvironmentCallback.md)
- [@ohos.application.FormExtension](js-apis-formextension.md)
- [@ohos.application.ServiceExtensionAbility](js-apis-service-extension-ability.md)
- [@ohos.application.StartOptions](js-apis-application-StartOptions.md)
- [@ohos.application.StaticSubscriberExtensionAbility](js-apis-application-staticSubscriberExtensionAbility.md)
- [@ohos.application.WindowExtensionAbility](js-apis-application-windowExtensionAbility.md)
- application/[AbilityContext](js-apis-ability-context.md)
- application/[ApplicationContext](js-apis-application-applicationContext.md)
- application/[AbilityStageContext](js-apis-abilitystagecontext.md)
- application/[Context](js-apis-application-context.md)
- application/[ExtensionContext](js-apis-extension-context.md)
- application/[FormExtensionContext](js-apis-formextensioncontext.md)
- application/[PermissionRequestResult](js-apis-permissionrequestresult.md)
- application/[ServiceExtensionContext](js-apis-service-extension-context.md)
- FA and Stage Models
- [@ohos.ability.dataUriUtils](js-apis-DataUriUtils.md)
- Stage Model (To Be Deprecated Soon)
- [@ohos.application.Ability](js-apis-application-ability.md)
- [@ohos.application.AbilityConstant](js-apis-application-abilityConstant.md)
- [@ohos.application.AbilityLifecycleCallback](js-apis-application-abilityLifecycleCallback.md)
- [@ohos.application.AbilityStage](js-apis-application-abilityStage.md)
- [@ohos.application.context](js-apis-application-context.md)
- [@ohos.application.EnvironmentCallback](js-apis-application-environmentCallback.md)
- [@ohos.application.ExtensionAbility](js-apis-application-extensionAbility.md)
- [@ohos.application.FormExtension](js-apis-application-formExtension.md)
- [@ohos.application.ServiceExtensionAbility](js-apis-application-serviceExtensionAbility.md)
- [@ohos.application.StartOptions](js-apis-application-startOptions.md)
- FA Model
- [@ohos.ability.ability](js-apis-ability-ability.md)
- [@ohos.ability.featureAbility](js-apis-ability-featureAbility.md)
- [@ohos.ability.particleAbility](js-apis-ability-particleAbility.md)
- Both Models (Recommended)
- [@ohos.app.ability.abilityDelegatorRegistry](js-apis-app-ability-abilityDelegatorRegistry.md)
- [@ohos.app.ability.abilityManager](js-apis-app-ability-abilityManager.md)
- [@ohos.app.ability.appManager](js-apis-app-ability-appManager.md)
- [@ohos.app.ability.appRecovery](js-apis-app-ability-appRecovery.md)
- [@ohos.app.ability.Configuration](js-apis-app-ability-configuration.md)
- [@ohos.app.ability.ConfigurationConstant](js-apis-app-ability-configurationConstant.md)
- [@ohos.app.ability.dataUriUtils](js-apis-app-ability-dataUriUtils.md)
- [@ohos.app.ability.errorManager](js-apis-app-ability-errorManager.md)
- [@ohos.app.ability.missionManager](js-apis-app-ability-missionManager.md)
- [@ohos.app.ability.quickFixManager](js-apis-app-ability-quickFixManager.md)
- [@ohos.app.ability.Want](js-apis-app-ability-want.md)
- [@ohos.app.ability.wantAgent](js-apis-app-ability-wantAgent.md)
- [@ohos.app.ability.wantConstant](js-apis-app-ability-wantConstant.md)
- [@ohos.app.form.formBindingData](js-apis-app-form-formBindingData.md)
- [@ohos.app.form.formHost](js-apis-app-form-formHost.md)
- [@ohos.app.form.formInfo](js-apis-app-form-formInfo.md)
- [@ohos.app.form.formProvider](js-apis-app-form-formProvider.md)
- Both Models (To Be Deprecated Soon)
- [@ohos.ability.dataUriUtils](js-apis-ability-dataUriUtils.md)
- [@ohos.ability.errorCode](js-apis-ability-errorCode.md)
- [@ohos.ability.wantConstant](js-apis-ability-wantConstant.md)
- [@ohos.application.abilityDelegatorRegistry](js-apis-abilityDelegatorRegistry.md)
- [@ohos.application.abilityDelegatorRegistry](js-apis-application-abilityDelegatorRegistry.md)
- [@ohos.application.abilityManager](js-apis-application-abilityManager.md)
- [@ohos.application.appManager](js-apis-appmanager.md)
- [@ohos.application.errorManager](js-apis-errorManager.md)
- [@ohos.application.formBindingData](js-apis-formbindingdata.md)
- [@ohos.application.formError](js-apis-formerror.md)
- [@ohos.application.formHost](js-apis-formhost.md)
- [@ohos.application.formInfo](js-apis-formInfo.md)
- [@ohos.application.formProvider](js-apis-formprovider.md)
- [@ohos.application.missionManager](js-apis-missionManager.md)
- [@ohos.application.quickFixManager](js-apis-application-quickFixManager.md)
- [@ohos.application.Want](js-apis-application-Want.md)
- [@ohos.continuation.continuationManager](js-apis-continuation-continuationManager.md)
- [@ohos.application.appManager](js-apis-application-appManager.md)
- [@ohos.application.Configuration](js-apis-application-configuration.md)
- [@ohos.application.ConfigurationConstant](js-apis-application-configurationConstant.md)
- [@ohos.application.errorManager)](js-apis-application-errorManager.md)
- [@ohos.application.formBindingData](js-apis-application-formBindingData.md)
- [@ohos.application.formError](js-apis-application-formError.md)
- [@ohos.application.formHost](js-apis-application-formHost.md)
- [@ohos.application.formInfo](js-apis-application-formInfo.md)
- [@ohos.application.formProvider](js-apis-application-formProvider.md)
- [@ohos.application.missionManager](js-apis-application-missionManager.md)
- [@ohos.application.Want](js-apis-application-want.md)
- [@ohos.wantAgent](js-apis-wantAgent.md)
- application/[abilityDelegator](js-apis-application-abilityDelegator.md)
- application/[abilityDelegatorArgs](js-apis-application-abilityDelegatorArgs.md)
- application/[abilityMonitor](js-apis-application-abilityMonitor.md)
- application/[AbilityRunningInfo](js-apis-abilityrunninginfo.md)
- application/[ExtensionRunningInfo](js-apis-extensionrunninginfo.md)
- application/[MissionSnapshot](js-apis-application-MissionSnapshot.md)
- application/[ProcessRunningInformation](js-apis-processrunninginformation.md)
- application/[shellCmdResult](js-apis-application-shellCmdResult.md)
- continuation/[continuationExtraParams](js-apis-continuation-continuationExtraParams.md)
- continuation/[ContinuationResult](js-apis-continuation-continuationResult.md)
- Dependent Elements and Definitions
- ability
- [abilityResult](js-apis-inner-ability-abilityResult.md)
- [connectOptions](js-apis-inner-ability-connectOptions.md)
- [dataAbilityHelper](js-apis-inner-ability-dataAbilityHelper.md)
- [dataAbilityOperation](js-apis-inner-ability-dataAbilityOperation.md)
- [dataAbilityResult](js-apis-inner-ability-dataAbilityResult.md)
- [startAbilityParameter](js-apis-inner-ability-startAbilityParameter.md)
- [want](js-apis-inner-ability-want.md)
- app
- [appVersionInfo](js-apis-inner-app-appVersionInfo.md)
- [context](js-apis-inner-app-context.md)
- [processInfo](js-apis-inner-app-processInfo.md)
- application
- [AbilityContext](js-apis-ability-context.md)
- [abilityDelegator](js-apis-inner-application-abilityDelegator.md)
- [abilityDelegatorArgs](js-apis-inner-application-abilityDelegatorArgs.md)
- [abilityMonitor](js-apis-inner-application-abilityMonitor.md)
- [AbilityRunningInfo](js-apis-inner-application-abilityRunningInfo.md)
- [AbilityStageContext](js-apis-inner-application-abilityStageContext.md)
- [AbilityStateData](js-apis-inner-application-abilityStateData.md)
- [abilityStageMonitor](js-apis-inner-application-abilityStageMonitor.md)
- [ApplicationContext](js-apis-inner-application-applicationContext.md)
- [ApplicationStateObserver](js-apis-inner-application-applicationStateObserver.md)
- [AppStateData](js-apis-inner-application-appStateData.md)
- [BaseContext](js-apis-inner-application-baseContext.md)
- [Context](js-apis-inner-application-context.md)
- [ContinueCallback](js-apis-inner-application-continueCallback.md)
- [ContinueDeviceInfo](js-apis-inner-application-continueDeviceInfo.md)
- [ErrorObserver](js-apis-inner-application-errorObserver.md)
- [ExtensionContext](js-apis-inner-application-extensionContext.md)
- [ExtensionRunningInfo](js-apis-inner-application-extensionRunningInfo.md)
- [FormExtensionContext](js-apis-inner-application-formExtensionContext.md)
- [MissionCallbacks](js-apis-inner-application-missionCallbacks.md)
- [MissionDeviceInfo](js-apis-inner-application-missionDeviceInfo.md)
- [MissionInfo](js-apis-inner-application-missionInfo.md)
- [MissionListener](js-apis-inner-application-missionListener.md)
- [MissionParameter](js-apis-inner-application-missionParameter.md)
- [MissionSnapshot](js-apis-inner-application-missionSnapshot.md)
- [PermissionRequestResult](js-apis-inner-application-permissionRequestResult.md)
- [ProcessData](js-apis-inner-application-processData.md)
- [ProcessRunningInfo](js-apis-inner-application-processRunningInfo.md)
- [ProcessRunningInformation](js-apis-inner-application-processRunningInformation.md)
- [ServiceExtensionContext](js-apis-inner-application-serviceExtensionContext.md)
- [UIAbilityContext](js-apis-inner-application-uiAbilityContext.md)
- [shellCmdResult](js-apis-inner-application-shellCmdResult.md)
- wantAgent
- [triggerInfo](js-apis-inner-wantAgent-triggerInfo.md)
- [wantAgentInfo](js-apis-inner-wantAgent-wantAgentInfo.md)
- Continuation
- [@ohos.continuation.continuationManager (continuationManager)](js-apis-continuation-continuationManager.md)
- continuation
- [continuationExtraParams](js-apis-continuation-continuationExtraParams.md)
- [continuationResult](js-apis-continuation-continuationResult.md)
- Common Event and Notification
- [@ohos.events.emitter](js-apis-emitter.md)
- [@ohos.notification](js-apis-notification.md)
- application/[EventHub](js-apis-eventhub.md)
- application/[EventHub](js-apis-inner-application-eventHub.md)
- Bundle Management
- [@ohos.bundle.appControl](js-apis-appControl.md)
- [@ohos.bundle.bundleManager](js-apis-bundleManager.md)
......@@ -69,19 +138,20 @@
- [@ohos.bundle.installer](js-apis-installer.md)
- [@ohos.bundle.launcherBundleManager](js-apis-launcherBundleManager.md)
- [@ohos.zlib](js-apis-zlib.md)
- bundleManager/[abilityInfo](js-apis-bundleManager-abilityInfo.md)
- bundleManager/[applicationInfo](js-apis-bundleManager-applicationInfo.md)
- bundleManager/[bundleInfo](js-apis-bundleManager-bundleInfo.md)
- bundleManager/[dispatchInfo](js-apis-bundleManager-dispatchInfo.md)
- bundleManager/[elementName](js-apis-bundleManager-elementName.md)
- bundleManager/[extensionAbilityInfo](js-apis-bundleManager-extensionAbilityInfo.md)
- bundleManager/[hapModuleInfo](js-apis-bundleManager-hapModuleInfo.md)
- bundleManager/[launcherAbilityInfo](js-apis-bundleManager-launcherAbilityInfo.md)
- bundleManager/[metadata](js-apis-bundleManager-metadata.md)
- bundleManager/[packInfo](js-apis-bundleManager-packInfo.md)
- bundleManager/[permissionDef](js-apis-bundleManager-permissionDef.md)
- bundleManager/[remoteAbilityInfo](js-apis-bundleManager-remoteAbilityInfo.md)
- bundleManager/[shortcutInfo](js-apis-bundleManager-shortcutInfo.md)
- bundleManager
- [abilityInfo](js-apis-bundleManager-abilityInfo.md)
- [applicationInfo](js-apis-bundleManager-applicationInfo.md)
- [bundleInfo](js-apis-bundleManager-bundleInfo.md)
- [dispatchInfo](js-apis-bundleManager-dispatchInfo.md)
- [elementName](js-apis-bundleManager-elementName.md)
- [extensionAbilityInfo](js-apis-bundleManager-extensionAbilityInfo.md)
- [hapModuleInfo](js-apis-bundleManager-hapModuleInfo.md)
- [launcherAbilityInfo](js-apis-bundleManager-launcherAbilityInfo.md)
- [metadata](js-apis-bundleManager-metadata.md)
- [packInfo](js-apis-bundleManager-packInfo.md)
- [permissionDef](js-apis-bundleManager-permissionDef.md)
- [remoteAbilityInfo](js-apis-bundleManager-remoteAbilityInfo.md)
- [shortcutInfo](js-apis-bundleManager-shortcutInfo.md)
- UI Page
- [@ohos.animator](js-apis-animator.md)
- [@ohos.mediaquery](js-apis-mediaquery.md)
......@@ -89,16 +159,19 @@
- [@ohos.router](js-apis-router.md)
- Graphics
- [@ohos.animation.windowAnimationManager](js-apis-windowAnimationManager.md)
- [@ohos.application.WindowExtensionAbility](js-apis-application-windowExtensionAbility.md)
- [@ohos.display ](js-apis-display.md)
- [@ohos.effectKit](js-apis-effectKit.md)
- [@ohos.graphics.colorSpaceManager](js-apis-colorSpaceManager.md)
- [@ohos.screen](js-apis-screen.md)
- [@ohos.screenshot](js-apis-screenshot.md)
- [@ohos.window](js-apis-window.md)
- [webgl](js-apis-webgl.md)
- [webgl2](js-apis-webgl2.md)
- webgl
- [webgl](js-apis-webgl.md)
- [webgl2](js-apis-webgl2.md)
- Media
- [@ohos.multimedia.audio](js-apis-audio.md)
- [@ohos.multimedia.avsession](js-apis-avsession.md)
- [@ohos.multimedia.camera](js-apis-camera.md)
- [@ohos.multimedia.image](js-apis-image.md)
- [@ohos.multimedia.media](js-apis-media.md)
......@@ -127,7 +200,6 @@
- [@ohos.data.dataSharePredicates](js-apis-data-dataSharePredicates.md)
- [@ohos.data.dataShareResultSet](js-apis-data-DataShareResultSet.md)
- [@ohos.data.distributedDataObject](js-apis-data-distributedobject.md)
- [@ohos.data.distributedKVStore](js-apis-distributedKVStore.md)
- [@ohos.data.preferences](js-apis-data-preferences.md)
- [@ohos.data.rdb](js-apis-data-rdb.md)
- [@ohos.data.ValuesBucket](js-apis-data-ValuesBucket.md)
......@@ -182,8 +254,9 @@
- [@ohos.hiSysEvent](js-apis-hisysevent.md)
- [@ohos.hiTraceChain](js-apis-hitracechain.md)
- [@ohos.hiTraceMeter](js-apis-hitracemeter.md)
- [@ohos.inputmethod](js-apis-inputmethod.md)
- [@ohos.inputmethodengine](js-apis-inputmethodengine.md)
- [@ohos.hiviewdfx.hiAppEvent](js-apis-hiviewdfx-hiappevent.md)
- [@ohos.inputMethod](js-apis-inputmethod.md)
- [@ohos.inputMethodEngine](js-apis-inputmethodengine.md)
- [@ohos.inputmethodextensionability](js-apis-inputmethod-extension-ability.md)
- [@ohos.inputmethodextensioncontext](js-apis-inputmethod-extension-context.md)
- [@ohos.pasteboard](js-apis-pasteboard.md)
......@@ -191,6 +264,7 @@
- [@ohos.systemTime](js-apis-system-time.md)
- [@ohos.systemTimer](js-apis-system-timer.md)
- [@ohos.wallpaper](js-apis-wallpaper.md)
- [@ohos.web.webview](js-apis-webview.md)
- [console](js-apis-logs.md)
- [Timer](js-apis-timer.md)
- application/[AccessibilityExtensionContext](js-apis-accessibility-extension-context.md)
......@@ -225,7 +299,7 @@
- [@ohos.account.osAccount](js-apis-osAccount.md)
- Custom Management
- [@ohos.configPolicy](js-apis-configPolicy.md)
- [@ohos.enterpriseAdminExtensionAbility](js-apis-EnterpriseAdminExtensionAbility.md)
- [@ohos.EnterpriseAdminExtensionAbility](js-apis-EnterpriseAdminExtensionAbility.md)
- Language Base Class Library
- [@ohos.buffer](js-apis-buffer.md)
- [@ohos.convertxml](js-apis-convertxml.md)
......@@ -250,15 +324,14 @@
- [@ohos.worker](js-apis-worker.md)
- [@ohos.xml](js-apis-xml.md)
- Test
- [@ohos.application.testRunner](js-apis-testRunner.md)
- [@ohos.application.testRunner](js-apis-application-testRunner.md)
- [@ohos.uitest](js-apis-uitest.md)
- APIs No Longer Maintained
- APIs No Longer Maintained
- [@ohos.backgroundTaskManager](js-apis-backgroundTaskManager.md)
- [@ohos.bundle](js-apis-Bundle.md)
- [@ohos.bundle.innerBundleManager](js-apis-Bundle-InnerBundleManager.md)
- [@ohos.bundleState](js-apis-deviceUsageStatistics.md)
- [@ohos.bytrace](js-apis-bytrace.md)
- [@ohos.commonEvent](js-apis-commonEvent.md)
- [@ohos.data.storage](js-apis-data-storage.md)
- [@ohos.data.distributedData](js-apis-distributed-data.md)
- [@ohos.distributedBundle](js-apis-Bundle-distributedBundle.md)
......@@ -268,6 +341,7 @@
- [@ohos.prompt](js-apis-prompt.md)
- [@ohos.reminderAgent](js-apis-reminderAgent.md)
- [@ohos.systemParameter](js-apis-system-parameter.md)
- [@ohos.usb](js-apis-usb-deprecated.md)
- [@ohos.workScheduler](js-apis-workScheduler.md)
- [@system.app](js-apis-system-app.md)
- [@system.battery](js-apis-system-battery.md)
......@@ -288,17 +362,17 @@
- [@system.sensor](js-apis-system-sensor.md)
- [@system.storage](js-apis-system-storage.md)
- [@system.vibrator](js-apis-system-vibrate.md)
- application/[ProcessRunningInfo](js-apis-processrunninginfo.md)
- bundle/[abilityInfo](js-apis-bundle-AbilityInfo.md)
- bundle/[applicationInfo](js-apis-bundle-ApplicationInfo.md)
- bundle/[bundleInfo](js-apis-bundle-BundleInfo.md)
- bundle/[bundleInstaller](js-apis-bundle-BundleInstaller.md)
- bundle/[bundleStatusCallback](js-apis-Bundle-BundleStatusCallback.md)
- bundle/[customizeData](js-apis-bundle-CustomizeData.md)
- bundle/[elementName](js-apis-bundle-ElementName.md)
- bundle/[hapModuleInfo](js-apis-bundle-HapModuleInfo.md)
- bundle/[launcherAbilityInfo](js-apis-bundle-LauncherAbilityInfo.md)
- bundle/[moduleInfo](js-apis-bundle-ModuleInfo.md)
- bundle/[PermissionDef](js-apis-bundle-PermissionDef.md)
- bundle/[remoteAbilityInfo](js-apis-bundle-remoteAbilityInfo.md)
- bundle/[shortcutInfo](js-apis-bundle-ShortcutInfo.md)
- bundle
- [abilityInfo](js-apis-bundle-AbilityInfo.md)
- [applicationInfo](js-apis-bundle-ApplicationInfo.md)
- [bundleInfo](js-apis-bundle-BundleInfo.md)
- [bundleInstaller](js-apis-bundle-BundleInstaller.md)
- [bundleStatusCallback](js-apis-Bundle-BundleStatusCallback.md)
- [customizeData](js-apis-bundle-CustomizeData.md)
- [elementName](js-apis-bundle-ElementName.md)
- [hapModuleInfo](js-apis-bundle-HapModuleInfo.md)
- [launcherAbilityInfo](js-apis-bundle-LauncherAbilityInfo.md)
- [moduleInfo](js-apis-bundle-ModuleInfo.md)
- [PermissionDef](js-apis-bundle-PermissionDef.md)
- [remoteAbilityInfo](js-apis-bundle-remoteAbilityInfo.md)
- [shortcutInfo](js-apis-bundle-ShortcutInfo.md)
# Ability
# @ohos.ability.ability
The **Ability** module provides all level-2 module APIs for developers to export.
......@@ -37,5 +37,3 @@ let abilityResult: ability.AbilityResult;
let connectOptions: ability.ConnectOptions;
let startAbilityParameter: ability.StartAbilityParameter;
```
<!--no_check-->
\ No newline at end of file
# DataUriUtils
# @ohos.ability.dataUriUtils
The **DataUriUtils** module provides APIs to handle utility classes for objects using the **DataAbilityHelper** schema. You can use the APIs to attach an ID to the end of a given URI and obtain, delete, or update the ID attached to the end of a given URI.
The **DataUriUtils** module provides APIs to handle utility classes for objects using the **DataAbilityHelper** schema. You can use the APIs to attach an ID to the end of a given URI and obtain, delete, or update the ID attached to the end of a given URI. This module will be replaced by the **app.ability.dataUriUtils** module in the near future. You are advised to use the **[@ohos.app.ability.dataUriUtils](js-apis-app-ability-dataUriUtils.md)** module.
> **NOTE**
>
......@@ -8,7 +8,7 @@ The **DataUriUtils** module provides APIs to handle utility classes for objects
## Modules to Import
```js
```ts
import dataUriUtils from '@ohos.ability.dataUriUtils';
```
......@@ -34,7 +34,7 @@ Obtains the ID attached to the end of a given URI.
**Example**
```js
```ts
dataUriUtils.getId("com.example.dataUriUtils/1221")
```
......@@ -63,7 +63,7 @@ Attaches an ID to the end of a given URI.
**Example**
```js
```ts
var idint = 1122;
dataUriUtils.attachId(
"com.example.dataUriUtils",
......@@ -95,12 +95,10 @@ Deletes the ID from the end of a given URI.
**Example**
```js
```ts
dataUriUtils.deleteId("com.example.dataUriUtils/1221")
```
## dataUriUtils.updateId
updateId(uri: string, id: number): string
......@@ -124,7 +122,7 @@ Updates the ID in a given URI.
**Example**
```js
```ts
var idint = 1122;
dataUriUtils.updateId(
"com.example.dataUriUtils",
......
# ErrorCode
# @ohos.ability.errorCode
The **ErrorCode** module defines the error codes that can be used when the ability is started.
The **ErrorCode** module defines the error codes that can be used when the ability is started.
**NOTE**
> **NOTE**
>
> The initial APIs of this module are supported since API version 6. Newly added APIs will be marked with a superscript to indicate their earliest API version.
## Modules to Import
```
```ts
import errorCode from '@ohos.ability.errorCode'
```
......
# FeatureAbility
# @ohos.ability.featureAbility
The **FeatureAbility** module provides a UI for interacting with users. You can use APIs of this module to start a new ability, obtain the **dataAbilityHelper**, set a Page ability, obtain the window corresponding to this ability, and connect to a Service ability.
......@@ -13,7 +13,7 @@ APIs of the **FeatureAbility** module can be called only by Page abilities.
## Modules to Import
```
```ts
import featureAbility from '@ohos.ability.featureAbility';
```
......@@ -29,12 +29,12 @@ Starts an ability. This API uses an asynchronous callback to return the result.
| Name | Type | Mandatory | Description |
| --------- | ---------------------------------------- | ---- | -------------- |
| parameter | [StartAbilityParameter](#startabilityparameter) | Yes | Ability to start.|
| parameter | [StartAbilityParameter](js-apis-inner-ability-startAbilityParameter.md) | Yes | Ability to start.|
| callback | AsyncCallback\<number> | Yes | Callback used to return the result. |
**Example**
```javascript
```ts
import featureAbility from '@ohos.ability.featureAbility';
import wantConstant from '@ohos.ability.wantConstant';
featureAbility.startAbility(
......@@ -72,11 +72,11 @@ Starts an ability. This API uses a promise to return the result.
| Name | Type | Mandatory | Description |
| --------- | ---------------------------------------- | ---- | -------------- |
| parameter | [StartAbilityParameter](#startabilityparameter) | Yes | Ability to start.|
| parameter | [StartAbilityParameter](js-apis-inner-ability-startAbilityParameter.md) | Yes | Ability to start.|
**Example**
```javascript
```ts
import featureAbility from '@ohos.ability.featureAbility';
import wantConstant from '@ohos.ability.wantConstant';
featureAbility.startAbility(
......@@ -121,7 +121,7 @@ Obtains a **dataAbilityHelper** object.
**Example**
```javascript
```ts
import featureAbility from '@ohos.ability.featureAbility';
var dataAbilityHelper = featureAbility.acquireDataAbilityHelper(
"dataability:///com.example.DataAbility"
......@@ -140,12 +140,12 @@ Starts an ability. This API uses an asynchronous callback to return the executio
| Name | Type | Mandatory | Description |
| --------- | ---------------------------------------- | ---- | -------------- |
| parameter | [StartAbilityParameter](#startabilityparameter) | Yes | Ability to start.|
| callback | AsyncCallback\<[AbilityResult](#abilityresult)> | Yes | Callback used to return the result. |
| parameter | [StartAbilityParameter](js-apis-inner-ability-startAbilityParameter.md) | Yes | Ability to start.|
| callback | AsyncCallback\<[AbilityResult](js-apis-inner-ability-abilityResult.md)> | Yes | Callback used to return the result. |
**Example**
```javascript
```ts
import featureAbility from '@ohos.ability.featureAbility';
import wantConstant from '@ohos.ability.wantConstant';
featureAbility.startAbilityForResult(
......@@ -181,17 +181,17 @@ Starts an ability. This API uses a promise to return the execution result when t
| Name | Type | Mandatory | Description |
| --------- | ---------------------------------------- | ---- | ------------- |
| parameter | [StartAbilityParameter](#startabilityparameter) | Yes | Ability to start.|
| parameter | [StartAbilityParameter](js-apis-inner-ability-startAbilityParameter.md) | Yes | Ability to start.|
**Return value**
| Type | Description |
| ---------------------------------------- | ------- |
| Promise\<[AbilityResult](#abilityresult)> | Promised returned with the execution result.|
| Promise\<[AbilityResult](js-apis-inner-ability-abilityResult.md)> | Promised returned with the execution result.|
**Example**
```javascript
```ts
import featureAbility from '@ohos.ability.featureAbility';
import wantConstant from '@ohos.ability.wantConstant';
featureAbility.startAbilityForResult(
......@@ -237,12 +237,12 @@ Destroys this Page ability, with the result code and data sent to the caller. Th
| Name | Type | Mandatory | Description |
| --------- | ------------------------------- | ---- | -------------- |
| parameter | [AbilityResult](#abilityresult) | Yes | Ability to destroy.|
| parameter | [AbilityResult](js-apis-inner-ability-abilityResult.md) | Yes | Ability to start.|
| callback | AsyncCallback\<void> | Yes | Callback used to return the result. |
**Example**
```javascript
```ts
import featureAbility from '@ohos.ability.featureAbility';
import wantConstant from '@ohos.ability.wantConstant';
featureAbility.terminateSelfWithResult(
......@@ -289,7 +289,7 @@ Destroys this Page ability, with the result code and data sent to the caller. Th
| Name | Type | Mandatory | Description |
| --------- | ------------------------------- | ---- | ------------- |
| parameter | [AbilityResult](#abilityresult) | Yes | Ability to destroy.|
| parameter | [AbilityResult](js-apis-inner-ability-abilityResult.md) | Yes | Ability to start.|
**Return value**
......@@ -299,7 +299,7 @@ Destroys this Page ability, with the result code and data sent to the caller. Th
**Example**
```javascript
```ts
import featureAbility from '@ohos.ability.featureAbility';
import wantConstant from '@ohos.ability.wantConstant';
featureAbility.terminateSelfWithResult(
......@@ -349,7 +349,7 @@ Checks whether the main window of this ability has the focus. This API uses an a
**Example**
```javascript
```ts
import featureAbility from '@ohos.ability.featureAbility';
featureAbility.hasWindowFocus((err, data) => {
console.info("hasWindowFocus err: " + JSON.stringify(err) + "data: " + JSON.stringify(data));
......@@ -372,7 +372,7 @@ Checks whether the main window of this ability has the focus. This API uses a pr
**Example**
```javascript
```ts
import featureAbility from '@ohos.ability.featureAbility';
featureAbility.hasWindowFocus().then((data) => {
console.info("hasWindowFocus data: " + JSON.stringify(data));
......@@ -391,11 +391,11 @@ Obtains the **Want** object sent from this ability. This API uses an asynchronou
| Name | Type | Mandatory | Description |
| -------- | ----------------------------- | ---- | --------- |
| callback | AsyncCallback\<[Want](js-apis-application-Want.md)> | Yes | Callback used to return the result.|
| callback | AsyncCallback\<[Want](js-apis-application-want.md)> | Yes | Callback used to return the result.|
**Example**
```javascript
```ts
import featureAbility from '@ohos.ability.featureAbility';
featureAbility.getWant((err, data) => {
console.info("getWant err: " + JSON.stringify(err) + "data: " + JSON.stringify(data));
......@@ -414,11 +414,11 @@ Obtains the **Want** object sent from this ability. This API uses a promise to r
| Type | Description |
| ----------------------- | ---------------- |
| Promise\<[Want](js-apis-application-Want.md)> | Promise used to return the result.|
| Promise\<[Want](js-apis-application-want.md)> | Promise used to return the result.|
**Example**
```javascript
```ts
import featureAbility from '@ohos.ability.featureAbility';
featureAbility.getWant().then((data) => {
console.info("getWant data: " + JSON.stringify(data));
......@@ -441,7 +441,7 @@ Obtains the application context.
**Example**
```javascript
```ts
import featureAbility from '@ohos.ability.featureAbility';
var context = featureAbility.getContext()
context.getBundleName((err, data) => {
......@@ -465,7 +465,7 @@ Destroys this Page ability, with the result code and data sent to the caller. Th
**Example**
```javascript
```ts
import featureAbility from '@ohos.ability.featureAbility';
featureAbility.terminateSelf(
(err) => {
......@@ -490,7 +490,7 @@ Destroys this Page ability, with the result code and data sent to the caller. Th
**Example**
```javascript
```ts
import featureAbility from '@ohos.ability.featureAbility';
featureAbility.terminateSelf().then((data) => {
console.info("==========================>terminateSelf=======================>");
......@@ -509,20 +509,8 @@ Connects this ability to a specific Service ability. This API uses an asynchrono
| Name | Type | Mandatory | Description |
| ------- | -------------- | ---- | --------------------- |
| request | [Want](js-apis-application-Want.md) | Yes | Service ability to connect.|
| options | [ConnectOptions](#connectoptions) | Yes | Callback used to return the result. |
## ConnectOptions
Describes the connection options.
**System capability**: SystemCapability.Ability.AbilityRuntime.Core
| Name | Readable|Writable| Type | Mandatory | Description |
| ------------ | -- | -- | -------- | ---- | ------------------------- |
| onConnect<sup>7+</sup> | Yes|No | function | Yes | Callback invoked when the connection is successful. |
| onDisconnect<sup>7+</sup> | Yes|No | function | Yes | Callback invoked when the connection fails. |
| onFailed<sup>7+</sup> | Yes|No | function | Yes | Callback invoked when **connectAbility** fails to be called.|
| request | [Want](js-apis-application-want.md) | Yes | Service ability to connect.|
| options | [ConnectOptions](js-apis-inner-ability-connectOptions.md) | Yes | Callback used to return the result. |
**Return value**
......@@ -532,7 +520,7 @@ Describes the connection options.
**Example**
```javascript
```ts
import rpc from '@ohos.rpc';
import featureAbility from '@ohos.ability.featureAbility';
function onConnectCallback(element, remote){
......@@ -575,7 +563,7 @@ Disconnects this ability from a specific Service ability. This API uses an async
**Example**
```javascript
```ts
import rpc from '@ohos.rpc';
import featureAbility from '@ohos.ability.featureAbility';
function onConnectCallback(element, remote){
......@@ -627,7 +615,7 @@ Disconnects this ability from a specific Service ability. This API uses a promis
**Example**
```javascript
```ts
import rpc from '@ohos.rpc';
import featureAbility from '@ohos.ability.featureAbility';
function onConnectCallback(element, remote){
......@@ -675,7 +663,7 @@ Obtains the window corresponding to this ability. This API uses an asynchronous
**Example**
```javascript
```ts
featureAbility.getWindow((err, data) => {
console.info("getWindow err: " + JSON.stringify(err) + "data: " + typeof(data));
});
......@@ -697,143 +685,12 @@ Obtains the window corresponding to this ability. This API uses a promise to ret
**Example**
```javascript
```ts
featureAbility.getWindow().then((data) => {
console.info("getWindow data: " + typeof(data));
});
```
## ConnectOptions.onConnect<sup>7+</sup>
onConnect(elementName: ElementName, remote: rpc.IRemoteObject): void;
Callback invoked when the connection is successful.
**System capability**: SystemCapability.Ability.AbilityRuntime.Core
**Parameters**
| Name | Type | Mandatory | Description |
| ----------- | ----------------- | ---- | -------- |
| elementName | ElementName | Yes | Element name. |
| remote | rpc.IRemoteObject | Yes | RPC remote object.|
**Example**
```javascript
import rpc from '@ohos.rpc';
import featureAbility from '@ohos.ability.featureAbility';
function onConnectCallback(element, remote){
console.log('ConnectAbility onConnect remote is proxy:' + (remote instanceof rpc.RemoteProxy));
}
function onDisconnectCallback(element){
console.log('ConnectAbility onDisconnect element.deviceId : ' + element.deviceId)
}
function onFailedCallback(code){
console.log('featureAbilityTest ConnectAbility onFailed errCode : ' + code)
}
var connectId = featureAbility.connectAbility(
{
deviceId: "",
bundleName: "com.ix.ServiceAbility",
abilityName: "ServiceAbilityA",
},
{
onConnect: onConnectCallback,
onDisconnect: onDisconnectCallback,
onFailed: onFailedCallback,
},
);
```
## ConnectOptions.onDisconnect<sup>7+</sup>
onDisconnect(elementName: ElementName): void;
Callback invoked when the connection fails.
**System capability**: SystemCapability.Ability.AbilityRuntime.Core
**Parameters**
| Name | Type | Mandatory | Description |
| ----------- | ----------- | ---- | ---- |
| elementName | ElementName | Yes | Element name.|
**Example**
```javascript
import rpc from '@ohos.rpc';
import featureAbility from '@ohos.ability.featureAbility';
function onConnectCallback(element, remote){
console.log('ConnectAbility onConnect remote is proxy:' + (remote instanceof rpc.RemoteProxy));
}
function onDisconnectCallback(element){
console.log('ConnectAbility onDisconnect element.deviceId : ' + element.deviceId)
}
function onFailedCallback(code){
console.log('featureAbilityTest ConnectAbility onFailed errCode : ' + code)
}
var connectId = featureAbility.connectAbility(
{
deviceId: "",
bundleName: "com.ix.ServiceAbility",
abilityName: "ServiceAbilityA",
},
{
onConnect: onConnectCallback,
onDisconnect: onDisconnectCallback,
onFailed: onFailedCallback,
},
);
```
## ConnectOptions.onFailed<sup>7+</sup>
onFailed(code: number): void;
Callback invoked when **connectAbility** fails to be called.
**System capability**: SystemCapability.Ability.AbilityRuntime.Core
**Parameters**
| Name | Type | Mandatory | Description |
| ---- | ------ | ---- | --------- |
| code | number | Yes | Number type.|
**Example**
```javascript
import rpc from '@ohos.rpc';
import featureAbility from '@ohos.ability.featureAbility';
function onConnectCallback(element, remote){
console.log('ConnectAbility onConnect remote is proxy:' + (remote instanceof rpc.RemoteProxy));
}
function onDisconnectCallback(element){
console.log('ConnectAbility onDisconnect element.deviceId : ' + element.deviceId)
}
function onFailedCallback(code){
console.log('featureAbilityTest ConnectAbility onFailed errCode : ' + code)
}
var connectId = featureAbility.connectAbility(
{
deviceId: "",
bundleName: "com.ix.ServiceAbility",
abilityName: "ServiceAbilityA",
},
{
onConnect: onConnectCallback,
onDisconnect: onDisconnectCallback,
onFailed: onFailedCallback,
},
);
```
## AbilityWindowConfiguration
The value is obtained through the **featureAbility.AbilityWindowConfiguration** API.
......@@ -902,26 +759,6 @@ Enumerates operation types of the Data ability.
| TYPE_DELETE<sup>7+</sup> | 3 | Deletion operation.|
| TYPE_ASSERT<sup>7+</sup> | 4 | Assert operation.|
## AbilityResult
**System capability**: SystemCapability.Ability.AbilityBase
| Name | Type | Readable| Writable | Mandatory | Description |
| --------------- |-------- | ------ | ------------- | ---- | ------------------------------------- |
| resultCode<sup>7+</sup>| number| Yes | No | Yes | Result code returned after the ability is destroyed. The feature for defining error-specific result codes is coming soon.|
| want<sup>7+</sup> | [Want](js-apis-application-Want.md)| Yes | No| No | Data returned after the ability is destroyed. You can define the data to be returned. This parameter can be **null**. |
## StartAbilityParameter
**System capability**: SystemCapability.Ability.AbilityRuntime.FAModel
| Name | Type | Readable| Writable | Mandatory | Description |
| ------------------- | -------- | -------------------- | ---- | -------------------------------------- |
| want | [Want](js-apis-application-Want.md)| Yes | No | Yes | Information about the ability to start. |
| abilityStartSetting | {[key: string]: any} | Yes |No | No | Special attribute of the ability to start. This attribute can be passed in the method call.|
## flags
**System capability**: SystemCapability.Ability.AbilityBase
......
# particleAbility
# @ohos.ability.particleAbility
The **particleAbility** module provides APIs for Service abilities. You can use the APIs to start and terminate a Particle ability, obtain a **dataAbilityHelper** object, connect the current ability to a specific Service ability, and disconnect the current ability from a specific Service ability.
......@@ -13,7 +13,7 @@ The ParticleAbility module is used to perform operations on abilities of the Dat
## Modules to Import
```js
```ts
import particleAbility from '@ohos.ability.particleAbility'
```
......@@ -27,19 +27,19 @@ Starts a Particle ability. This API uses an asynchronous callback to return the
**Parameters**
| Name | Type | Mandatory| Description |
| --------- | ----------------------------------------------- | ---- | ----------------- |
| parameter | [StartAbilityParameter](js-apis-featureAbility.md#startabilityparameter) | Yes | Ability to start.|
| parameter | [StartAbilityParameter](js-apis-inner-ability-startAbilityParameter.md) | Yes | Ability to start.|
| callback | AsyncCallback\<void> | Yes | Callback used to return the result. |
**Example**
```js
```ts
import particleAbility from '@ohos.ability.particleAbility'
import wantConstant from '@ohos.ability.wantConstant'
particleAbility.startAbility(
{
{
want:
{
action: "action.system.home",
......@@ -49,17 +49,15 @@ particleAbility.startAbility(
deviceId: "",
bundleName: "com.example.Data",
abilityName: "com.example.Data.MainAbility",
uri:""
uri: ""
},
},
(error, result) => {
console.log('particleAbility startAbility errCode:' + error + 'result:' + result)
console.log('particleAbility startAbility errCode:' + error + 'result:' + result)
},
)
```
## particleAbility.startAbility
startAbility(parameter: StartAbilityParameter): Promise\<void>;
......@@ -70,10 +68,9 @@ Starts a Particle ability. This API uses a promise to return the result.
**Parameters**
| Name | Type | Mandatory| Description |
| --------- | ----------------------------------------------- | ---- | ----------------- |
| parameter | [StartAbilityParameter](js-apis-featureAbility.md#startabilityparameter) | Yes | Ability to start.|
| parameter | [StartAbilityParameter](js-apis-inner-ability-startAbilityParameter.md) | Yes | Ability to start.|
**Return value**
......@@ -83,11 +80,12 @@ Starts a Particle ability. This API uses a promise to return the result.
**Example**
```js
```ts
import particleAbility from '@ohos.ability.particleAbility'
import wantConstant from '@ohos.ability.wantConstant'
particleAbility.startAbility(
{
{
want:
{
action: "action.system.home",
......@@ -97,7 +95,7 @@ particleAbility.startAbility(
deviceId: "",
bundleName: "com.example.Data",
abilityName: "com.example. Data.MainAbility",
uri:""
uri: ""
},
},
).then((data) => {
......@@ -105,8 +103,6 @@ particleAbility.startAbility(
});
```
## particleAbility.terminateSelf
terminateSelf(callback: AsyncCallback\<void>): void
......@@ -123,17 +119,16 @@ Terminates this Particle ability. This API uses an asynchronous callback to retu
**Example**
```js
```ts
import particleAbility from '@ohos.ability.particleAbility'
particleAbility.terminateSelf(
(error, result) => {
console.log('particleAbility terminateSelf errCode:' + error + 'result:' + result)
console.log('particleAbility terminateSelf errCode:' + error + 'result:' + result)
}
)
```
## particleAbility.terminateSelf
terminateSelf(): Promise\<void>
......@@ -150,8 +145,9 @@ Terminates this Particle ability. This API uses a promise to return the result.
**Example**
```js
```ts
import particleAbility from '@ohos.ability.particleAbility'
particleAbility.terminateSelf().then((data) => {
console.info("particleAbility terminateSelf");
});
......@@ -181,8 +177,9 @@ Obtains a **dataAbilityHelper** object.
**Example**
```js
import particleAbility from '@ohos.ability.particleAbility'
```ts
import particleAbility from '@ohos.ability.particleAbility'
var uri = "";
particleAbility.acquireDataAbilityHelper(uri)
```
......@@ -208,7 +205,7 @@ Requests a continuous task from the system. This API uses an asynchronous callba
**Example**
```js
```ts
import notification from '@ohos.notification';
import particleAbility from '@ohos.ability.particleAbility';
import wantAgent from '@ohos.wantAgent';
......@@ -277,7 +274,7 @@ Requests a continuous task from the system. This API uses a promise to return th
**Example**
```js
```ts
import notification from '@ohos.notification';
import particleAbility from '@ohos.ability.particleAbility';
import wantAgent from '@ohos.wantAgent';
......@@ -333,7 +330,7 @@ Requests to cancel a continuous task from the system. This API uses an asynchron
**Example**
```js
```ts
import particleAbility from '@ohos.ability.particleAbility';
function callback(err, data) {
......@@ -364,7 +361,7 @@ Requests a continuous task from the system. This API uses a promise to return th
**Example**
```js
```ts
import particleAbility from '@ohos.ability.particleAbility';
particleAbility.cancelBackgroundRunning().then(() => {
......@@ -375,7 +372,6 @@ particleAbility.cancelBackgroundRunning().then(() => {
```
## particleAbility.connectAbility
connectAbility(request: Want, options:ConnectOptions): number
......@@ -388,7 +384,7 @@ Connects this ability to a specific Service ability. This API uses a callback to
| Name | Type | Mandatory| Description |
| ------- | -------------- | ---- | ---------------------------- |
| request | [Want](js-apis-application-Want.md) | Yes | Service ability to connect.|
| request | [Want](js-apis-application-want.md) | Yes | Service ability to connect.|
| options | ConnectOptions | Yes | Callback used to return the result. |
......@@ -396,46 +392,48 @@ ConnectOptions
**System capability**: SystemCapability.Ability.AbilityRuntime.Core
| Name | Readable/Writable| Type | Mandatory | Description |
| ------------ | ---- | -------- | ---- | ------------------------- |
| onConnect | Read only | function | Yes | Callback invoked when the connection is successful. |
| onDisconnect | Read only | function | Yes | Callback invoked when the connection fails. |
| onFailed | Read only | function | Yes | Callback invoked when **connectAbility** fails to be called.|
| Name | Type | Mandatory | Description |
| ------------ | -------- | ---- | ------------------------- |
| onConnect | function | Yes | Callback invoked when the connection is successful. |
| onDisconnect | function | Yes | Callback invoked when the connection fails. |
| onFailed | function | Yes | Callback invoked when **connectAbility** fails to be called.|
**Example**
```js
import rpc from '@ohos.rpc'
function onConnectCallback(element, remote){
console.log('ConnectAbility onConnect remote is proxy:' + (remote instanceof rpc.RemoteProxy));
}
function onDisconnectCallback(element){
console.log('ConnectAbility onDisconnect element.deviceId : ' + element.deviceId)
}
function onFailedCallback(code){
console.log('particleAbilityTest ConnectAbility onFailed errCode : ' + code)
}
var connId = particleAbility.connectAbility(
{
bundleName: "com.ix.ServiceAbility",
abilityName: "ServiceAbilityA",
},
{
onConnect: onConnectCallback,
onDisconnect: onDisconnectCallback,
onFailed: onFailedCallback,
},
);
particleAbility.disconnectAbility(connId).then((data)=>{
console.log( " data: " + data);
}).catch((error)=>{
console.log('particleAbilityTest result errCode : ' + error.code )
});
```ts
import rpc from '@ohos.rpc'
```
function onConnectCallback(element, remote) {
console.log('ConnectAbility onConnect remote is proxy:' + (remote instanceof rpc.RemoteProxy));
}
function onDisconnectCallback(element) {
console.log('ConnectAbility onDisconnect element.deviceId : ' + element.deviceId)
}
function onFailedCallback(code) {
console.log('particleAbilityTest ConnectAbility onFailed errCode : ' + code)
}
var connId = particleAbility.connectAbility(
{
bundleName: "com.ix.ServiceAbility",
abilityName: "ServiceAbilityA",
},
{
onConnect: onConnectCallback,
onDisconnect: onDisconnectCallback,
onFailed: onFailedCallback,
},
);
particleAbility.disconnectAbility(connId).then((data) => {
console.log(" data: " + data);
}).catch((error) => {
console.log('particleAbilityTest result errCode : ' + error.code)
});
```
## particleAbility.disconnectAbility
......@@ -453,34 +451,37 @@ Disconnects this ability from the Service ability. This API uses a callback to r
**Example**
```js
```ts
import rpc from '@ohos.rpc'
function onConnectCallback(element, remote){
console.log('ConnectAbility onConnect remote is proxy:' + (remote instanceof rpc.RemoteProxy));
}
function onDisconnectCallback(element){
console.log('ConnectAbility onDisconnect element.deviceId : ' + element.deviceId)
}
function onFailedCallback(code){
console.log('particleAbilityTest ConnectAbility onFailed errCode : ' + code)
}
var connId = particleAbility.connectAbility(
{
bundleName: "com.ix.ServiceAbility",
abilityName: "ServiceAbilityA",
},
{
onConnect: onConnectCallback,
onDisconnect: onDisconnectCallback,
onFailed: onFailedCallback,
},
);
var result = particleAbility.disconnectAbility(connId).then((data)=>{
console.log( " data: " + data);
}).catch((error)=>{
console.log('particleAbilityTest result errCode : ' + error.code )
});
function onConnectCallback(element, remote) {
console.log('ConnectAbility onConnect remote is proxy:' + (remote instanceof rpc.RemoteProxy));
}
function onDisconnectCallback(element) {
console.log('ConnectAbility onDisconnect element.deviceId : ' + element.deviceId)
}
function onFailedCallback(code) {
console.log('particleAbilityTest ConnectAbility onFailed errCode : ' + code)
}
var connId = particleAbility.connectAbility(
{
bundleName: "com.ix.ServiceAbility",
abilityName: "ServiceAbilityA",
},
{
onConnect: onConnectCallback,
onDisconnect: onDisconnectCallback,
onFailed: onFailedCallback,
},
);
var result = particleAbility.disconnectAbility(connId).then((data) => {
console.log(" data: " + data);
}).catch((error) => {
console.log('particleAbilityTest result errCode : ' + error.code)
});
```
......@@ -500,34 +501,38 @@ Disconnects this ability from the Service ability. This API uses a promise to re
**Example**
```js
```ts
import rpc from '@ohos.rpc'
function onConnectCallback(element, remote){
console.log('ConnectAbility onConnect remote is proxy:' + (remote instanceof rpc.RemoteProxy));
}
function onDisconnectCallback(element){
console.log('ConnectAbility onDisconnect element.deviceId : ' + element.deviceId)
}
function onFailedCallback(code){
console.log('particleAbilityTest ConnectAbility onFailed errCode : ' + code)
}
var connId = particleAbility.connectAbility(
{
bundleName: "com.ix.ServiceAbility",
abilityName: "ServiceAbilityA",
},
{
onConnect: onConnectCallback,
onDisconnect: onDisconnectCallback,
onFailed: onFailedCallback,
},
);
particleAbility.disconnectAbility(connId).then((data)=>{
console.log( " data: " + data);
}).catch((error)=>{
console.log('particleAbilityTest result errCode : ' + error.code )
});
function onConnectCallback(element, remote) {
console.log('ConnectAbility onConnect remote is proxy:' + (remote instanceof rpc.RemoteProxy));
}
function onDisconnectCallback(element) {
console.log('ConnectAbility onDisconnect element.deviceId : ' + element.deviceId)
}
function onFailedCallback(code) {
console.log('particleAbilityTest ConnectAbility onFailed errCode : ' + code)
}
var connId = particleAbility.connectAbility(
{
bundleName: "com.ix.ServiceAbility",
abilityName: "ServiceAbilityA",
},
{
onConnect: onConnectCallback,
onDisconnect: onDisconnectCallback,
onFailed: onFailedCallback,
},
);
particleAbility.disconnectAbility(connId).then((data) => {
console.log(" data: " + data);
}).catch((error) => {
console.log('particleAbilityTest result errCode : ' + error.code)
});
```
......
# wantConstant
# @ohos.ability.wantConstant
The **wantConstant** module provides the actions, entities, and flags used in **Want** objects.
> **NOTE**
>
> The initial APIs of this module are supported since API version 6. Newly added APIs will be marked with a superscript to indicate their earliest API version.
> The APIs of this module are supported since API version 6 and deprecated since API version 9. You are advised to use [@ohos.app.ability.wantConstant](js-apis-app-ability-wantConstant.md) instead. Newly added APIs will be marked with a superscript to indicate their earliest API version.
## Modules to Import
```js
```ts
import wantConstant from '@ohos.ability.wantConstant';
```
......@@ -46,6 +46,7 @@ Enumerates the action constants of the **Want** object.
| 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. |
| 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. |
......
# @ohos.app.ability.Ability
The **Ability** module manages the ability lifecycle and context, such as creating and destroying an ability, and dumping client information.
> **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.
> The APIs of this module can be used only in the stage model.
## Modules to Import
```ts
import Ability from '@ohos.app.ability.Ability';
```
## Ability.onConfigurationUpdate
onConfigurationUpdate(newConfig: Configuration): void;
Called when the configuration of the environment where the ability is running is updated.
**System capability**: SystemCapability.Ability.AbilityRuntime.AbilityCore
**Parameters**
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| newConfig | [Configuration](js-apis-app-ability-configuration.md) | Yes| New configuration.|
**Example**
```ts
class myAbility extends Ability {
onConfigurationUpdate(config) {
console.log('onConfigurationUpdate, config:' + JSON.stringify(config));
}
}
```
## Ability.onMemoryLevel
onMemoryLevel(level: AbilityConstant.MemoryLevel): void;
Called when the system has decided to adjust the memory level. For example, this API can be used when there is not enough memory to run as many background processes as possible.
**System capability**: SystemCapability.Ability.AbilityRuntime.AbilityCore
**Parameters**
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| level | [AbilityConstant.MemoryLevel](js-apis-app-ability-abilityConstant.md#abilityconstantmemorylevel) | Yes| Memory level that indicates the memory usage status. When the specified memory level is reached, a callback will be invoked and the system will start adjustment.|
**Example**
```ts
class myAbility extends Ability {
onMemoryLevel(level) {
console.log('onMemoryLevel, level:' + JSON.stringify(level));
}
}
```
# @ohos.app.ability.AbilityConstant
The **AbilityConstant** module provides ability launch parameters.
The parameters include the initial launch reasons, reasons for the last exit, and ability continuation results.
> **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.
> The APIs of this module can be used only in the stage model.
## Modules to Import
```ts
import AbilityConstant from '@ohos.app.ability.AbilityConstant';
```
## Attributes
**System capability**: SystemCapability.Ability.AbilityRuntime.Core
| Name| Type| Readable| Writable| Description|
| -------- | -------- | -------- | -------- | -------- |
| launchReason | LaunchReason| Yes| Yes| Ability launch reason.|
| lastExitReason | LastExitReason | Yes| Yes| Reason for the last exit.|
## AbilityConstant.LaunchReason
Enumerates the ability launch reasons.
**System capability**: SystemCapability.Ability.AbilityRuntime.Core
| Name | Value | Description |
| ----------------------------- | ---- | ------------------------------------------------------------ |
| UNKNOWN | 0 | Unknown reason.|
| START_ABILITY | 1 | Ability startup.|
| CALL | 2 | Call.|
| CONTINUATION | 3 | Ability continuation.|
| APP_RECOVERY | 4 | Application recovery.|
## AbilityConstant.LastExitReason
Enumerates reasons for the last exit.
**System capability**: SystemCapability.Ability.AbilityRuntime.Core
| Name | Value | Description |
| ----------------------------- | ---- | ------------------------------------------------------------ |
| UNKNOWN | 0 | Unknown reason.|
| ABILITY_NOT_RESPONDING | 1 | The ability does not respond.|
| NORMAL | 2 | Normal status.|
## AbilityConstant.OnContinueResult
Enumerates ability continuation results.
**System capability**: SystemCapability.Ability.AbilityRuntime.Core
| Name | Value | Description |
| ----------------------------- | ---- | ------------------------------------------------------------ |
| AGREE | 0 | Continuation agreed.|
| REJECT | 1 | Continuation denied.|
| MISMATCH | 2 | Mismatch.|
## AbilityConstant.WindowMode
Enumerates the window modes in which an ability can be displayed at startup.
**System capability**: SystemCapability.Ability.AbilityRuntime.Core
| Name | Value| Description |
| --- | --- | --- |
| 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_FLOATING | 102 | The ability is displayed in a floating window.|
## AbilityConstant.MemoryLevel
Enumerates the memory levels.
**System capability**: SystemCapability.Ability.AbilityRuntime.Core
| Name | Value| Description |
| --- | --- | --- |
| MEMORY_LEVEL_MODERATE | 0 | Moderate memory usage. |
| MEMORY_LEVEL_LOW | 1 | Low memory usage. |
| MEMORY_LEVEL_CRITICAL | 2 | High memory usage. |
## AbilityConstant.OnSaveResult
Enumerates the result types for the operation of saving application data.
**System capability**: SystemCapability.Ability.AbilityRuntime.Core
| Name | Value | Description |
| ----------------------------- | ---- | ------------------------------------------------------------ |
| ALL_AGREE | 0 | Agreed to save the status.|
| CONTINUATION_REJECT | 1 | Rejected to save the status in continuation.|
| CONTINUATION_MISMATCH | 2 | Continuation mismatch.|
| RECOVERY_AGREE | 3 | Agreed to restore the saved status.|
| RECOVERY_REJECT | 4 | Rejected to restore the saved state.|
| ALL_REJECT | 5 | Rejected to save the status.|
## AbilityConstant.StateType
Enumerates the scenarios for saving application data.
**System capability**: SystemCapability.Ability.AbilityRuntime.Core
| Name | Value | Description |
| ----------------------------- | ---- | ------------------------------------------------------------ |
| CONTINUATION | 0 | Saving the status in continuation.|
| APP_RECOVERY | 1 | Saving the status in application recovery.|
# @ohos.app.ability.abilityDelegatorRegistry
The **AbilityDelegatorRegistry** module provides APIs for storing the global registers of the registered **AbilityDelegator** and **AbilityDelegatorArgs** objects. You can use the APIs to obtain the **AbilityDelegator** and **AbilityDelegatorArgs** objects of an application.
> **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.
## Modules to Import
```ts
import AbilityDelegatorRegistry from '@ohos.app.ability.abilityDelegatorRegistry'
```
## AbilityLifecycleState
Enumerates the ability lifecycle states.
**System capability**: SystemCapability.Ability.AbilityRuntime.Core
| Name | Value | Description |
| ------------- | ---- | --------------------------- |
| UNINITIALIZED | 0 | The ability is in an invalid state. |
| CREATE | 1 | The ability is created.|
| FOREGROUND | 2 | The ability is running in the foreground. |
| BACKGROUND | 3 | The ability is running in the background. |
| DESTROY | 4 | The ability is destroyed.|
## AbilityDelegatorRegistry.getAbilityDelegator
getAbilityDelegator(): AbilityDelegator
Obtains the **AbilityDelegator** object of the application.
**System capability**: SystemCapability.Ability.AbilityRuntime.Core
**Return value**
| Type | Description |
| ------------------------------------------------------------ | ------------------------------------------------------------ |
| [AbilityDelegator](js-apis-inner-application-abilityDelegator.md#AbilityDelegator) | [AbilityDelegator](js-apis-inner-application-abilityDelegator.md#AbilityDelegator) object, which can be used to schedule functions related to the test framework.|
**Example**
```ts
var abilityDelegator;
abilityDelegator = AbilityDelegatorRegistry.getAbilityDelegator();
```
## AbilityDelegatorRegistry.getArguments
getArguments(): AbilityDelegatorArgs
Obtains the **AbilityDelegatorArgs** object of the application.
**System capability**: SystemCapability.Ability.AbilityRuntime.Core
**Return value**
| Type | Description |
| ------------------------------------------------------------ | ------------------------------------------------------------ |
| [AbilityDelegatorArgs](js-apis-inner-application-abilityDelegatorArgs.md) | [AbilityDelegatorArgs](js-apis-inner-application-abilityDelegatorArgs.md) object, which can be used to obtain test parameters.|
**Example**
```ts
var args = AbilityDelegatorRegistry.getArguments();
console.info("getArguments bundleName:" + args.bundleName);
console.info("getArguments testCaseNames:" + args.testCaseNames);
console.info("getArguments testRunnerClassName:" + args.testRunnerClassName);
```
# @ohos.app.ability.abilityLifecycleCallback
The **AbilityLifecycleCallback** module provides callbacks, such as **onAbilityCreate**, **onWindowStageCreate**, and **onWindowStageDestroy**, to receive lifecycle state changes in the application context.
> **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.
> The APIs of this module can be used only in the stage model.
## Modules to Import
```ts
import AbilityLifecycleCallback from "@ohos.app.ability.AbilityLifecycleCallback";
```
## AbilityLifecycleCallback.onAbilityCreate
onAbilityCreate(ability: UIAbility): void;
Called when an ability is created.
**System capability**: SystemCapability.Ability.AbilityRuntime.AbilityCore
**Parameters**
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| ability | [UIAbility](js-apis-application-ability.md#Ability) | Yes| **Ability** object.|
## AbilityLifecycleCallback.onWindowStageCreate
onWindowStageCreate(ability: UIAbility, windowStage: window.WindowStage): void;
Called when the window stage of an ability is created.
**System capability**: SystemCapability.Ability.AbilityRuntime.AbilityCore
**Parameters**
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| ability | [UIAbility](js-apis-application-ability.md#Ability) | Yes| **Ability** object.|
| windowStage | [window.WindowStage](js-apis-window.md#windowstage9) | Yes| **WindowStage** object.|
## AbilityLifecycleCallback.onWindowStageActive
onWindowStageActive(ability: UIAbility, windowStage: window.WindowStage): void;
Called when the window stage of an ability gains focus.
**System capability**: SystemCapability.Ability.AbilityRuntime.AbilityCore
**Parameters**
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| ability | [UIAbility](js-apis-application-ability.md#Ability) | Yes| **Ability** object.|
| windowStage | [window.WindowStage](js-apis-window.md#windowstage9) | Yes| **WindowStage** object.|
## AbilityLifecycleCallback.onWindowStageInactive
onWindowStageInactive(ability: UIAbility, windowStage: window.WindowStage): void;
Called when the window stage of an ability loses focus.
**System capability**: SystemCapability.Ability.AbilityRuntime.AbilityCore
**Parameters**
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| ability | [UIAbility](js-apis-application-ability.md#Ability) | Yes| **Ability** object.|
| windowStage | [window.WindowStage](js-apis-window.md#windowstage9) | Yes| **WindowStage** object.|
## AbilityLifecycleCallback.onWindowStageDestroy
onWindowStageDestroy(ability: UIAbility, windowStage: window.WindowStage): void;
Called when the window stage of an ability is destroyed.
**System capability**: SystemCapability.Ability.AbilityRuntime.AbilityCore
**Parameters**
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| ability | [UIAbility](js-apis-application-ability.md#Ability) | Yes| **Ability** object.|
| windowStage | [window.WindowStage](js-apis-window.md#windowstage9) | Yes| **WindowStage** object.|
## AbilityLifecycleCallback.onAbilityDestroy
onAbilityDestroy(ability: UIAbility): void;
Called when an ability is destroyed.
**System capability**: SystemCapability.Ability.AbilityRuntime.AbilityCore
**Parameters**
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| ability | [UIAbility](js-apis-application-ability.md#Ability) | Yes| **Ability** object.|
## AbilityLifecycleCallback.onAbilityForeground
onAbilityForeground(ability: UIAbility): void;
Called when an ability is switched from the background to the foreground.
**System capability**: SystemCapability.Ability.AbilityRuntime.AbilityCore
**Parameters**
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| ability | [UIAbility](js-apis-application-ability.md#Ability) | Yes| **Ability** object.|
## AbilityLifecycleCallback.onAbilityBackground
onAbilityBackground(ability: UIAbility): void;
Called when an ability is switched from the foreground to the background.
**System capability**: SystemCapability.Ability.AbilityRuntime.AbilityCore
**Parameters**
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| ability | [UIAbility](js-apis-application-ability.md#Ability) | Yes| **Ability** object.|
## AbilityLifecycleCallback.onAbilityContinue
onAbilityContinue(ability: UIAbility): void;
Called when an ability is continued on another device.
**System capability**: SystemCapability.Ability.AbilityRuntime.AbilityCore
**Parameters**
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| ability | [UIAbility](js-apis-application-ability.md#Ability) | Yes| **Ability** object.|
**Example**
```ts
import UIAbility from "@ohos.app.ability.UIAbility";
export default class MyAbility extends UIAbility {
onCreate() {
console.log("MyAbility onCreate")
let AbilityLifecycleCallback = {
onAbilityCreate(ability){
console.log("AbilityLifecycleCallback onAbilityCreate ability:" + JSON.stringify(ability));
},
onWindowStageCreate(ability, windowStage){
console.log("AbilityLifecycleCallback onWindowStageCreate ability:" + JSON.stringify(ability));
console.log("AbilityLifecycleCallback onWindowStageCreate windowStage:" + JSON.stringify(windowStage));
},
onWindowStageActive(ability, windowStage){
console.log("AbilityLifecycleCallback onWindowStageActive ability:" + JSON.stringify(ability));
console.log("AbilityLifecycleCallback onWindowStageActive windowStage:" + JSON.stringify(windowStage));
},
onWindowStageInactive(ability, windowStage){
console.log("AbilityLifecycleCallback onWindowStageInactive ability:" + JSON.stringify(ability));
console.log("AbilityLifecycleCallback onWindowStageInactive windowStage:" + JSON.stringify(windowStage));
},
onWindowStageDestroy(ability, windowStage){
console.log("AbilityLifecycleCallback onWindowStageDestroy ability:" + JSON.stringify(ability));
console.log("AbilityLifecycleCallback onWindowStageDestroy windowStage:" + JSON.stringify(windowStage));
},
onAbilityDestroy(ability){
console.log("AbilityLifecycleCallback onAbilityDestroy ability:" + JSON.stringify(ability));
},
onAbilityForeground(ability){
console.log("AbilityLifecycleCallback onAbilityForeground ability:" + JSON.stringify(ability));
},
onAbilityBackground(ability){
console.log("AbilityLifecycleCallback onAbilityBackground ability:" + JSON.stringify(ability));
},
onAbilityContinue(ability){
console.log("AbilityLifecycleCallback onAbilityContinue ability:" + JSON.stringify(ability));
}
}
// 1. Obtain applicationContext through the context attribute.
let applicationContext = this.context.getApplicationContext();
// 2. Use applicationContext to register a listener for the ability lifecycle in the application.
let lifecycleid = applicationContext.on("abilityLifecycle", AbilityLifecycleCallback);
console.log("registerAbilityLifecycleCallback number: " + JSON.stringify(lifecycleid));
},
onDestroy() {
let applicationContext = this.context.getApplicationContext();
applicationContext.off("abilityLifecycle", lifecycleid, (error, data) => {
console.log("unregisterAbilityLifecycleCallback success, err: " + JSON.stringify(error));
});
}
}
```
# @ohos.app.ability.abilityManager
The **AbilityManager** module provides APIs for obtaining, adding, and modifying ability running information and state information.
> **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.
> The APIs of this module are system APIs and cannot be called by third-party applications.
## Modules to Import
```ts
import AbilityManager from '@ohos.app.ability.abilityManager'
```
## AbilityState
Enumerates the ability states.
**System capability**: SystemCapability.Ability.AbilityRuntime.Core
**System API**: This is a system API and cannot be called by third-party applications.
| Name| Value| Description|
| -------- | -------- | -------- |
| INITIAL | 0 | The ability is in the initial state.|
| FOREGROUND | 9 | The ability is in the foreground state. |
| BACKGROUND | 10 | The ability is in the background state. |
| FOREGROUNDING | 11 | The ability is in the foregrounding state. |
| BACKGROUNDING | 12 | The ability is in the backgrounding state. |
## updateConfiguration
updateConfiguration(config: Configuration, callback: AsyncCallback\<void>): void
Updates the configuration. This API uses an asynchronous callback to return the result.
**Permission required**: ohos.permission.UPDATE_CONFIGURATION
**System capability**: SystemCapability.Ability.AbilityRuntime.Core
**Parameters**
| Name | Type | Mandatory | Description |
| --------- | ---------------------------------------- | ---- | -------------- |
| config | [Configuration](js-apis-app-ability-configuration.md) | Yes | New configuration.|
| callback | AsyncCallback\<void> | Yes | Callback used to return the result. |
**Example**
```ts
import abilitymanager from '@ohos.app.ability.abilityManager';
var config = {
language: 'chinese'
}
try {
abilitymanager.updateConfiguration(config, () => {
console.log('------------ updateConfiguration -----------');
})
} catch (paramError) {
console.log('error.code: ' + JSON.stringify(paramError.code) +
' error.message: ' + JSON.stringify(paramError.message));
}
```
## updateConfiguration
updateConfiguration(config: Configuration): Promise\<void>
Updates the configuration. This API uses a promise to return the result.
**Permission required**: ohos.permission.UPDATE_CONFIGURATION
**System capability**: SystemCapability.Ability.AbilityRuntime.Core
**Parameters**
| Name | Type | Mandatory | Description |
| --------- | ---------------------------------------- | ---- | -------------- |
| config | [Configuration](js-apis-app-ability-configuration.md) | Yes | New configuration.|
**Return value**
| Type | Description |
| ---------------------------------------- | ------- |
| Promise\<void> | Promise used to return the result.|
**Example**
```ts
import abilitymanager from '@ohos.app.ability.abilityManager';
var config = {
language: 'chinese'
}
try {
abilitymanager.updateConfiguration(config).then(() => {
console.log('updateConfiguration success');
}).catch((err) => {
console.log('updateConfiguration fail');
})
} catch (paramError) {
console.log('error.code: ' + JSON.stringify(paramError.code) +
' error.message: ' + JSON.stringify(paramError.message));
}
```
## getAbilityRunningInfos
getAbilityRunningInfos(callback: AsyncCallback\<Array\<AbilityRunningInfo>>): void
Obtains the ability running information. This API uses an asynchronous callback to return the result.
**Required permissions**: ohos.permission.GET_RUNNING_INFO
**System capability**: SystemCapability.Ability.AbilityRuntime.Core
**Parameters**
| Name | Type | Mandatory | Description |
| --------- | ---------------------------------------- | ---- | -------------- |
| callback | AsyncCallback\<Array\<AbilityRunningInfo>> | Yes | Callback used to return the result. |
**Example**
```ts
import abilitymanager from '@ohos.app.ability.abilityManager';
try {
abilitymanager.getAbilityRunningInfos((err,data) => {
console.log("getAbilityRunningInfos err: " + err + " data: " + JSON.stringify(data));
});
} catch (paramError) {
console.log('error.code: ' + JSON.stringify(paramError.code) +
' error.message: ' + JSON.stringify(paramError.message));
}
```
## getAbilityRunningInfos
getAbilityRunningInfos(): Promise\<Array\<AbilityRunningInfo>>
Obtains the ability running information. This API uses a promise to return the result.
**Required permissions**: ohos.permission.GET_RUNNING_INFO
**System capability**: SystemCapability.Ability.AbilityRuntime.Core
**Return value**
| Type | Description |
| ---------------------------------------- | ------- |
| Promise\<Array\<AbilityRunningInfo>> | Promise used to return the result.|
**Example**
```ts
import abilitymanager from '@ohos.app.ability.abilityManager';
try {
abilitymanager.getAbilityRunningInfos().then((data) => {
console.log("getAbilityRunningInfos data: " + JSON.stringify(data))
}).catch((err) => {
console.log("getAbilityRunningInfos err: " + err)
});
} catch (paramError) {
console.log('error.code: ' + JSON.stringify(paramError.code) +
' error.message: ' + JSON.stringify(paramError.message));
}
```
## getExtensionRunningInfos
getExtensionRunningInfos(upperLimit: number, callback: AsyncCallback\<Array\<ExtensionRunningInfo>>): void
Obtains the extension running information. This API uses an asynchronous callback to return the result.
**Required permissions**: ohos.permission.GET_RUNNING_INFO
**System capability**: SystemCapability.Ability.AbilityRuntime.Core
**Parameters**
| Name | Type | Mandatory | Description |
| --------- | ---------------------------------------- | ---- | -------------- |
| upperLimit | number | Yes| Maximum number of messages that can be obtained.|
| callback | AsyncCallback\<Array\<AbilityRunningInfo>> | Yes | Callback used to return the result. |
**Example**
```ts
import abilitymanager from '@ohos.app.ability.abilityManager';
var upperLimit = 0;
try {
abilitymanager.getExtensionRunningInfos(upperLimit, (err,data) => {
console.log("getExtensionRunningInfos err: " + err + " data: " + JSON.stringify(data));
});
} catch (paramError) {
console.log('error.code: ' + JSON.stringify(paramError.code) +
' error.message: ' + JSON.stringify(paramError.message));
}
```
## getExtensionRunningInfos
getExtensionRunningInfos(upperLimit: number): Promise\<Array\<ExtensionRunningInfo>>
Obtains the extension running information. This API uses a promise to return the result.
**Required permissions**: ohos.permission.GET_RUNNING_INFO
**System capability**: SystemCapability.Ability.AbilityRuntime.Core
**Parameters**
| Name | Type | Mandatory | Description |
| --------- | ---------------------------------------- | ---- | -------------- |
| upperLimit | number | Yes| Maximum number of messages that can be obtained.|
**Return value**
| Type | Description |
| ---------------------------------------- | ------- |
| Promise\<Array\<AbilityRunningInfo>> | Promise used to return the result.|
**Example**
```ts
import abilitymanager from '@ohos.app.ability.abilityManager';
var upperLimit = 0;
try {
abilitymanager.getExtensionRunningInfos(upperLimit).then((data) => {
console.log("getAbilityRunningInfos data: " + JSON.stringify(data));
}).catch((err) => {
console.log("getAbilityRunningInfos err: " + err);
})
} catch (paramError) {
console.log('error.code: ' + JSON.stringify(paramError.code) +
' error.message: ' + JSON.stringify(paramError.message));
}
```
## getTopAbility<sup>9+</sup>
getTopAbility(callback: AsyncCallback\<ElementName>): void;
Obtains the top ability, which is the ability that has the window focus. This API uses an asynchronous callback to return the result.
**System capability**: SystemCapability.Ability.AbilityRuntime.Core
**Parameters**
| Name | Type | Mandatory | Description |
| --------- | ---------------------------------------- | ---- | -------------- |
| callback | AsyncCallback\<ElementName> | Yes | Callback used to return the result. |
**Example**
```ts
import abilitymanager from '@ohos.app.ability.abilityManager';
try {
abilitymanager.getTopAbility((err,data) => {
console.log("getTopAbility err: " + err + " data: " + JSON.stringify(data));
});
} catch (paramError) {
console.log('error.code: ' + JSON.stringify(paramError.code) +
' error.message: ' + JSON.stringify(paramError.message));
}
```
## getTopAbility
getTopAbility(): Promise\<ElementName>;
Obtains the top ability, which is the ability that has the window focus. This API uses a promise to return the result.
**System capability**: SystemCapability.Ability.AbilityRuntime.Core
**Return value**
| Type | Description |
| ---------------------------------------- | ------- |
| Promise\<ElementName>| Promise used to return the result.|
**Example**
```ts
import abilitymanager from '@ohos.app.ability.abilityManager';
try {
abilitymanager.getTopAbility().then((data) => {
console.log("getTopAbility data: " + JSON.stringify(data));
}).catch((err) => {
console.log("getTopAbility err: " + err);
})
} catch (paramError) {
console.log('error.code: ' + JSON.stringify(paramError.code) +
' error.message: ' + JSON.stringify(paramError.message));
}
```
# @ohos.app.ability.AbilityStage
**AbilityStage** is a runtime class for HAP files.
**AbilityStage** notifies you of when you can perform HAP initialization such as resource pre-loading and thread creation during the HAP loading.
> **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.
> The APIs of this module can be used only in the stage model.
## Modules to Import
```ts
import AbilityStage from '@ohos.app.ability.AbilityStage';
```
## AbilityStage.onCreate
onCreate(): void
Called when the application is created.
**System capability**: SystemCapability.Ability.AbilityRuntime.Core
**Example**
```ts
class MyAbilityStage extends AbilityStage {
onCreate() {
console.log("MyAbilityStage.onCreate is called")
}
}
```
## AbilityStage.onAcceptWant
onAcceptWant(want: Want): string;
Called when a specified ability is started.
**System capability**: SystemCapability.Ability.AbilityRuntime.Core
**Parameters**
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| want | [Want](js-apis-app-ability-want.md) | Yes| Information about the ability to start, such as the ability name and bundle name.|
**Return value**
| Type| Description|
| -------- | -------- |
| string | Returns an ability ID. If this ability has been started, no new instance is created and the ability is placed at the top of the stack. Otherwise, a new instance is created and started.|
**Example**
```ts
class MyAbilityStage extends AbilityStage {
onAcceptWant(want) {
console.log("MyAbilityStage.onAcceptWant called");
return "com.example.test";
}
}
```
## AbilityStage.onConfigurationUpdate
onConfigurationUpdate(newConfig: Configuration): void;
Called when the global configuration is updated.
**System capability**: SystemCapability.Ability.AbilityRuntime.Core
**Parameters**
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| newConfig | [Configuration](js-apis-app-ability-configuration.md) | Yes| Callback invoked when the global configuration is updated. The global configuration indicates the configuration of the environment where the application is running and includes the language and color mode.|
**Example**
```ts
class MyAbilityStage extends AbilityStage {
onConfigurationUpdate(config) {
console.log('onConfigurationUpdate, language:' + config.language);
}
}
```
## AbilityStage.onMemoryLevel
onMemoryLevel(level: AbilityConstant.MemoryLevel): void;
Called when the system has decided to adjust the memory level. For example, this API can be used when there is not enough memory to run as many background processes as possible.
**System capability**: SystemCapability.Ability.AbilityRuntime.Core
**Parameters**
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| level | [AbilityConstant.MemoryLevel](js-apis-app-ability-abilityConstant.md#abilityconstantmemorylevel) | Yes| Memory level that indicates the memory usage status. When the specified memory level is reached, a callback will be invoked and the system will start adjustment.|
**Example**
```ts
class MyAbilityStage extends AbilityStage {
onMemoryLevel(level) {
console.log('onMemoryLevel, level:' + JSON.stringify(level));
}
}
```
## AbilityStage.context
context: AbilityStageContext;
Describes the configuration information about the context.
**System capability**: SystemCapability.Ability.AbilityRuntime.Core
| Name | Type | Description |
| ----------- | --------------------------- | ------------------------------------------------------------ |
| context | [AbilityStageContext](js-apis-inner-application-abilityStageContext.md) | Called when initialization is performed during ability startup.|
# @ohos.app.ability.appRecovery
The **appRecovery** module provides APIs for recovering faulty applications.
> **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. In the current version, only applications with a single ability in a single process can be recovered.
## Modules to Import
```ts
import appRecovery from '@ohos.app.ability.appRecovery'
```
## appRecovery.RestartFlag
Enumerates the application restart options used in [enableAppRecovery](#apprecoveryenableapprecovery).
**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.|
## appRecovery.SaveOccasionFlag
Enumerates the scenarios for saving the application state, which is used in [enableAppRecovery](#apprecoveryenableapprecovery).
**System capability**: SystemCapability.Ability.AbilityRuntime.Core
| Name | Value | Description |
| ----------------------------- | ---- | ------------------------------------------------------------ |
| SAVE_WHEN_ERROR | 0x0001 | Saving the application state when an application fault occurs.|
| SAVE_WHEN_BACKGROUND | 0x0002 | Saving the application state when the application is switched to the background.|
## appRecovery.SaveModeFlag
Enumerates the application state saving modes used in [enableAppRecovery](#apprecoveryenableapprecovery).
**System capability**: SystemCapability.Ability.AbilityRuntime.Core
| Name | Value | Description |
| ----------------------------- | ---- | ------------------------------------------------------------ |
| SAVE_WITH_FILE | 0x0001 | The application state is saved and written to the local file cache.|
| SAVE_WITH_SHARED_MEMORY | 0x0002 | The application state is saved in the memory. When the application exits due to a fault, it is written to the local file cache.|
## appRecovery.enableAppRecovery
enableAppRecovery(restart?: RestartFlag, saveOccasion?: SaveOccasionFlag, saveMode?: SaveModeFlag) : void;
Enables application recovery.
**System capability**: SystemCapability.Ability.AbilityRuntime.Core
**Parameters**
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| restart | [RestartFlag](#apprecoveryrestartflag) | No| Whether the application is restarted upon a fault. By default, the application is not restarted.|
| saveOccasion | [SaveOccasionFlag](#apprecoverysaveoccasionflag) | No| Scenario for saving the application state. By default, the state is saved when a fault occurs.|
| saveMode | [SaveModeFlag](#apprecoverysavemodeflag) | No| Application state saving mode. By default, the application state is written to the local file cache.|
**Example**
```ts
export default class MyAbilityStage extends AbilityStage {
onCreate() {
appRecovery.enableAppRecovery(RestartFlag::ALWAYS_RESTART, SaveOccasionFlag::SAVE_WHEN_ERROR, SaveModeFlag::SAVE_WITH_FILE);
}
}
```
## appRecovery.restartApp
restartApp(): void;
Restarts the application. This API can be used together with APIs of [errorManager](js-apis-app-ability-errorManager.md).
**System capability**: SystemCapability.Ability.AbilityRuntime.Core
**Example**
```ts
var observer = {
onUnhandledException(errorMsg) {
console.log('onUnhandledException, errorMsg: ', errorMsg)
appRecovery.restartApp();
}
}
```
## appRecovery.saveAppState
saveAppState(): boolean;
Saves the application state. This API can be used together with APIs of [errorManager](js-apis-app-ability-errorManager.md).
**System capability**: SystemCapability.Ability.AbilityRuntime.Core
**Return value**
| Type| Description|
| -------- | -------- |
| boolean | Whether the saving is successful.|
**Example**
```ts
var observer = {
onUnhandledException(errorMsg) {
console.log('onUnhandledException, errorMsg: ', errorMsg)
appRecovery.saveAppState();
}
}
```
# @ohos.app.ability.common
The **Common** module provides all level-2 module APIs for developers to export.
> **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.
> The APIs of this module can be used only in the stage model.
## Modules to Import
```ts
import common from '@ohos.app.ability.common'
```
**System capability**: SystemCapability.Ability.AbilityBase
| Name | Type | Mandatory| Description |
| ----------- | -------------------- | ---- | ------------------------------------------------------------ |
| UIAbilityContext | [UIAbilityContext](js-apis-inner-application-uiAbilityContext.md) | No | Level-2 module **UIAbilityContext**. |
| AbilityStageContext | [AbilityStageContext](js-apis-inner-application-abilityStageContext.md) | No | Level-2 module **AbilityStageContext**.|
| ApplicationContext | [ApplicationContext](js-apis-inner-application-applicationContext.md) | No | Level-2 module **ApplicationContext**.|
| BaseContext | [BaseContext](js-apis-inner-application-baseContext.md) | No | Level-2 module **BaseContext**.|
| Context | [Context](js-apis-inner-application-context.md) | No | Level-2 module **Context**.|
| ExtensionContext | [ExtensionContext](js-apis-inner-application-extensionContext.md) | No | Level-2 module **ExtensionContext**.|
| FormExtensionContext | [FormExtensionContext](js-apis-inner-application-formExtensionContext.md) | No | Level-2 module **FormExtensionContext**.|
| AreaMode | [AreaMode](#areamode) | No | Enumerated values of **AreaMode**.|
| EventHub | [EventHub](js-apis-inner-application-eventHub.md) | No | Level-2 module **EventHub**.|
| PermissionRequestResult | [PermissionRequestResult](js-apis-inner-application-permissionRequestResult.md) | No | Level-2 module **PermissionRequestResult**.|
| PacMap | [PacMap](js-apis-inner-ability-dataAbilityHelper.md#PacMap) | No | Level-2 module **PacMap**.|
| AbilityResult | [AbilityResult](js-apis-inner-ability-abilityResult.md) | No | Level-2 module **AbilityResult**.|
| ConnectOptions | [ConnectOptions](js-apis-inner-ability-connectOptions.md) | No | Level-2 module **ConnectOptions**.|
**Example**
```ts
import common from '@ohos.app.ability.common'
let uiAbilityContext: common.UIAbilityContext;
let abilityStageContext: common.AbilityStageContext;
let applicationContext: common.ApplicationContext;
let baseContext: common.BaseContext;
let context: common.Context;
let extensionContext: common.ExtensionContext;
let formExtensionContext: common.FormExtensionContext;
let areaMode: common.AreaMode;
let eventHub: common.EventHub;
let permissionRequestResult: common.PermissionRequestResult;
let pacMap: common.PacMap;
let abilityResult: common.AbilityResult;
let connectOptions: common.ConnectOptions;
```
## AreaMode
Defines the area where the file to be access is located. Each area has its own content.
**System capability**: SystemCapability.Ability.AbilityRuntime.Core
| Name | Value | Description |
| --------------- | ---- | --------------- |
| EL1 | 0 | Device-level encryption area. |
| EL2 | 1 | User credential encryption area. The default value is **EL2**.|
# @ohos.app.ability.Configuration
The **Configuration** module defines environment change information.
> **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.
## Modules to Import
```ts
import Configuration from '@ohos.app.ability.Configuration'
```
**System capability**: SystemCapability.Ability.AbilityBase
| Name| Type| Readable| Writable| Description|
| -------- | -------- | -------- | -------- | -------- |
| language | string | Yes| Yes| Language of the application.|
| colorMode | [ColorMode](js-apis-app-ability-configurationConstant.md#configurationconstantcolormode) | Yes| Yes| Color mode, which can be **COLOR_MODE_LIGHT** or **COLOR_MODE_DARK**. The default value is **COLOR_MODE_LIGHT**.|
| direction | Direction | Yes| No| Screen orientation, which can be **DIRECTION_HORIZONTAL** or **DIRECTION_VERTICAL**.|
| screenDensity | 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 | number | Yes| No| ID of the display where the application is located.|
| hasPointerDevice | boolean | Yes| No| Whether a pointer device, such as a keyboard, mouse, or touchpad, is connected.|
For details about the fields, see the **ohos.app.ability.Configuration.d.ts** file.
**Example**
```ts
let envCallback = {
onConfigurationUpdated(config) {
console.info(`envCallback onConfigurationUpdated success: ${JSON.stringify(config)}`)
let language = config.language;
let colorMode = config.colorMode;
let direction = config.direction;
let screenDensity = config.screenDensity;
let displayId = config.displayId;
let hasPointerDevice = config.hasPointerDevice;
}
};
try {
var callbackId = applicationContext.on("environment", envCallback);
} catch (paramError) {
console.log("error: " + paramError.code + ", " + paramError.message);
}
```
# ConfigurationConstant
# @ohos.app.ability.ConfigurationConstant
The **ConfigurationConstant** module provides the enumerated values of the 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.
> 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.
## Modules to Import
```js
import ConfigurationConstant from '@ohos.application.ConfigurationConstant';
```ts
import ConfigurationConstant from '@ohos.app.ability.ConfigurationConstant';
```
## ConfigurationConstant.ColorMode
You can obtain the value of this constant by calling the **ConfigurationConstant.ColorMode** API.
**Example**
```
ConfigurationConstant.ColorMode.COLOR_MODE_LIGHT
```
**System capability**: SystemCapability.Ability.AbilityBase
| Name| Value| Description|
......@@ -36,12 +29,6 @@ ConfigurationConstant.ColorMode.COLOR_MODE_LIGHT
You can obtain the value of this constant by calling the **ConfigurationConstant.Direction** API.
**Example**
```
ConfigurationConstant.Direction.DIRECTION_VERTICAL
```
**System capability**: SystemCapability.Ability.AbilityBase
| Name| Value| Description|
......@@ -55,12 +42,6 @@ ConfigurationConstant.Direction.DIRECTION_VERTICAL
You can obtain the value of this constant by calling the **ConfigurationConstant.ScreenDensity** API.
**Example**
```
ConfigurationConstant.ScreenDensity.SCREEN_DENSITY_NOT_SET
```
**System capability**: SystemCapability.Ability.AbilityBase
| Name| Value| Description|
......
# @ohos.app.ability.contextConstant
The **ContextConstant** module defines data encryption levels.
> **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.
> The APIs of this module can be used only in the stage model.
## Modules to Import
```ts
import contextConstant from '@ohos.app.ability.contextConstant';
```
## ContextConstant.AreaMode
You can obtain the value of this constant by calling the **ContextConstant.AreaMode** API.
**System capability**: SystemCapability.Ability.AbilityRuntime.Core
| Name| Value| Description|
| -------- | -------- | -------- |
| EL1 | 0 | Device-level encryption area.|
| EL2 | 1 | User credential encryption area.|
# ohos.app.ability.dataUriUtils
The **DataUriUtils** module provides APIs to handle utility classes for objects using the **DataAbilityHelper** schema. You can use the APIs to attach an ID to the end of a given URI and obtain, delete, or update the ID attached to the end of a given URI.
> **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.
## Modules to Import
```ts
import dataUriUtils from '@ohos.app.ability.dataUriUtils';
```
## dataUriUtils.getId
getId(uri: string): number
Obtains the ID attached to the end of a given URI.
**System capability**: SystemCapability.Ability.AbilityRuntime.Core
**Parameters**
| Name| Type | Mandatory| Description |
| ---- | ------ | ---- | --------------------------- |
| uri | string | Yes | URI object from which the ID is to be obtained.|
**Return value**
| Type | Description |
| ------ | ------------------------ |
| number | ID obtained from the URI object.|
**Example**
```ts
try {
var id = dataUriUtils.getId("com.example.dataUriUtils/1221")
console.info('get id: ' + id)
} catch(err) {
console.error('get id err ,check the uri' + err)
}
```
## dataUriUtils.attachId
attachId(uri: string, id: number): string
Attaches an ID to the end of a given URI. It can be used to generate a new URI.
**System capability**: SystemCapability.Ability.AbilityRuntime.Core
**Parameters**
| Name| Type | Mandatory| Description |
| ---- | ------ | ---- | --------------------------- |
| uri | string | Yes | URI object to which an ID is to be attached.|
| id | number | Yes | ID to be attached. |
**Return value**
| Type | Description |
| ------ | --------------------- |
| string | URI object with the ID attached.|
**Example**
```ts
var idint = 1122;
try {
var uri = dataUriUtils.attachId(
"com.example.dataUriUtils",
idint,
)
console.info('attachId the uri is: ' + uri)
} catch (err) {
console.error('get id err ,check the uri' + err)
}
```
## dataUriUtils.deleteId
deleteId(uri: string): string
Deletes the ID from the end of a given URI.
**System capability**: SystemCapability.Ability.AbilityRuntime.Core
**Parameters**
| Name| Type | Mandatory| Description |
| ---- | ------ | ---- | --------------------------- |
| uri | string | Yes | URI object from which the ID is to be deleted.|
**Return value**
| Type | Description |
| ------ | ------------------- |
| string | URI object with the ID deleted.|
**Example**
```ts
try {
var uri = dataUriUtils.deleteId("com.example.dataUriUtils/1221")
console.info('delete id with the uri is: ' + uri)
} catch(err) {
console.error('delete uri err, check the input uri' + err)
}
```
## dataUriUtils.updateId
updateId(uri: string, id: number): string
Updates the ID in a given URI.
**System capability**: SystemCapability.Ability.AbilityRuntime.Core
**Parameters**
| Name| Type | Mandatory| Description |
| ---- | ------ | ---- | ------------------- |
| uri | string | Yes | URI object to be updated.|
| id | number | Yes | New ID. |
**Return value**
| Type | Description |
| ------ | --------------- |
| string | URI object with the new ID.|
**Example**
```ts
try {
var idint = 1122;
var uri = dataUriUtils.updateId(
"com.example.dataUriUtils",
idint
)
} catch (err) {
console.error('delete uri err, check the input uri' + err)
}
```
# EnvironmentCallback
# @ohos.app.ability.EnvironmentCallback
The **EnvironmentCallback** module provides the **onConfigurationUpdated** API for the application context to listen for system environment changes.
......@@ -10,8 +10,8 @@ The **EnvironmentCallback** module provides the **onConfigurationUpdated** API f
## Modules to Import
```js
import EnvironmentCallback from "@ohos.application.EnvironmentCallback";
```ts
import EnvironmentCallback from "@ohos.app.ability.EnvironmentCallback";
```
......@@ -27,19 +27,19 @@ Called when the system environment changes.
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| config | [Configuration](js-apis-configuration.md) | Yes| **Configuration** object after the change.|
| config | [Configuration](js-apis-app-ability-configuration.md) | Yes| **Configuration** object after the change.|
**Example**
```js
import AbilityStage from "@ohos.application.AbilityStage";
```ts
import Ability from "@ohos.application.Ability";
var callbackId;
export default class MyAbilityStage extends AbilityStage {
export default class MyAbility extends Ability {
onCreate() {
console.log("MyAbilityStage onCreate")
console.log("MyAbility onCreate")
globalThis.applicationContext = this.context.getApplicationContext();
let EnvironmentCallback = {
onConfigurationUpdated(config){
......
# @ohos.app.ability.errorManager
The **ErrorManager** module provides APIs for registering and deregistering error observers.
> **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.
## Modules to Import
```
import errorManager from '@ohos.app.ability.errorManager'
```
## ErrorManager.on
on(type: "error", observer: ErrorObserver): number;
Registers an error observer.
**System capability**: SystemCapability.Ability.AbilityRuntime.Core
**Parameters**
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| type | string | Yes| Type of the API to call.|
| observer | [ErrorObserver](./js-apis-inner-application-errorObserver.md) | Yes| Numeric code of the observer.|
**Example**
```js
var observer = {
onUnhandledException(errorMsg) {
console.log('onUnhandledException, errorMsg: ', errorMsg)
}
}
try {
errorManager.on("error", observer);
} catch (paramError) {
console.log("error: " + paramError.code + ", " + paramError.message);
}
```
## ErrorManager.off
off(type: "error", observerId: number, callback: AsyncCallback\<void>): void;
Deregisters an error observer. This API uses an asynchronous callback to return the result.
**System capability**: SystemCapability.Ability.AbilityRuntime.Core
**Parameters**
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| type | string | Yes| Type of the API to call.|
| observerId | number | Yes| Numeric code of the observer.|
| callback | AsyncCallback\<void> | Yes| Callback used to return the result.|
**Example**
```js
var observerId = 100;
function unregisterErrorObserverCallback(err) {
if (err) {
console.log('------------ unregisterErrorObserverCallback ------------', err);
}
}
try {
errorManager.off("error", observerId, unregisterErrorObserverCallback);
} catch (paramError) {
console.log("error: " + paramError.code + ", " + paramError.message);
}
```
## ErrorManager.off
off(type: "error", observerId: number): Promise\<void>;
Deregisters an error observer. This API uses a promise to return the result.
**System capability**: SystemCapability.Ability.AbilityRuntime.Core
**Parameters**
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| type | string | Yes| Type of the API to call.|
| observerId | number | Yes| Numeric code of the observer.|
**Return value**
| Type| Description|
| -------- | -------- |
| Promise\<void> | Promise used to return the result.|
**Example**
```js
var observerId = 100;
try {
errorManager.off("error", observerId)
.then((data) => {
console.log('----------- unregisterErrorObserver success ----------', data);
})
.catch((err) => {
console.log('----------- unregisterErrorObserver fail ----------', err);
})
} catch (paramError) {
console.log("error: " + paramError.code + ", " + paramError.message);
}
```
# @ohos.app.ability.ExtensionAbility
The **ExtensionAbility** module manages the Extension ability lifecycle and context, such as creating and destroying an Extension ability, and dumping client information.
> **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.
> The APIs of this module can be used only in the stage model.
## Modules to Import
```ts
import ExtensionAbility from '@ohos.app.ability.ExtensionAbility';
```
**System capability**: SystemCapability.Ability.AbilityRuntime.AbilityCore
**Example**
```ts
class MyExtensionAbility extends ExtensionAbility {
onConfigurationUpdated(config) {
console.log('onConfigurationUpdated, config:' + JSON.stringify(config));
}
onMemoryLevel(level) {
console.log('onMemoryLevel, level:' + JSON.stringify(level));
}
}
```
# quickFixManager
# @ohos.app.ability.quickFixManager
The **quickFixManager** module provides APIs for quick fix. With quick fix, you can fix bugs in your application by applying patches, which is more efficient than by updating the entire application.
......@@ -8,8 +8,8 @@ The **quickFixManager** module provides APIs for quick fix. With quick fix, you
## Modules to Import
```
import quickFixManager from '@ohos.application.quickFixManager';
```ts
import quickFixManager from '@ohos.app.ability.quickFixManager';
```
## HapModuleQuickFixInfo
......@@ -20,11 +20,11 @@ Defines the quick fix information at the HAP file level.
**System API**: This is a system API and cannot be called by third-party applications.
| Name | Readable/Writable| Type | Mandatory| Description |
| ----------- | -------- | -------------------- | ---- | ------------------------------------------------------------ |
| moduleName | Read only | string | Yes | Name of the HAP file. |
| originHapHash | Read only | string | Yes | Hash value of the HAP file. |
| quickFixFilePath | Read only | string | Yes | Installation path of the quick fix file. |
| Name | Type | Mandatory| Description |
| ----------- | -------------------- | ---- | ------------------------------------------------------------ |
| moduleName | string | Yes | Name of the HAP file. |
| originHapHash | string | Yes | Hash value of the HAP file. |
| quickFixFilePath | string | Yes | Installation path of the quick fix file. |
## ApplicationQuickFixInfo
......@@ -34,14 +34,14 @@ Defines the quick fix information at the application level.
**System API**: This is a system API and cannot be called by third-party applications.
| Name | Readable/Writable| Type | Mandatory| Description |
| ----------- | -------- | -------------------- | ---- | ------------------------------------------------------------ |
| bundleName | Read only | string | Yes | Bundle name of the application. |
| bundleVersionCode | Read only | number | Yes | Internal version number of the application. |
| bundleVersionName | Read only | string | Yes | Version number of the application that is shown to users. |
| quickFixVersionCode | Read only | number | Yes | Version code of the quick fix patch package. |
| quickFixVersionName | Read only | string | Yes | Text description of the version number of the quick fix patch package. |
| hapModuleQuickFixInfo | Read only | Array\<[HapModuleQuickFixInfo](#hapmodulequickfixinfo)> | Yes | Quick fix information at the HAP file level. |
| Name | Type | Mandatory| Description |
| ----------- | -------------------- | ---- | ------------------------------------------------------------ |
| bundleName | string | Yes | Bundle name of the application. |
| bundleVersionCode | number | Yes | Internal version number of the application. |
| bundleVersionName | string | Yes | Version number of the application that is shown to users. |
| quickFixVersionCode | number | Yes | Version code of the quick fix patch package. |
| quickFixVersionName | string | Yes | Text description of the version number of the quick fix patch package. |
| hapModuleQuickFixInfo | Array\<[HapModuleQuickFixInfo](#hapmodulequickfixinfo)> | Yes | Quick fix information at the HAP file level. |
## quickFixManager.applyQuickFix
......@@ -59,22 +59,26 @@ Applies a quick fix patch. This API uses an asynchronous callback to return the
| Parameter| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| hapModuleQuickFixFiles | Array\<string> | No| Quick fix files, each of which must contain a valid file path.|
| callback | AsyncCallback\<void> | No| Callback used to return the result.|
| hapModuleQuickFixFiles | Array\<string> | Yes| Quick fix files, each of which must contain a valid file path.|
| callback | AsyncCallback\<void> | Yes| Callback used to return the result.|
**Example**
```js
import quickFixManager from '@ohos.application.quickFixManager'
```ts
import quickFixManager from '@ohos.app.ability.quickFixManager'
let hapModuleQuickFixFiles = ["/data/storage/el2/base/entry.hqf"]
quickFixManager.applyQuickFix(hapModuleQuickFixFiles, (error) => {
try {
let hapModuleQuickFixFiles = ["/data/storage/el2/base/entry.hqf"]
quickFixManager.applyQuickFix(hapModuleQuickFixFiles, (error) => {
if (error) {
console.info( `applyQuickFix failed with error + ${error}`)
} else {
console.info( 'applyQuickFix success')
}
})
})
} catch (paramError) {
console.log("error: " + paramError.code + ", " + paramError.message);
}
```
## quickFixManager.applyQuickFix
......@@ -93,7 +97,7 @@ Applies a quick fix patch. This API uses a promise to return the result.
| Parameter| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| hapModuleQuickFixFiles | Array\<string> | No| Quick fix files, each of which must contain a valid file path.|
| hapModuleQuickFixFiles | Array\<string> | Yes| Quick fix files, each of which must contain a valid file path.|
**Return value**
......@@ -103,15 +107,19 @@ Applies a quick fix patch. This API uses a promise to return the result.
**Example**
```js
import quickFixManager from '@ohos.application.quickFixManager'
```ts
import quickFixManager from '@ohos.app.ability.quickFixManager'
let hapModuleQuickFixFiles = ["/data/storage/el2/base/entry.hqf"]
quickFixManager.applyQuickFix(hapModuleQuickFixFiles).then(() => {
console.info('applyQuickFix success')
}).catch((error) => {
console.info(`applyQuickFix err: + ${error}`)
})
try {
quickFixManager.applyQuickFix(hapModuleQuickFixFiles).then(() => {
console.info('applyQuickFix success')
}).catch((error) => {
console.info(`applyQuickFix err: + ${error}`)
})
} catch (paramError) {
console.log("error: " + paramError.code + ", " + paramError.message);
}
```
## quickFixManager.getApplicationQuickFixInfo
......@@ -130,22 +138,26 @@ Obtains the quick fix information of the application. This API uses an asynchron
| Parameter| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| bundleName | string | No|Bundle name of the application. |
| callback | AsyncCallback\<[ApplicationQuickFixInfo](#applicationquickfixinfo)> | No| Callback used to return the quick fix information.|
| bundleName | string | Yes|Bundle name of the application. |
| callback | AsyncCallback\<[ApplicationQuickFixInfo](#applicationquickfixinfo)> | Yes| Callback used to return the quick fix information.|
**Example**
```js
import quickFixManager from '@ohos.application.quickFixManager'
let bundleName = "bundleName"
quickFixManager.getApplicationQuickFixInfo(bundleName, (error, data) => {
if (error) {
console.info(`getApplicationQuickFixInfo error: + ${error}`)
} else {
console.info(`getApplicationQuickFixInfo success: + ${data}`)
}
})
```ts
import quickFixManager from '@ohos.app.ability.quickFixManager'
try {
let bundleName = "bundleName"
quickFixManager.getApplicationQuickFixInfo(bundleName, (error, data) => {
if (error) {
console.info(`getApplicationQuickFixInfo error: + ${error}`)
} else {
console.info(`getApplicationQuickFixInfo success: + ${data}`)
}
})
} catch (paramError) {
console.log("error: " + paramError.code + ", " + paramError.message);
}
```
## quickFixManager.getApplicationQuickFixInfo
......@@ -164,7 +176,7 @@ Obtains the quick fix information of the application. This API uses a promise to
| Parameter| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| bundleName | string | No| Bundle name of the application. |
| bundleName | string | Yes| Bundle name of the application. |
**Return value**
......@@ -174,13 +186,17 @@ Obtains the quick fix information of the application. This API uses a promise to
**Example**
```js
import quickFixManager from '@ohos.application.quickFixManager'
let bundleName = "bundleName"
quickFixManager.getApplicationQuickFixInfo(bundleName).then((data) => {
console.info(`getApplicationQuickFixInfo success: + ${data}`)
}).catch((error) => {
console.info(`getApplicationQuickFixInfo err: + ${error}`)
})
```ts
import quickFixManager from '@ohos.app.ability.quickFixManager'
try {
let bundleName = "bundleName"
quickFixManager.getApplicationQuickFixInfo(bundleName).then((data) => {
console.info(`getApplicationQuickFixInfo success: + ${data}`)
}).catch((error) => {
console.info(`getApplicationQuickFixInfo err: + ${error}`)
})
} catch (paramError) {
console.log("error: " + paramError.code + ", " + paramError.message);
}
```
# @ohos.app.ability.ServiceExtensionAbility
The **ServiceExtensionAbility** module provides APIs for Service Extension abilities.
> **NOTE**
>
> The APIs of this module are supported and deprecated since API version 9. You are advised to use [@ohos.app.ability.ServiceExtensionAbility](js-apis-app-ability-serviceExtensionAbility.md) instead. Newly added APIs will be marked with a superscript to indicate their earliest API version.
> The APIs of this module can be used only in the stage model.
## Modules to Import
```ts
import ServiceExtension from '@ohos.app.ability.ServiceExtensionAbility';
```
## Required Permissions
None.
## Attributes
**System capability**: SystemCapability.Ability.AbilityRuntime.Core
**System API**: This is a system API and cannot be called by third-party applications.
| Name| Type| Readable| Writable| Description|
| -------- | -------- | -------- | -------- | -------- |
| context | [ServiceExtensionContext](js-apis-inner-application-serviceExtensionContext.md) | Yes| No| Service Extension context, which is inherited from **ExtensionContext**.|
## ServiceExtensionAbility.onCreate
onCreate(want: Want): void;
Called when a Service Extension ability is created to initialize the service logic.
**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|
| -------- | -------- | -------- | -------- |
| want | [Want](js-apis-app-ability-want.md) | Yes| Want information related to this Service Extension ability, including the ability name and bundle name.|
**Example**
```ts
class ServiceExt extends ServiceExtension {
onCreate(want) {
console.log('onCreate, want:' + want.abilityName);
}
}
```
## ServiceExtensionAbility.onDestroy
onDestroy(): void;
Called when this Service Extension ability is destroyed to clear resources.
**System capability**: SystemCapability.Ability.AbilityRuntime.Core
**System API**: This is a system API and cannot be called by third-party applications.
**Example**
```ts
class ServiceExt extends ServiceExtension {
onDestroy() {
console.log('onDestroy');
}
}
```
## ServiceExtensionAbility.onRequest
onRequest(want: Want, startId: number): void;
Called after **onCreate** is invoked when a Service Extension ability is started by calling **startAbility**. The value of **startId** is incremented for each ability that is started.
**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|
| -------- | -------- | -------- | -------- |
| want | [Want](js-apis-app-ability-want.md) | Yes| Want information related to this Service Extension ability, including the ability name and bundle name.|
| startId | number | Yes| Number of ability start times. The initial value is **1**, and the value is automatically incremented for each ability started.|
**Example**
```ts
class ServiceExt extends ServiceExtension {
onRequest(want, startId) {
console.log('onRequest, want:' + want.abilityName);
}
}
```
## ServiceExtensionAbility.onConnect
onConnect(want: Want): rpc.RemoteObject;
Called after **onCreate** is invoked when a Service Extension ability is started by calling **connectAbility**. A **RemoteObject** object is returned for communication with the client.
**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|
| -------- | -------- | -------- | -------- |
| want | [Want](js-apis-app-ability-want.md)| Yes| Want information related to this Service Extension ability, including the ability name and bundle name.|
**Return value**
| Type| Description|
| -------- | -------- |
| rpc.RemoteObject | A **RemoteObject** object used for communication with the client.|
**Example**
```ts
import rpc from '@ohos.rpc'
class StubTest extends rpc.RemoteObject{
constructor(des) {
super(des);
}
onConnect(code, data, reply, option) {
}
}
class ServiceExt extends ServiceExtension {
onConnect(want) {
console.log('onConnect , want:' + want.abilityName);
return new StubTest("test");
}
}
```
## ServiceExtensionAbility.onDisconnect
onDisconnect(want: Want): void;
Called when this Service Extension ability is disconnected.
**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|
| -------- | -------- | -------- | -------- |
| want |[Want](js-apis-app-ability-want.md)| Yes| Want information related to this Service Extension ability, including the ability name and bundle name.|
**Example**
```ts
class ServiceExt extends ServiceExtension {
onDisconnect(want) {
console.log('onDisconnect, want:' + want.abilityName);
}
}
```
## ServiceExtensionAbility.onReconnect
onReconnect(want: Want): void;
Called when this Service Extension ability is reconnected.
**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|
| -------- | -------- | -------- | -------- |
| want |[Want](js-apis-app-ability-want.md)| Yes| Want information related to this Service Extension ability, including the ability name and bundle name.|
**Example**
```ts
class ServiceExt extends ServiceExtension {
onReconnect(want) {
console.log('onReconnect, want:' + want.abilityName);
}
}
```
## ServiceExtensionAbility.onConfigurationUpdate
onConfigurationUpdate(newConfig: Configuration): void;
Called when the configuration of this Service Extension ability is updated.
**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|
| -------- | -------- | -------- | -------- |
| newConfig | [Configuration](js-apis-app-ability-configuration.md) | Yes| New configuration.|
**Example**
```ts
class ServiceExt extends ServiceExtension {
onConfigurationUpdate(config) {
console.log('onConfigurationUpdate, config:' + JSON.stringify(config));
}
}
```
## ServiceExtensionAbility.onDump
onDump(params: Array\<string>): Array\<string>;
Dumps the client information.
**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|
| -------- | -------- | -------- | -------- |
| params | Array\<string> | Yes| Parameters in the form of a command.|
**Example**
```ts
class ServiceExt extends ServiceExtension {
onDump(params) {
console.log('dump, params:' + JSON.stringify(params));
return ["params"]
}
}
```
# StartOptions
# @ohos.app.ability.StartOptions
The **StartOptions** module implements ability startup options.
......@@ -9,15 +9,16 @@ The **StartOptions** module implements ability startup options.
## Modules to Import
```
import StartOptions from '@ohos.application.StartOptions';
```ts
import StartOptions from '@ohos.app.ability.StartOptions';
```
## Attributes
**System capability**: SystemCapability.Ability.AbilityRuntime.Core
| Name| Readable| Writable| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- | -------- | -------- |
| [windowMode](js-apis-application-abilityConstant.md#abilityconstantwindowmode) | Yes| No| number | No| Window mode.|
| displayId | Yes| No| number | No| Display ID.|
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| [windowMode](js-apis-application-abilityConstant.md#abilityconstantwindowmode) | number | No| Window mode.|
| displayId | number | No| Display ID.|
# Want
# @ohos.app.ability.Want
Want is a carrier for information transfer between objects (application components). Want can be used as a parameter of **startAbility** to specify a startup target and information that needs to be carried during startup, for example, **bundleName** and **abilityName**, which respectively indicate the bundle name of the target ability and the ability name in the bundle. When ability A needs to start ability B and transfer some data to ability B, it can use Want a carrier to transfer the data.
......
# @ohos.app.ability.wantConstant
The **wantConstant** module provides the actions, entities, and flags used in **Want** objects.
> **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.
## Modules to Import
```js
import wantConstant from '@ohos.app.ability.wantConstant';
```
## wantConstant.Action
Enumerates the action constants of the **Want** object.
**System capability**: SystemCapability.Ability.AbilityBase
| Name | Value | Description |
| ------------ | ------------------ | ---------------------- |
| ACTION_HOME | ohos.want.action.home | Action of returning to the home page. |
| ACTION_DIAL | ohos.want.action.dial | Action of launching the numeric keypad. |
| ACTION_SEARCH | ohos.want.action.search | Action of launching the search function. |
| ACTION_WIRELESS_SETTINGS | ohos.settings.wireless | Action of launching the UI that provides wireless network settings, for example, Wi-Fi options. |
| ACTION_MANAGE_APPLICATIONS_SETTINGS | ohos.settings.manage.applications | Action of launching the UI for managing installed applications. |
| ACTION_APPLICATION_DETAILS_SETTINGS | ohos.settings.application.details | Action of launching the UI that displays the details of an application. |
| ACTION_SET_ALARM | ohos.want.action.setAlarm | Action of launching the UI for setting the alarm clock. |
| ACTION_SHOW_ALARMS | ohos.want.action.showAlarms | Action of launching the UI that displays all alarms. |
| ACTION_SNOOZE_ALARM | ohos.want.action.snoozeAlarm | Action of launching the UI for snoozing an alarm. |
| ACTION_DISMISS_ALARM | ohos.want.action.dismissAlarm | Action of launching the UI for deleting an alarm. |
| ACTION_DISMISS_TIMER | ohos.want.action.dismissTimer | Action of launching the UI for dismissing a timer. |
| ACTION_SEND_SMS | ohos.want.action.sendSms | Action of launching the UI for sending an SMS message. |
| ACTION_CHOOSE | ohos.want.action.choose | Action of launching the UI for opening a contact or picture. |
| ACTION_IMAGE_CAPTURE | ohos.want.action.imageCapture | Action of launching the UI for photographing. |
| ACTION_VIDEO_CAPTURE | ohos.want.action.videoCapture | Action of launching the UI for shooting a video. |
| ACTION_SELECT | ohos.want.action.select | Action of launching the UI for application selection. |
| ACTION_SEND_DATA | ohos.want.action.sendData | Action of launching the UI for sending a single data record. |
| ACTION_SEND_MULTIPLE_DATA | ohos.want.action.sendMultipleData | Action of launching the UI for sending multiple data records. |
| ACTION_SCAN_MEDIA_FILE | ohos.want.action.scanMediaFile | Action of requesting a media scanner to scan a file and add the file to the media library. |
| ACTION_VIEW_DATA | ohos.want.action.viewData | Action of viewing data. |
| ACTION_EDIT_DATA | ohos.want.action.editData | Action of editing data. |
| INTENT_PARAMS_INTENT | ability.want.params.INTENT | Action of displaying selection options with an action selector. |
| INTENT_PARAMS_TITLE | ability.want.params.TITLE | Title of the character sequence dialog box used with the action selector. |
| ACTION_FILE_SELECT | ohos.action.fileSelect | Action of selecting a file. |
| PARAMS_STREAM | ability.params.stream | URI of the data stream associated with the target when the data is sent. | |
| ACTION_APP_ACCOUNT_AUTH | account.appAccount.action.auth | Action of providing the authentication service. |
| ACTION_MARKET_DOWNLOAD | 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 | 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 |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 |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 |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 |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 |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
Enumerates the entity constants of the **Want** object.
**System capability**: SystemCapability.Ability.AbilityBase
| Name | Value | Description |
| ------------ | ------------------ | ---------------------- |
| ENTITY_DEFAULT | entity.system.default | Default entity. The default entity is used if no entity is specified. |
| ENTITY_HOME | entity.system.home | Home screen entity. |
| ENTITY_VOICE | entity.system.voice | Voice interaction entity. |
| ENTITY_BROWSABLE | entity.system.browsable | Browser type entity. |
| ENTITY_VIDEO | entity.system.video | Video type entity. |
## wantConstant.Flags
Describes flags.
**System capability**: SystemCapability.Ability.AbilityBase
| Name | Value | Description |
| ------------------------------------ | ---------- | ------------------------------------------------------------ |
| FLAG_AUTH_READ_URI_PERMISSION | 0x00000001 | Indicates the permission to read the URI. |
| FLAG_AUTH_WRITE_URI_PERMISSION | 0x00000002 | Indicates the permission to write data to the URI. |
| FLAG_ABILITY_FORWARD_RESULT | 0x00000004 | Returns the result to the ability. |
| FLAG_ABILITY_CONTINUATION | 0x00000008 | Indicates whether the ability on the local device can be continued on a remote device. |
| FLAG_NOT_OHOS_COMPONENT | 0x00000010 | Indicates that a component does not belong to OHOS. |
| FLAG_ABILITY_FORM_ENABLED | 0x00000020 | Indicates that an ability is enabled. |
| FLAG_AUTH_PERSISTABLE_URI_PERMISSION | 0x00000040 | Indicates the permission to make the URI persistent.<br>**System API**: This is a system API and cannot be called by third-party applications. |
| FLAG_AUTH_PREFIX_URI_PERMISSION | 0x00000080 | Indicates the permission to verify URIs by prefix matching.<br>**System API**: This is a system API and cannot be called by third-party applications.|
| FLAG_ABILITYSLICE_MULTI_DEVICE | 0x00000100 | Supports cross-device startup in a distributed scheduler. |
| FLAG_START_FOREGROUND_ABILITY | 0x00000200 | Indicates that the Service ability is started regardless of whether the host application has been started. |
| 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_NEW_MISSION | 0x10000000 | Indicates the operation of creating a mission on the history mission stack. |
| FLAG_ABILITY_MISSION_TOP | 0x20000000 | Starts the mission on the top of the existing mission stack; creates an ability instance if no mission exists.|
# @ohos.app.form.formBindingData
The **FormBindingData** module provides APIs for widget data binding. You can use the APIs to create a **FormBindingData** object and obtain related information.
> **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.
## Modules to Import
```ts
import formBindingData from '@ohos.app.form.formBindingData';
```
## FormBindingData
Describes a **FormBindingData** object.
**System capability**: SystemCapability.Ability.Form
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| data | Object | Yes| Data to be displayed on the JS widget. The value can be an object containing multiple key-value pairs or a string in JSON format.|
## createFormBindingData
createFormBindingData(obj?: Object | string): FormBindingData
Creates a **FormBindingData** object.
**System capability**: SystemCapability.Ability.Form
**Parameters**
| Name| Type | Mandatory| Description |
| ------ | -------------- | ---- | ------------------------------------------------------------ |
| obj | Object\|string | No | Data to be displayed on the JS widget. The value can be an object containing multiple key-value pairs or a string in JSON format. The image data is identified by "formImages", and the content is multiple key-value pairs, each of which consists of an image identifier and image file descriptor. The final format is {"formImages": {"key1": fd1, "key2": fd2}}.|
**Return value**
| Type | Description |
| ----------------------------------- | --------------------------------------- |
| [FormBindingData](#formbindingdata) | **FormBindingData** object created based on the passed data.|
**Example**
```ts
import featureAbility from '@ohos.ability.featureAbility';
import fileio from '@ohos.fileio';
let context=featureAbility.getContext();
context.getOrCreateLocalDir((err,data)=>{
let path=data+"/xxx.jpg";
let fd = fileio.openSync(path);
let obj = {
"temperature": "21°",
"formImages": {"image": fd}
};
try {
formBindingData.createFormBindingData(obj);
} catch (error) {
console.log(`catch err->${JSON.stringify(err)}`);
}
})
```
# @ohos.app.form.formInfo
The **FormInfo** module provides widget information and state.
> **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.
## Modules to Import
```ts
import formInfo from '@ohos.app.form.formInfo';
```
## FormInfo
Describes widget information.
**System capability**: SystemCapability.Ability.Form
| Name | Type | Readable | Writable | Description |
| ----------- | -------- | -------- | -------------------- | ------------------------------------------------------------ |
| bundleName | string | Yes | No | Name of the bundle to which the widget belongs. |
| moduleName | string | Yes | No | Name of the module to which the widget belongs. |
| abilityName | string | Yes | No | Name of the ability to which the widget belongs. |
| name | string | Yes | No | Widget name. |
| description | string | Yes | No | Description of the widget. |
| type | [FormType](#formtype) | Yes | No | Type of the widget. Currently, only JS widgets are supported.|
| jsComponentName | string | Yes | No | Name of the component used in the JS widget. |
| colorMode | [ColorMode](#colormode) | Yes | No | Color mode of the widget. |
| isDefault | boolean | Yes | No | Whether the widget is the default one. |
| updateEnabled | boolean | Yes | No | Whether the widget is updatable. |
| formVisibleNotify | string | Yes | No | Whether to send a notification when the widget is visible. |
| relatedBundleName | string | Yes | No | Name of the associated bundle to which the widget belongs. |
| scheduledUpdateTime | string | Yes | No | Time when the widget was updated. |
| formConfigAbility | string | Yes | No | Configuration ability of the widget, that is, the ability corresponding to the option in the selection box displayed when the widget is long pressed. |
| updateDuration | string | Yes | No | Update period of the widget.|
| defaultDimension | number | Yes | No | Default dimension of the widget. |
| supportDimensions | Array&lt;number&gt; | Yes | No | Dimensions supported by the widget. For details, see [FormDimension](#formdimension). |
| customizeData | {[key: string]: [value: string]} | Yes | No | Custom data of the widget. |
## FormType
Enumerates the widget types.
**System capability**: SystemCapability.Ability.Form
| Name | Value | Description |
| ----------- | ---- | ------------ |
| JS | 1 | JS widget. |
| eTS | 2 | eTS widget.|
## ColorMode
Enumerates the color modes supported by the widget.
**System capability**: SystemCapability.Ability.Form
| Name | Value | Description |
| ----------- | ---- | ------------ |
| MODE_AUTO | -1 | Auto mode. |
| MODE_DARK | 0 | Dark mode. |
| MODE_LIGHT | 1 | Light mode. |
## FormStateInfo
Describes the widget state information.
**System capability**: SystemCapability.Ability.Form
| Name | Type | Readable | Writable | Description |
| ----------- | -------- | -------- | -------------------- | ------------------------------------------------------------ |
| formState | [FormState](#formstate) | Yes | No | Widget state. |
| want | Want | Yes | No | Want text. |
## FormState
Enumerates the widget states.
**System capability**: SystemCapability.Ability.Form
| Name | Value | Description |
| ----------- | ---- | ------------ |
| UNKNOWN | -1 | Unknown state. |
| DEFAULT | 0 | Default state. |
| READY | 1 | Ready state. |
## FormParam
Enumerates the widget parameters.
**System capability**: SystemCapability.Ability.Form
| Name | Value | Description |
| ----------- | ---- | ------------ |
| IDENTITY_KEY | "ohos.extra.param.key.form_identity" | Widget ID. |
| DIMENSION_KEY | "ohos.extra.param.key.form_dimension" | Widget dimension. |
| NAME_KEY | "ohos.extra.param.key.form_name" | Widget name. |
| MODULE_NAME_KEY | "ohos.extra.param.key.module_name" | Name of the module to which the widget belongs. |
| WIDTH_KEY | "ohos.extra.param.key.form_width" | Widget width. |
| HEIGHT_KEY | "ohos.extra.param.key.form_height" | Widget height. |
| TEMPORARY_KEY | "ohos.extra.param.key.form_temporary" | Temporary widget. |
| ABILITY_NAME_KEY | "ohos.extra.param.key.ability_name" | Ability name. |
| DEVICE_ID_KEY | "ohos.extra.param.key.device_id" | Device ID.<br>**System API**: This is a system API. |
| BUNDLE_NAME_KEY | "ohos.extra.param.key.bundle_name" | Key that specifies the target bundle name.|
## FormDimension
Enumerates the widget dimensions.
**System capability**: SystemCapability.Ability.Form
| Name | Value | Description |
| ----------- | ---- | ------------ |
| Dimension_1_2 | 1 | 1 x 2. |
| Dimension_2_2 | 2 | 2 x 2. |
| Dimension_2_4 | 3 | 2 x 4. |
| Dimension_4_4 | 4 | 4 x 4. |
| Dimension_2_1 | 5 | 2 x 1. |
## FormInfoFilter
Defines the widget information filter. Only the widget information that meets the filter is returned.
**System capability**: SystemCapability.Ability.Form
| Name | Description |
| ----------- | ------------ |
| moduleName | Only the information about the widget whose **moduleName** is the same as the provided value is returned.|
## VisibilityType
Enumerates the visibility types of the widget.
**System capability**: SystemCapability.Ability.Form
| Name | Value | Description |
| ----------- | ---- | ------------ |
| FORM_VISIBLE | 1 | The widget is visible.|
| FORM_INVISIBLE | 2 | The widget is invisible.|
# AbilityConstant
# @ohos.application.AbilityConstant
The **AbilityConstant** module provides ability launch parameters.
......@@ -6,12 +6,12 @@ The parameters include the initial launch reasons, reasons for the last exit, an
> **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.
> The APIs of this module are supported and deprecated since API version 9. You are advised to use [@ohos.app.ability.AbilityConstant](js-apis-app-ability-abilityConstant.md) instead. Newly added APIs will be marked with a superscript to indicate their earliest API version.
> The APIs of this module can be used only in the stage model.
## Modules to Import
```js
```ts
import AbilityConstant from '@ohos.application.AbilityConstant';
```
......@@ -19,10 +19,10 @@ import AbilityConstant from '@ohos.application.AbilityConstant';
**System capability**: SystemCapability.Ability.AbilityRuntime.Core
| Name| Type| Readable| Writable| Description|
| Name| Type| Readable| Writable| Description|
| -------- | -------- | -------- | -------- | -------- |
| launchReason | LaunchReason| Yes| Yes| Ability launch reason.|
| lastExitReason | LastExitReason | Yes| Yes| Reason for the last exit.|
| launchReason | LaunchReason| Yes| Yes| Ability launch reason.|
| lastExitReason | LastExitReason | Yes| Yes| Reason for the last exit.|
## AbilityConstant.LaunchReason
......@@ -36,6 +36,7 @@ Enumerates ability launch reasons.
| START_ABILITY | 1 | Ability startup.|
| CALL | 2 | Call.|
| CONTINUATION | 3 | Ability continuation.|
| APP_RECOVERY | 4 | Application recovery.|
## AbilityConstant.LastExitReason
......@@ -88,3 +89,29 @@ Enumerates the memory levels.
| MEMORY_LEVEL_MODERATE | 0 | Moderate memory usage. |
| MEMORY_LEVEL_LOW | 1 | Low memory usage. |
| MEMORY_LEVEL_CRITICAL | 2 | High memory usage. |
## AbilityConstant.OnSaveResult
Enumerates the result types for the operation of saving application data.
**System capability**: SystemCapability.Ability.AbilityRuntime.Core
| Name | Value | Description |
| ----------------------------- | ---- | ------------------------------------------------------------ |
| ALL_AGREE | 0 | Agreed to save the status.|
| CONTINUATION_REJECT | 1 | Rejected to save the status in continuation.|
| CONTINUATION_MISMATCH | 2 | Continuation mismatch.|
| RECOVERY_AGREE | 3 | Agreed to restore the saved status.|
| RECOVERY_REJECT | 4 | Rejected to restore the saved state.|
| ALL_REJECT | 5 | Rejected to save the status.|
## AbilityConstant.StateType
Enumerates the scenarios for saving application data.
**System capability**: SystemCapability.Ability.AbilityRuntime.Core
| Name | Value | Description |
| ----------------------------- | ---- | ------------------------------------------------------------ |
| CONTINUATION | 0 | Saving the status in continuation.|
| APP_RECOVERY | 1 | Saving the status in application recovery.|
# AbilityDelegatorRegistry
# @ohos.application.abilityDelegatorRegistry
The **AbilityDelegatorRegistry** module provides APIs for storing the global registers of the registered **AbilityDelegator** and **AbilityDelegatorArgs** objects. You can use the APIs to obtain the **AbilityDelegator** and **AbilityDelegatorArgs** objects of an application.
......@@ -8,7 +8,7 @@ The **AbilityDelegatorRegistry** module provides APIs for storing the global reg
## Modules to Import
```js
```ts
import AbilityDelegatorRegistry from '@ohos.application.abilityDelegatorRegistry'
```
......@@ -38,18 +38,16 @@ Obtains the **AbilityDelegator** object of the application.
| Type | Description |
| ------------------------------------------------------------ | ------------------------------------------------------------ |
| [AbilityDelegator](js-apis-application-abilityDelegator.md#AbilityDelegator) | [AbilityDelegator](js-apis-application-abilityDelegator.md#AbilityDelegator) object, which can be used to schedule functions related to the test framework.|
| [AbilityDelegator](js-apis-inner-application-abilityDelegator.md#AbilityDelegator) | [AbilityDelegator](js-apis-inner-application-abilityDelegator.md#AbilityDelegator) object, which can be used to schedule functions related to the test framework.|
**Example**
```js
```ts
var abilityDelegator;
abilityDelegator = AbilityDelegatorRegistry.getAbilityDelegator();
```
## AbilityDelegatorRegistry.getArguments
getArguments(): AbilityDelegatorArgs
......@@ -62,11 +60,11 @@ Obtains the **AbilityDelegatorArgs** object of the application.
| Type | Description |
| ------------------------------------------------------------ | ------------------------------------------------------------ |
| [AbilityDelegatorArgs](js-apis-application-abilityDelegatorArgs.md#AbilityDelegatorArgs) | [AbilityDelegatorArgs](js-apis-application-abilityDelegatorArgs.md#AbilityDelegatorArgs) object, which can be used to obtain test parameters.|
| [AbilityDelegatorArgs](js-apis-inner-application-abilityDelegatorArgs.md#AbilityDelegatorArgs) | [AbilityDelegatorArgs](js-apis-inner-application-abilityDelegatorArgs.md#AbilityDelegatorArgs) object, which can be used to obtain test parameters.|
**Example**
```js
```ts
var args = AbilityDelegatorRegistry.getArguments();
console.info("getArguments bundleName:" + args.bundleName);
console.info("getArguments testCaseNames:" + args.testCaseNames);
......
......@@ -107,5 +107,3 @@ export default class MyWindowExtensionAbility extends WindowExtensionAbility {
}
```
<!--no_check-->
\ No newline at end of file
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册