diff --git a/en/application-dev/application-models/accessibilityextensionability.md b/en/application-dev/application-models/accessibilityextensionability.md index 42968456fe88c836e5befe9c096eb2f3892729e1..a76742c142bfccdd015665478aadbaedf19ff39e 100644 --- a/en/application-dev/application-models/accessibilityextensionability.md +++ b/en/application-dev/application-models/accessibilityextensionability.md @@ -20,11 +20,11 @@ Below shows the AccessibilityExtensionAbility framework. ![AccessibilityFramework](figures/AccessibilityFramework.png) -1. Accessibility app: extension service application developed based on the AccessibilityExtensionAbility framework, for example, a screen reader application. -2. Target app: application assisted by the accessibility app. -3. AccessibilityAbilityManagerService (AAMS): main service of the AccessibilityExtensionAbility framework, which is used to manage the lifecycle of accessibility apps and provide a bridge for information exchange between accessibility apps and target apps. -4. AccessibilityAbility (AAkit): ability that is used by the accessibility app to build an extension service ability operating environment and that provides interfaces for the accessibility app to query and operate the target app, including performing click/long press operations. -5. AccessibilitySystemAbilityClient (ASACkit): used by the target app to send accessibility events, such as content change events, to AAMS, and respond to the instructions (such as performing click/long press operations) sent by the accessibility app through AAMS. +1. Accessibility application: extension service application developed based on the AccessibilityExtensionAbility framework, for example, a screen reader application. +2. Target application: application assisted by the accessibility application. +3. AccessibilityAbilityManagerService (AAMS): main service of the AccessibilityExtensionAbility framework, which is used to manage the lifecycle of accessibility applications and provide a bridge for information exchange between accessibility applications and target applications. +4. AccessibilityAbility (AAkit): ability that is used by the accessibility application to build an extension service ability operating environment and that provides interfaces for the accessibility application to query and operate the target application, including performing click/long press operations. +5. AccessibilitySystemAbilityClient (ASACkit): used by the target application to send accessibility events, such as content change events, to AAMS, and respond to the instructions (such as performing click/long press operations) sent by the accessibility application through AAMS. ## Creating an Accessibility Extension Service @@ -116,13 +116,13 @@ After developing the custom logic for an accessibility extension service, you mu ] } ``` -## Enabling a Custom Accessibility Extension Service +## Enabling or Disabling a Custom Accessibility Extension Service To enable or disable an accessibility extension service, run the following command: - To enable the service: **accessibility enable -a AccessibilityExtAbility -b com.example.demo -c rg** - To disable the service: **accessibility disable -a AccessibilityExtAbility -b com.example.demo** -In the preceding commands, **AccessibilityExtAbility** indicates the name of the accessibility extension service, **com.example.demo** indicates the bundle name, and **rg** indicates the capabilities (**r** is short for retrieve). +In the preceding commands, **AccessibilityExtAbility** indicates the name of the accessibility extension service, **com.example.demo** indicates the bundle name, and **rg** indicates the capabilities (**r** is short for retrieve and **g** gesture). If the service is enabled or disabled successfully, the message "enable ability successfully" or "disable ability successfully" is displayed. diff --git a/en/application-dev/application-models/figures/AccessibilityFramework.png b/en/application-dev/application-models/figures/AccessibilityFramework.png index 786233e6ac160972f62b9786397eb077f7ee767c..31abfb8cf00bf1c91e8718c06647443301892002 100644 Binary files a/en/application-dev/application-models/figures/AccessibilityFramework.png and b/en/application-dev/application-models/figures/AccessibilityFramework.png differ diff --git a/en/application-dev/reference/apis/Readme-EN.md b/en/application-dev/reference/apis/Readme-EN.md index d1d995be1e12f728d88d1d00e2a03549147199b4..94e19e5292225eae01f65b5cce8edb8109208265 100644 --- a/en/application-dev/reference/apis/Readme-EN.md +++ b/en/application-dev/reference/apis/Readme-EN.md @@ -145,9 +145,12 @@ - [NotificationTemplate](js-apis-inner-notification-notificationTemplate.md) - [NotificationUserInput](js-apis-inner-notification-notificationUserInput.md) - Common Events + - [Common Events of the Ability Subsystem](common_event/commonEvent-ability.md) - [Common Events of the Bundle Management Subsystem](common_event/commonEvent-bundleManager.md) - [Common Events of the Notification Service](common_event/commonEvent-ans.md) + - [Common Events of the Resource Scheduler Subsystem](common_event/commonEvent-resourceschedule.md) - [Common Events of the Telephony Subsystem](common_event/commonEvent-telephony.md) + - [Common Events of the USB Subsystem](common_event/commonEvent-usb.md) - Bundle Management - [@ohos.bundle.appControl (appControl)](js-apis-appControl.md) - [@ohos.bundle.bundleManager (bundleManager)](js-apis-bundleManager.md) @@ -211,7 +214,7 @@ - [@ohos.multimedia.image (Image Processing)](js-apis-image.md) - [@ohos.multimedia.media (Media)](js-apis-media.md) - [@ohos.multimedia.systemSoundManager (System Sound Management)](js-apis-systemSoundManager.md) - - multimedia + - Multimedia - [ringtonePlayer (Ringtone Player)](js-apis-inner-multimedia-ringtonePlayer.md) - Resource Manager @@ -333,6 +336,7 @@ - [@ohos.web.webview (Webview)](js-apis-webview.md) - [Console](js-apis-logs.md) - [Timer](js-apis-timer.md) + - [SysCap](js-apis-syscap.md) - application - [AccessibilityExtensionContext (Accessibility Extension Context)](js-apis-inner-application-accessibilityExtensionContext.md) diff --git a/en/application-dev/reference/apis/js-apis-animator.md b/en/application-dev/reference/apis/js-apis-animator.md index 3aaf9f11af2349900af865eb977f493bec8c343b..5eb3e73a20a45f459f1879b49cfc4c9743c22fa7 100644 --- a/en/application-dev/reference/apis/js-apis-animator.md +++ b/en/application-dev/reference/apis/js-apis-animator.md @@ -5,6 +5,8 @@ The **Animator** module provides APIs for applying animation effects, including > **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. +> +> This module can be used only after a component instance is created, and it cannot be used in the [UIAbility](./js-apis-app-ability-uiAbility.md). ## Modules to Import diff --git a/en/application-dev/reference/apis/js-apis-mediaquery.md b/en/application-dev/reference/apis/js-apis-mediaquery.md index e5e74dc82b8abbcb15e48308484df7f587daf379..b2b8dfd30eb68510227790c45366de315cbb856b 100644 --- a/en/application-dev/reference/apis/js-apis-mediaquery.md +++ b/en/application-dev/reference/apis/js-apis-mediaquery.md @@ -5,6 +5,8 @@ The **mediaquery** module provides different styles for different media types. > **NOTE** > > The APIs of this module are supported since API version 7. Updates will be marked with a superscript to indicate their earliest API version. +> +> This module can be used only after a component instance is created, and it cannot be used in the [UIAbility](./js-apis-app-ability-uiAbility.md). ## Modules to Import @@ -26,7 +28,7 @@ Sets the media query condition. This API returns the corresponding media query l | Name | Type | Mandatory | Description | | --------- | ------ | ---- | ---------------------------------------- | -| condition | string | Yes | Media query condition. For details, see [Syntax of Media Query Conditions](../../ui/arkts-layout-development-media-query.md#syntax-of-media-query-conditions).| +| condition | string | Yes | Media query condition. For details, see [Syntax](../../ui/arkts-layout-development-media-query.md#syntax).| **Return value** @@ -146,7 +148,7 @@ struct MediaQueryExample { } aboutToAppear() { - let portraitFunc = this.onPortrait.bind(this) // Bind the current JS instance. + let portraitFunc = this.onPortrait.bind(this) // Bind the JS instance. this.listener.on('change', portraitFunc) } @@ -158,5 +160,3 @@ struct MediaQueryExample { } } ``` - - \ No newline at end of file diff --git a/en/application-dev/reference/apis/js-apis-promptAction.md b/en/application-dev/reference/apis/js-apis-promptAction.md index 4250e7503f68a0ef1144531c2f2ac74c5143edd4..aed51460eb6f196f07d72ee6071da53e4b052458 100644 --- a/en/application-dev/reference/apis/js-apis-promptAction.md +++ b/en/application-dev/reference/apis/js-apis-promptAction.md @@ -5,6 +5,8 @@ The **PromptAction** module provides APIs for creating and showing toasts, dialo > **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. +> +> This module can be used only after a component instance is created, and it cannot be used in the [UIAbility](./js-apis-app-ability-uiAbility.md). ## Modules to Import diff --git a/en/application-dev/reference/apis/js-apis-syscap.md b/en/application-dev/reference/apis/js-apis-syscap.md new file mode 100644 index 0000000000000000000000000000000000000000..05439e8cd6949a8f50caec8481fae3eb908cac3c --- /dev/null +++ b/en/application-dev/reference/apis/js-apis-syscap.md @@ -0,0 +1,42 @@ +# SysCap + +SystemCapability (SysCap) refers to a standalone feature in the operating system. Different devices support different SysCap sets. Each SysCap corresponds to one or more APIs. You can determine whether an API can be used by checking SysCap support. + +> **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. + +## canIUse + +canIUse(syscap: string): boolean + +Checks whether a SysCap is supported. + +**System capability**: SystemCapability.ArkUI.ArkUI.Full + +**Parameters** + +| Name| Type| Mandatory| Description| +| -------- | -------- | -------- | -------- | +| syscap | string | Yes| Name of the SysCap to check.| + +**Return value** + +| Type| Description| +| -------- | -------- | +| boolean | Check result. The value **true** means that the SysCap is supported, and **false** means the opposite.| + +**Example** + + ```js +import geolocation from '@ohos.geolocation' + +const isLocationAvailable = canIUse('SystemCapability.Location.Location'); +if (isLocationAvailable) { + geolocation.getCurrentLocation((location) => { + console.log(location.latitude, location.longitue); + }); +} else { + console.log('Location not by this device.'); +} + ``` diff --git a/en/application-dev/reference/arkui-ts/Readme-EN.md b/en/application-dev/reference/arkui-ts/Readme-EN.md index f2b75b5ee72085cc451b147a50d909edf44964a1..bb367dd6c32061334312afe76f0acee149f06bee 100644 --- a/en/application-dev/reference/arkui-ts/Readme-EN.md +++ b/en/application-dev/reference/arkui-ts/Readme-EN.md @@ -41,7 +41,6 @@ - [Foreground Color](ts-universal-attributes-foreground-color.md) - [Click Effect](ts-universal-attributes-click-effect.md) - Touch Interactions - - [Click Control](ts-universal-attributes-click.md) - [Touch Target](ts-universal-attributes-touch-target.md) - [Hit Test Control](ts-universal-attributes-hit-test-behavior.md) - Touch Interactions @@ -177,5 +176,7 @@ - [Pixel Units](ts-pixel-units.md) - [Enums](ts-appendix-enums.md) - [Types](ts-types.md) -- Components No Longer Maintained +- Components No Longer Maintained - [GridContainer](ts-container-gridcontainer.md) +- APIs No Longer Maintained + - [Click Control](ts-universal-attributes-click.md) \ No newline at end of file diff --git a/en/application-dev/reference/arkui-ts/ts-basic-components-marquee.md b/en/application-dev/reference/arkui-ts/ts-basic-components-marquee.md index a6c0b032ca3d1234898704a15d87358800f737e7..e14c0aee93857ea01cdec4f6e2843b273de28e97 100644 --- a/en/application-dev/reference/arkui-ts/ts-basic-components-marquee.md +++ b/en/application-dev/reference/arkui-ts/ts-basic-components-marquee.md @@ -33,7 +33,7 @@ Since API version 9, this API is supported in ArkTS widgets. | Name | Type| Description | | ---------- | -------- | ------------------------------------------------------------ | -| allowScale | boolean | Whether to allow text to scale.
Default value: **false**
Since API version 9, this API is supported in ArkTS widgets.| +| allowScale | boolean | Whether to allow text to scale.
This attribute is not supported currently.
Default value: **false** | ## Events diff --git a/en/application-dev/reference/arkui-ts/ts-container-relativecontainer.md b/en/application-dev/reference/arkui-ts/ts-container-relativecontainer.md index 77f136b9f2c9de3a7e59cb69c017ba33df6b6a10..d9199a9659f233da33e8f8200823dac138f71e8c 100644 --- a/en/application-dev/reference/arkui-ts/ts-container-relativecontainer.md +++ b/en/application-dev/reference/arkui-ts/ts-container-relativecontainer.md @@ -15,7 +15,7 @@ The **\** component is used for element alignment in complex * Alignment modes in the vertical direction can be top, center, or bottom, achieved by the **VerticalAlign.Top**, **VerticalAlign.Center**, and **VerticalAlign.Bottom** attributes of the container, respectively. * A child component can set the container or another child component as the anchor. * To show in the **\**, child components must have an ID. The container ID is fixed at **__container__**. - * Three positions of the child component in a direction can use three positions of the container or another child components in the same direction as anchors. If anchors are set for more than two positions in a single direction, the third position is skipped. + * Three positions on the child component in a specific direction can use as anchors three positions on the container or another child component in the same direction. If anchors are set for more than two positions in a single direction, then: Start and Center are preferred in the horizontal direction, and Top and Center are preferred in the vertical direction. * The child component size set on the frontend page is not affected by the **\** rules. If two or more **alignRules** values are set for one direction of the child component, you are not advised to set the size for this direction. * If offset is required after the alignment, it can be set through **offset**. * Exceptions diff --git a/en/application-dev/reference/arkui-ts/ts-container-tabs.md b/en/application-dev/reference/arkui-ts/ts-container-tabs.md index 0acc1c38aa5efa22aa3184facbf3c8ff69d154a7..99f26a37c690f220d5d1a0bdbc0be42e7c789372 100644 --- a/en/application-dev/reference/arkui-ts/ts-container-tabs.md +++ b/en/application-dev/reference/arkui-ts/ts-container-tabs.md @@ -21,7 +21,7 @@ Tabs(value?: {barPosition?: BarPosition, index?: number, controller?: [TabsContr | Name | Type | Mandatory| Description | | ----------- | --------------------------------- | ---- | ------------------------------------------------------------ | | barPosition | BarPosition | No | Position of the **\** component.
Default value: **BarPosition.Start** | -| index | number | No | Initial tab index.
Default value: **0**
**NOTE**
A value less than 0 evaluates to the default value.
The value ranges from 0 to the number of **\** subnodes minus 1.
When this parameter is set to different values, the slide animation for tab switching is enabled by default. To disable the animation, set **animationDuration** to **0**.
Since API version 10, this parameter supports [$$](../../quick-start/arkts-two-way-sync.md) for two-way binding of variables.| +| index | number | No | Initial tab index.
Default value: **0**
**NOTE**
A value less than 0 evaluates to the default value.
The value ranges from 0 to the number of **\** subnodes minus 1.
When this parameter is set to different values, the slide animation for tab switching is enabled by default. To disable the animation, set **animationDuration** to **0**.
Since API version 10, this parameter supports [$$](../../quick-start/arkts-two-way-sync.md) for two-way binding of variables. | | controller | [TabsController](#tabscontroller) | No | Tab controller. | ## BarPosition @@ -41,11 +41,13 @@ In addition to the [universal attributes](ts-universal-attributes-size.md), the | vertical | boolean | Whether to use vertical tabs. The value **true** means to use vertical tabs, and **false** means to use horizontal tabs.
Default value: **false**| | scrollable | boolean | Whether the tabs are scrollable. The value **true** means that the tabs are scrollable, and **false** means the opposite.
Default value: **true**| | barMode | BarMode | Tab bar layout mode. For details, see **BarMode**.
Default value: **BarMode.Fixed**| -| barWidth | number \| Length8+ | Width of the tab bar.
**NOTE**

A value less than 0 or greater than the width of the **\** component evaluates to the default value.| -| barHeight | number \| Length8+ | Height of the tab bar.
**NOTE**
A value less than 0 or greater than the width of the **\** component evaluates to the default value. | -| animationDuration | number | Duration of the slide animation for tab switching. If this parameter is set, the tab switching animation is played when the user switches between tabs by sliding or clicking. If this parameter is not set, the tab switching animation is played only when the user switches between tabs by sliding.
Default value: **300**
**NOTE**
A value less than 0 or in percentage evaluates to the default value.| +| barWidth | number \| Length8+ | Width of the tab bar.
The default value varies.
If the tab bar has the **vertical** attribute set to **false** and does not have a style specified, the default value is the width of the **\** component.
If the tab bar has the **vertical** attribute set to **true** and does not have a style specified, the default value is **56vp**.
If the tab bar has the **vertical** attribute set to **false** and **SubTabbarStyle** specified, the default value is the width of the **\** component.
If the tab bar has the **vertical** attribute set to **true** and **SubTabbarStyle** specified, the default value is **56vp**.
If the tab bar has the **vertical** attribute set to **true** and **BottomTabbarStyle** specified, the default value is **96vp**.
If the tab bar has the **vertical** attribute set to **false** and **BottomTabbarStyle** specified, the default value is the width of the **\** component.
**NOTE**

A value less than 0 or greater than the width of the **\** component evaluates to the default value.| +| barHeight | number \| Length8+ | Height of the tab bar.
The default value varies.
If the tab bar has the **vertical** attribute set to **false** and does not have a style specified, the default value is **56vp**.
If the tab bar has the **vertical** attribute set to **true** and does not have a style specified, the default value is the height of the **\** component.
If the tab bar has the **vertical** attribute set to **false** and **SubTabbarStyle** specified, the default value is **56vp**.
If the tab bar has the **vertical** attribute set to **true** and **SubTabbarStyle** specified, the default value is the height of the **\** component.
If the tab bar has the **vertical** attribute set to **true** and **BottomTabbarStyle** specified, the default value is the height of the **\** component.
If the tab bar has the **vertical** attribute set to **false** and **BottomTabbarStyle** specified, the default value is **56vp**.
**NOTE**
A value less than 0 or greater than the height of the **\** component evaluates to the default value. | +| animationDuration | number | Duration of the slide animation for tab switching. If this parameter is set, the tab switching animation is played when the user switches between tabs by sliding or clicking. If this parameter is not set, the tab switching animation is played only when the user switches between tabs by sliding.
Default value: **300**
**NOTE**
A value less than 0 or in percentage evaluates to the default value. | | divider10+ | [DividerStyle](#dividerstyle10) \| null | Whether the divider is displayed for the **\** and **\** components and the divider style. By default, the divider is not displayed.
**DividerStyle**: divider style.
**null**: The divider is not displayed.| | fadingEdge10+ | boolean | Whether the tab fades out when it exceeds the container width.
Default value: **true** | +| barOverlap10+ | boolean | Whether the tab bar is superimposed on the **\** component after having its background blurred.
Default value: **false** | +| barBackgroundColor10+ | [ResourceColor](ts-types.md#resourcecolor) | Background color of the tab bar.
Default value: transparent| ## DividerStyle10+ @@ -91,7 +93,7 @@ Switches to the specified tab. | Name | Type | Mandatory | Description | | ----- | ------ | ---- | ---------------------------------------- | -| value | number | Yes | Index of the tab. The value starts from 0.
**NOTE**

If this parameter is set to a value less than 0 or greater than the maximum number, the event will be invalid.| +| value | number | Yes | Index of the tab. The value starts from 0.
**NOTE**
If this parameter is set to a value less than 0 or greater than the maximum number, the event will be invalid. | ## Example diff --git a/en/application-dev/reference/arkui-ts/ts-methods-custom-dialog-box.md b/en/application-dev/reference/arkui-ts/ts-methods-custom-dialog-box.md index 343b5b85365a51387a3dada28d87029a831594f7..8605a29ab1e390a0e5fea2ca77f0b5d337172783 100644 --- a/en/application-dev/reference/arkui-ts/ts-methods-custom-dialog-box.md +++ b/en/application-dev/reference/arkui-ts/ts-methods-custom-dialog-box.md @@ -112,9 +112,10 @@ struct CustomDialogUser { customStyle: false }) + // Delete the dialogController instance and set it to undefined when the custom component is about to be destroyed. aboutToDisappear() { - delete this.dialogController, - this.dialogController = undefined + delete this.dialogController, // Delete the dialogController instance. + this.dialogController = undefined //Set dialogController to undefined. } onCancel() { diff --git a/en/application-dev/reference/native-apis/Readme-EN.md b/en/application-dev/reference/native-apis/Readme-EN.md index 59113d614cd2764c01e94db9440c40268d2b686e..ee896c67409995bce0420d9b762ba232d270de01 100644 --- a/en/application-dev/reference/native-apis/Readme-EN.md +++ b/en/application-dev/reference/native-apis/Readme-EN.md @@ -18,6 +18,7 @@ - [HuksKeyApi](_huks_key_api.md) - [HuksParamSetApi](_huks_param_set_api.md) - [HuksTypeApi](_huks_type_api.md) + - [Init](init.md) - [Memory](memory.md) - Header Files - [drawing_bitmap.h](drawing__bitmap_8h.md) @@ -57,6 +58,7 @@ - [native_huks_api.h](native__huks__api_8h.md) - [native_huks_param.h](native__huks__param_8h.md) - [native_huks_type.h](native__huks__type_8h.md) + - [syscap_ndk.h](syscap__ndk_8h.md) - [purgeable_memory.h](purgeable__memory_8h.md) - Structs - [OH_Drawing_BitmapFormat](_o_h___drawing___bitmap_format.md) diff --git a/en/application-dev/reference/native-apis/init.md b/en/application-dev/reference/native-apis/init.md new file mode 100644 index 0000000000000000000000000000000000000000..fcbf32da041bace7ab6918384c1c4e17b7280fa8 --- /dev/null +++ b/en/application-dev/reference/native-apis/init.md @@ -0,0 +1,54 @@ +# Init + + +## Overview + +Provides APIs for checking SystemCapability (SycCap) support. + +You can use the provided APIs to read the SycCap parameter file to check whether a specific SycCap is supported. + +**Since:** + +8 + + +## Summary + + +### Files + +| Name| Description| +| -------- | -------- | +| [syscap_ndk.h](syscap__ndk_8h.md) | Defines the APIs for checking SycCap support.| + + +### Functions + +| Name| Description| +| -------- | -------- | +| [canIUse](#caniuse) (const char \*cap) | Checks whether a SysCap is supported. SystemCapability (SysCap) refers to a standalone feature in the operating system. Different devices support different SysCap sets. Each SysCap corresponds to one or more APIs. You can determine whether an API can be used by checking SysCap support.| + + +## Function Description + + +### canIUse() + + +``` +bool canIUse (const char * cap) +``` + +**Description** + +Checks whether a SysCap is supported. SystemCapability (SysCap) refers to a standalone feature in the operating system. Different devices support different SysCap sets. Each SysCap corresponds to one or more APIs. You can determine whether an API can be used by checking SysCap support. + +**Parameters** + +| Name| Description| +| -------- | -------- | +| cap | Name of the SysCap to check.| + +**Returns** + +Check result. The value **true** means that the SysCap is supported, and **false** means the opposite. diff --git a/en/application-dev/reference/native-apis/syscap__ndk_8h.md b/en/application-dev/reference/native-apis/syscap__ndk_8h.md new file mode 100644 index 0000000000000000000000000000000000000000..a96ab91cd628b2bb255fc098438c675ba9ca8a41 --- /dev/null +++ b/en/application-dev/reference/native-apis/syscap__ndk_8h.md @@ -0,0 +1,24 @@ +# syscap_ndk.h + + +## Overview + +Declares the APIs for checking SycCap support. + +**Since:** + +8 + +**Related Modules:** + +[Init](init.md) + + +## Summary + + +### Functions + +| Name| Description| +| -------- | -------- | +| [canIUse](init.md#caniuse) (const char \*cap) | Checks whether a SysCap is supported.
SystemCapability (SysCap) refers to a standalone feature in the operating system. Different devices support different SysCap sets. Each SysCap corresponds to one or more APIs. You can determine whether an API can be used by checking SysCap support.| diff --git a/en/application-dev/reference/syscap.md b/en/application-dev/reference/syscap.md index 03c2f4c42ba8d796582bab4debe536edcfafc3f9..f5db3a40c6ecaa666a828191f695d7ddeda92c6f 100644 --- a/en/application-dev/reference/syscap.md +++ b/en/application-dev/reference/syscap.md @@ -93,29 +93,49 @@ By default, the associated SysCap set of an application is the union of multiple ### Checking Whether an API Is Available -- Method 1: Use the **canIUse()** API to check whether a SysCap is supported. - - ```ts - if (canIUse("SystemCapability.ArkUI.ArkUI.Full")) { - console.log("This device supports SystemCapability.ArkUI.ArkUI.Full."); - } else { - console.log("This device does not support SystemCapability.ArkUI.ArkUI.Full."); - } - ``` - -- Method 2: Import a module using the **import** API. If the current device does not support the module, the import result is **undefined**. Before using an API, you must make sure the API is available. - - ```ts - import geolocation from '@ohos.geolocation'; - - if (geolocation) { - geolocation.getCurrentLocation((location) => { - console.log(location.latitude, location.longitude); - }); - } else { - console.log('This device does not support location information.'); - } - ``` +You can use either the ArtTS or native API to determine whether an API is available. + +- ArkTS API + + - Method 1: Use the **canIUse()** API to check whether a SysCap is supported. + + ```ts + if (canIUse("SystemCapability.ArkUI.ArkUI.Full")) { + console.log("This device supports SystemCapability.ArkUI.ArkUI.Full."); + } else { + console.log("This device does not support SystemCapability.ArkUI.ArkUI.Full."); + } + ``` + + - Method 2: Import a module using the **import** API. If the current device does not support the module, the import result is **undefined**. Before using an API, you must make sure the API is available. + + ```ts + import geolocation from '@ohos.geolocation'; + + if (geolocation) { + geolocation.getCurrentLocation((location) => { + console.log(location.latitude, location.longitude); + }); + } else { + console.log('This device does not support location information.'); + } + ``` +- Native API + + ```c + #include + #include + #include "syscap_ndk.h" + + char syscap[] = "SystemCapability.ArkUI.ArkUI.Full"; + bool result = canIUse(syscap); + if (result) { + printf("SysCap: %s is supported!\n", syscap); + } else { + printf("SysCap: %s is not supported!\n", syscap); + } + ``` + You can also find out the SysCap to which an API belongs by referring to the API reference document. ### Checking the Differences Between Devices with a Specific SysCap