提交 9d043700 编写于 作者: S sienna1128

Merge branch 'master' of https://gitee.com/sienna1128/docs

......@@ -29,11 +29,22 @@ zh-cn/device-dev/quick-start/quickstart-lite-env-setup.md @li-yan339 @chenmudan
zh-cn/device-dev/porting/porting-thirdparty-overview.md @Austin23 @chenmudan
zh-cn/device-dev/porting/porting-thirdparty-makefile.md @Austin23 @chenmudan
zh-cn/device-dev/porting/porting-thirdparty-cmake.md @Austin23 @chenmudan
zh-cn/device-dev/subsystems/subsys-build-mini-lite.md @Austin23 @chenmudan
zh-cn/device-dev/subsystems/subsys-build-standard-large.md @Austin23 @chenmudan
zh-cn/device-dev/subsystems/subsys-build-gn-coding-style-and-best-practice.md @Austin23 @chenmudan
zh-cn/device-dev/subsystems/subsys-build-gn-kconfig-visual-config-guid.md @Austin23 @chenmudan
zh-cn/device-dev/subsystems/subsys-build-gn-hap-compilation-guide.md @Austin23 @chenmudan
zh-cn/device-dev/subsystems/subsys-build-all.md @Austin23 @chenmudan
zh-cn/device-dev/subsystems/subsys-build-gn-coding-style-and-best-practice.md @Austin23 @chenmudan
zh-cn/device-dev/subsystems/subsys-build-gn-kconfig-visual-config-guide.md @Austin23 @chenmudan
zh-cn/device-dev/subsystems/subsys-build-product.md @Austin23 @chenmudan
zh-cn/device-dev/subsystems/subsys-build-zh-cn/device-dev/subsystems/subsystem.md @Austin23 @chenmudan
zh-cn/device-dev/subsystems/subsys-build-component.md @Austin23 @chenmudan
zh-cn/device-dev/subsystems/subsys-build-module.md @Austin23 @chenmudan
zh-cn/device-dev/subsystems/subsys-build-chip_solution.md @Austin23 @chenmudan
zh-cn/device-dev/subsystems/subsys-build-feature.md @Austin23 @chenmudan
zh-cn/device-dev/subsystems/subsys-build-syscap.md @Austin23 @chenmudan
zh-cn/device-dev/subsystems/subsys-build-reference.md @Austin23 @chenmudan
zh-cn/device-dev/subsystems/subsys-build-reference.md @Austin23 @chenmudan
zh-cn/device-dev/subsystems/subsys-build-reference.md @Austin23 @chenmudan
zh-cn/device-dev/subsystems/subsys-build-reference.md @Austin23 @chenmudan
zh-cn/device-dev/subsystems/subsys-build-gn-hap-compilation-guide.md @Austin23 @chenmudan
zh-cn/device-dev/subsystems/subsys-build-FAQ.md @Austin23 @chenmudan
zh-cn/device-dev/subsystems/subsys-remote-start.md @duangavin123_admin
zh-cn/device-dev/subsystems/subsys-graphics-overview.md @duangavin123_admin
zh-cn/device-dev/subsystems/subsys-graphics-container-guide.md @duangavin123_admin
......
# FAQs
- [Ability Framework Development](faqs-ability.md)
- [ArkUI (JavaScript) Development](faqs-ui-js.md)
- [ArkUI (eTS) Development](faqs-ui-ets.md)
- [Graphics and Image Development](faqs-graphics.md)
- [File Management Development](faqs-file-management.md)
- [Data Management Development](faqs-data-management.md)
- [Device Management Development](faqs-device-management.md)
- [Native API Usage](faqs-native.md)
- [Usage of Third- and Fourth-Party Libraries](faqs-third-party-library.md)
- [Development Board](faqs-development-board.md)
# Development Board
## How do I take screenshots on a development board?
Applicable to: OpenHarmony SDK 3.2.2.5, stage model of API version 9
- Method 1: Click the screenshot button in the Control Panel from the development board UI. The screenshot is displayed in Gallery.
- Method 2: Run the screenshot script. Connect to the development board to a computer running Windows. Create a text file on the computer, copy the following script content to the file, change the file name extension to **.bat** (the HDC environment variables must be configured in advance), and click **Run**. The screenshot is saved to the same directory as the **.bat** script file.
Example:
```
set filepath=/data/%date:~0,4%%date:~5,2%%date:~8,2%%time:~1,1%%time:~3,2%%time:~6,2%.png
echo %filepath%
: pause
hdc_std shell snapshot_display -f %filepath%
: pause
hdc_std file recv %filepath% .
: pause
```
## How do I adjust Previewer in DevEco Studio so that the preview looks the same as what's displayed on a real RK3568 development board?
Applicable to: DevEco Studio 3.0.0.991
1. Create a profile in Previewer.
![en-us_image_0000001361254285](figures/en-us_image_0000001361254285.png)
2. Set the profile parameters as follows:
Device type : default
Resolution: 720\*1280
DPI: 240
## What should I do if Device Manager incorrectly identifies a development board as FT232R USB UART even when the development board already has a driver installed?
Possible cause: The USB serial driver of the development version is not installed.
Solution: Search for **FT232R USB UART**, and download and install the driver.
## How do I complete authentication when logging in to the development board?
Applicable to: OpenHarmony SDK 3.2.2.5
When connecting to the network that requires authentication, open any web page in the browser to access the authentication page.
If there is no browser on the development board, you can install the [sample browser application](https://gitee.com/openharmony/app_samples/tree/master/device/Browser).
# Device Management Development
## How do I obtain the DPI of a device?
Applicable to: OpenHarmony SDK 3.2.2.5, stage model of API version 9
Import the **@ohos.display** module and call the **getDefaultDisplay** API.
Example:
```
import display from '@ohos.display';
display.getDefaultDisplay((err, data) => {
if (err.code) {
console.error('Test Failed to obtain the default display object. Code: ' + JSON.stringify(err));
return;
}
console.info('Test Succeeded in obtaining the default display object. Data:' + JSON.stringify(data));
console.info('Test densityDPI:' + JSON.stringify(data.densityDPI));
});https://gitee.com/openharmony/docs/blob/master/zh-cn/application-dev/reference/apis/js-apis-device-info.md)
```
# ArkUI (eTS) Development
## What are the restrictions on using generator functions in TypeScript?
Applicable to: OpenHarmony SDK 3.2.5.3, stage model of API version 9
Below are the restrictions on using generator functions in TypeScript:
- Expressions can be used only in character strings (in the ${expression} format), **if** conditions, **ForEach** parameters, and component parameters.
- No expressions should cause any application state variables (including **\@State**, **\@Link**, and **\@Prop**) to change. Otherwise, undefined and potentially unstable framework behavior may occur.
- The generator function cannot contain local variables.
None of the above restrictions apply to anonymous function implementations of event handlers (such as **onClick**)
Negative example:
```
build() {
let a: number = 1 // invalid: variable declaration not allowed
Column() {
Text('Hello ${this.myName.toUpperCase()}') // ok.
ForEach(this.arr.reverse(), ..., ...) // invalid: Array.reverse modifies the @State array varible in place
}
buildSpecial() // invalid: no function calls
Text(this.calcTextValue()) // this function call is ok.
}
```
## How do I use router to implement page redirection in the stage model?
Applicable to: OpenHarmony SDK 3.2.5.3, stage model of API version 9
To implement page redirection through **router**, add all redirected-to pages to the pages list in the **main_pages.json** file.
Page routing APIs in **router** can be invoked only after page rendering is complete. Do not call these APIs in **onInit** or **onReady** when the page is still in the rendering phase.
## Will a page pushed into the stack through router.push be reclaimed?
Applicable to: OpenHarmony SDK 3.2.5.3, stage model of API version 9
After being pushed to the stack through **router.push**, a page can be reclaimed only when it is popped from the stack through **router.back**.
## How do I dynamically replace the %s placeholder in a resource file?
Applicable to: OpenHarmony SDK 3.2.5.3, stage model of API version 9
In an application, you can replace the %s placeholder by using the second parameter in `$r('app.string.xx')`, which is used to reference application resources.
Example:
```
build() {
//do something
// The second parameter indicates the referenced string resource, which can be used to replace the %s placeholder.
Text($r('app.string.entry_desc','aaa'))
.fontSize(100)
.fontColor(Color.Black)
//do something
}
```
## How do I read an XML file in Resource and convert data in it to the string type?
Applicable to: OpenHarmony SDK 3.2.2.5, stage model of API version 9
1. Obtain data in Uint8Array format by calling the **RawFile** API of **resourceManager**.
2. Convert data in Uint8Array format to the string type by calling the **String.fromCharCode** API.
Reference: [Resource Management](https://gitee.com/openharmony/docs/blob/master/en/application-dev/reference/apis/js-apis-resource-manager.md)
Example:
```
resourceManager.getRawFile(path, (error, value) => {
if (error != null) {
console.log("error is " + error);
} else {
let rawFile = value;
let xml = String.fromCharCode.apply(null, rawFile)
}
});
```
## How do I convert a Resource object to the string type?
Applicable to: OpenHarmony SDK 3.2.3.5, stage model of API version 9
Use the **resourceManager.getString()** API of the **\@ohos.resourceManager** module.
Reference: [Resource Management](https://gitee.com/openharmony/docs/blob/master/en/application-dev/reference/apis/js-apis-resource-manager.md#getstring)
## What should I do if the global static variables of a class do not work?
Applicable to: OpenHarmony SDK 3.2.3.5, stage model of API version 9
Objects imported to abilities and pages are packaged into two different closures, that is, two global objects. In this case, a static variable referenced by the abilities is not the same object as that referenced by the pages. Therefore, global variables cannot be defined by defining static variables in the class. You are advised to use AppStorage to manage global variables.
Reference: [AppStorage](https://docs.openharmony.cn/pages/v3.2Beta/en/application-dev/ui/ts-application-states-appstorage.md/)
## How do I obtain resources in the stage model?
Applicable to: OpenHarmony SDK 3.2.3.5, stage model of API version 9
The stage model allows an application to obtain a **ResourceManager** object based on **context** and call its resource management APIs without first importing the required bundle. This method, however, is not applicable to the FA model.
Example:
```
const context = getContext(this) as any
context
.resourceManager
.getString($r('app.string.entry_desc').id)
.then(value => {
this.message = value.toString()
})
```
## How do I position a container component to the bottom of the screen?
Applicable to: OpenHarmony SDK 3.2.3.5, stage model of API version 9
Create a **<Stack\>** component, and set the target container at the bottom of the **<Stack\>** component.
Example:
```
build() {
Stack({alignContent : Alignment.Bottom}) {
// The container is at the bottom.
Stack() {
Column()
.width('100%')
.height('100%')
.backgroundColor(Color.Yellow)
}
.width('100%')
.height('10%')
}
.width('100%')
.height('100%')
.backgroundColor('rgba(255,255,255, 0)')
}
```
## Can CustomDialog be used in TypeScript files?
Applicable to: OpenHarmony SDK 3.2.2.5, stage model of API version 9
No. Currently, **CustomDialog** can be used only on eTS pages.
Reference: [Custom Dialog Box](https://gitee.com/openharmony/docs/blob/master/en/application-dev/reference/arkui-ts/ts-methods-custom-dialog-box.md)
## How do I transfer variables in CustomDialog to variables on pages?
Applicable to: OpenHarmony SDK 3.2.2.5, stage model of API version 9
Use a custom callback so that when the confirm button in the custom dialog box is clicked, the value of **data** is transferred from the dialog box to the current page.
Example:
```
// CustomDialog component
@CustomDialog
struct MyDialog {
controller: CustomDialogController
title: string
data: string
cancel: () => void
confirm: (data: string) => void
Button('confirm')
.onClick(() => {
this.controller.close()
this.data = 'test'
this.confirm(this.data)
}).backgroundColor(0xffffff).fontColor(Color.Red)
// Page
@Entry
@Component
struct DialogTest {
dialogController: CustomDialogController = new CustomDialogController({
builder: MyDialog({ title:'Custom Title',cancel: this.onCancel,
confirm: this.onAccept.bind(this)}), // Bind the custom callback to the button.
cancel: this.existApp,
autoCancel: true
})
onAccept(data:string) {
console.info('Callback when the second button is clicked ' + data)
}
}
```
## What should I do if the \<List> component cannot be dragged to the bottom after it has a \<Text> component added?
Applicable to: OpenHarmony SDK 3.2.5.3, stage model of API version 9
The **\<List>** component is a scrollable container. By default, it taks up the entire screen height. When any component with a fixed height takes up part of the screen height, you need to explicitly specify **layoutWeight(1)** for the parent container of the **\<List>** component to take up the remaining height instead of the entire screen height.
## How do I center child components in a grid container?
Applicable to: OpenHarmony SDK 3.2.5.3, stage model of API version 9
By default, child components in a **\<GridContainer>** are horizontally aligned to the left. To center them, perform the following steps:
Nest a **\<Row>** component and set it to **justifyContent(FlexAlign.Center)**. For details, see [Grid Layout](https://gitee.com/openharmony/docs/blob/master/zh-cn/application-dev/ui/ui-ts-layout-grid-container.md).
Example:
```
GridContainer({ sizeType: SizeType.SM, columns: 12 }) {
Row() {
Text('1')
.useSizeType({
sm: { span: 4, offset: 0 },
})
.backgroundColor(0x46F2B4)
}.justifyContent(FlexAlign.Center) // Center child components.
}
```
## How do I obtain the height of the status bar and navigation bar?
Applicable to: OpenHarmony SDK 3.2.5.3, stage model of API version 9
Before the window content is loaded, enable listening for the **systemAvoidAreaChange** event.
Example:
```
// MainAbility.ts
import window from '@ohos.window';
/**
* Set the immersive window and obtain the height of the status bar and navigation bar.
* @param mainWindow Indicates the main window.
*/
async function enterImmersion(mainWindow: window.Window) {
mainWindow.on("systemAvoidAreaChange", (area: window.AvoidArea) => {
AppStorage.SetOrCreate<number>("topHeight", area.topRect.height);
AppStorage.SetOrCreate<number>("bottomHeight", area.bottomRect.height);
})
await mainWindow.setFullScreen(true)
await mainWindow.setSystemBarEnable(["status", "navigation"])
await mainWindow.setSystemBarProperties({
navigationBarColor: "#00000000",
statusBarColor: "#00000000",
navigationBarContentColor: "#FF0000",
statusBarContentColor: "#FF0000"
})
}
export default class MainAbility extends Ability {
// do something
async onWindowStageCreate(windowStage: window.WindowStage) {
let mainWindow = await windowStage.getMainWindow()
await enterImmersion(mainWindow)
windowStage.loadContent('pages/index')
}
// do something
}
```
## How do I execute JavaScript functions in the \<Web> component in eTS code?
Applicable to: OpenHarmony SDK 3.2.3.5, stage model of API version 9
Call the **runJavaScript** API in the **WebController** to asynchronously execute JavaScript scripts. This API uses a callback to return the execution result. Note: **runJavaScript** can only be called after **loadUrl** has been completed. For example, it can be called in **onPageEnd**.
Reference: [Web](https://gitee.com/openharmony/docs/blob/master/en/application-dev/reference/arkui-ts/ts-basic-components-web.md)
## How do I fix misidentification of the pan gesture where container nesting is involved?
Applicable to: OpenHarmony SDK 3.2.5.3, stage model of API version 9
Set the **distance** attribute to **1** for the gesture. By default, this attribute is set to **5**.
# ArkUI (JavaScript) Development
## How do I convert the fields in an XML file into JavaScript objects?
Applicable to: OpenHarmony SDK 3.2.3.5, stage model of API version 9
To convert fields in an XML file into JavaScript objects, call the **convert** API in the **convertxml** module.
Example:
```
import convertxml from '@ohos.convertxml';
// Code snippet
xml =
'<?xml version="1.0" encoding="utf-8"?>' +
'<note importance="high" logged="true">' +
' <title>Happy</title>' +
' <todo>Work</todo>' +
' <todo>Play</todo>' +
'</note>';
let conv = new convertxml.ConvertXML();
// Options for conversion. For details, see the reference document.
let options = {trim : false, declarationKey:"_declaration",
instructionKey : "_instruction", attributesKey : "_attributes",
textKey : "_text", cdataKey:"_cdata", doctypeKey : "_doctype",
commentKey : "_comment", parentKey : "_parent", typeKey : "_type",
nameKey : "_name", elementsKey : "_elements"}
let result:any = conv.convert(xml, options) // Convert fields in the XML file into JavaScript objects.
console.log('Test: ' + JSON.stringify(result))
console.log('Test: ' + result._declaration._attributes.version) // vesion field in XML file
console.log('Test: ' + result._elements[0]._elements[0]._elements[0]._text) // title field in XML file
```
Reference: [XML-to-JavaScript Conversion](https://gitee.com/openharmony/docs/blob/master/en/application-dev/reference/apis/js-apis-convertxml.md)
## What are the differences between JavaScript, TypeScript, and eTS?
Applicable to: OpenHarmony SDK 3.2.3.5, stage model of API version 9
- JavaScript: a lightweight, weakly-typed programming language, most commonly known as the scripting language for web pages.
- TypeScript: a superset of JavaScript, with additions of static typing and more object-oriented APIs, enums, etc.
- eTS: a superset of TypeScript and the programming language for OpenHarmony ArkUI development, which powers UI development through a declarative development paradigm.
## How do I convert the time to the HHMMSS format?
Example:
```
export default class DateTimeUtil{
/**
* HHMMSS
*/
getTime() {
const DATETIME = new Date()
return this.concatTime(DATETIME.getHours(),DATETIME.getMinutes(),DATETIME.getSeconds())
}
/**
* YYYYMMDD
*/
getDate() {
const DATETIME = new Date()
return this.concatDate(DATETIME.getFullYear(),DATETIME.getMonth()+1,DATETIME.getDate())
}
/**
* If the date is less than 10, add a leading zero, for example, **07**.
* @param value Indicates the value.
*/
fill(value:number) {
return (value> 9 ? '' : '0') + value
}
/**
* Concatenate year, month, and date fields.
* @param year
* @param month
* @param date
*/
concatDate(year: number, month: number, date: number){
return `${year}${this.fill(month)}${this.fill(date)}`
}
/**
Concatenate hours, minutes, and seconds fields.
* @param hours
* @param minutes
* @param seconds
*/
concatTime(hours:number,minutes:number,seconds:number){
return `${this.fill(hours)}${this.fill(minutes)}${this.fill(seconds)}`
}
}
```
......@@ -9,10 +9,18 @@ You can use the APIs of this module to configure the concerned information, obta
> 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
## Usage
Before using the **AccessibilityExtensionContext** module, you must define a child class that inherits from **AccessibilityExtensionAbility**.
```js
import AccessibilityExtensionAbility from '@ohos.application.AccessibilityExtensionAbility'
class MainAbility extends AccessibilityExtensionAbility {
onConnect(): void {
console.log("AxExtensionAbility onConnect");
let axContext = this.context;
}
}
```
## FocusDirection
......@@ -203,9 +211,9 @@ this.context.getWindows().then(windows => {
})
```
## AccessibilityExtensionContext.gestureInject
## AccessibilityExtensionContext.injectGesture
gestureInject(gesturePath: GesturePath, listener: Callback\<boolean>): Promise\<boolean
injectGesture(gesturePath: GesturePath, listener: Callback\<boolean>): Promise\<boolean
Injects a gesture.
......
......@@ -162,7 +162,7 @@ In the following API examples, you must first use the [accessibility.getCaptions
on(type: 'enableChange', callback: Callback&lt;boolean&gt;): void;
Enables listening for enabled status changes of captions configuration.
Enables listening for the enabled status changes of captions configuration.
- **Parameters**
......@@ -204,7 +204,7 @@ Enables listening for captions style changes.
off(type: 'enableChange', callback?: Callback&lt;boolean&gt;): void;
Disables listening for enabled status changes of captions configuration.
Disables listening for the enabled status changes of captions configuration.
- **Parameters**
......@@ -269,6 +269,8 @@ constructor(jsonObject)
Implements a constructor.
**System capability**: SystemCapability.BarrierFree.Accessibility.Core
- **Parameters**
| Name| Type| Mandatory| Description|
......@@ -435,14 +437,16 @@ Obtains the captions configuration.
on(type: 'accessibilityStateChange' | 'touchGuideStateChange', callback: Callback&lt;boolean&gt;): void
Enables listening for the accessibility application or touch guide mode status changes.
Enables listening for the enabled status changes of the accessibility application or touch guide mode.
- **Parameters**
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| type | string | Yes| Type of the event to listen for.<br>- **'accessibilityStateChange'** means to listen for enabled status changes of the accessibility application.<br>**System capability**: SystemCapability.BarrierFree.Accessibility.Core<br>- **'touchGuideStateChange'** means to listen for enabled status changes of the touch guide mode.<br>**System capability**: SystemCapability.BarrierFree.Accessibility.Vision|
| callback | Callback&lt;boolean&gt; | Yes| Callback invoked when the enabled status of captions configuration changes.|
| type | string | Yes| Type of the event to listen for.<br>- **'accessibilityStateChange'** means to listen for the enabled status changes of the accessibility application.<br>**System capability**: SystemCapability.BarrierFree.Accessibility.Core<br>- **'touchGuideStateChange'** means to listen for the enabled status changes of the touch guide mode.<br>**System capability**: SystemCapability.BarrierFree.Accessibility.Vision|
| callback | Callback\<boolean> | Yes| Callback invoked when the enabled status of captions configuration changes.|
- **Example**
......@@ -456,13 +460,15 @@ Enables listening for the accessibility application or touch guide mode status c
off(type: 'accessibilityStateChange ' | 'touchGuideStateChange', callback?: Callback&lt;boolean&gt;): void
Disables listening for the accessibility application or touch guide mode status changes.
Disables listening for the enabled status changes of the accessibility application or touch guide mode.
- **Parameters**
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| type | string | No| Type of the event to listen for.<br>- **'accessibilityStateChange'** means to listen for enabled status changes of the accessibility application.<br>**System capability**: SystemCapability.BarrierFree.Accessibility.Core<br>- **'touchGuideStateChange'** means to listen for enabled status changes of the touch guide mode.<br>**System capability**: SystemCapability.BarrierFree.Accessibility.Vision|
| type | string | No| Type of the event to listen for.<br>- **'accessibilityStateChange'** means to listen for the enabled status changes of the accessibility application.<br>**System capability**: SystemCapability.BarrierFree.Accessibility.Core<br>- **'touchGuideStateChange'** means to listen for the enabled status changes of the touch guide mode.<br>**System capability**: SystemCapability.BarrierFree.Accessibility.Vision|
| callback | Callback&lt;boolean&gt; | No| Callback invoked when the enabled status changes.|
- **Example**
......
# Standard NFC Tag
# NFC Tags
The **nfcTag** module provides methods for managing Near-Field Communication (NFC) tags.
......
# Standard NFC Tag Technologies
# NFC Tag Technologies
The **nfctech** module provides methods for reading and writing tags that use different Near-Field Communication (NFC) technologies.
The **nfctech** module provides APIs for reading and writing tags that use different Near-Field Communication (NFC) technologies.
> **NOTE**
>
> The initial APIs of this module are supported since API version 7. Newly added APIs will be marked with a superscript to indicate their earliest API version.
## **Modules to Import**
......@@ -14,7 +13,7 @@ import tag from '@ohos.nfc.tag';
## NfcATag
Provides access to NFC-A (ISO 14443-3A) properties and I/O operations. **NfcATag** inherits from **TagSession**.
Provides access to NFC-A (ISO 14443-3A) properties and I/O operations. This class inherits from **TagSession**.
**TagSession** is the base class of all NFC tag technologies. It provides common interfaces for establishing connections and transferring data. For more details, see [TagSession](js-apis-tagSession.md).
......@@ -74,7 +73,7 @@ console.log("atqa:" +atqa);
## NfcBTag
Provides access to NFC-B (ISO 14443-3B) properties and I/O operations. **NfcBTag** inherits from **TagSession**.
Provides access to NFC-B (ISO 14443-3B) properties and I/O operations. This class inherits from **TagSession**.
**TagSession** is the base class of all NFC tag technologies. It provides common interfaces for establishing connections and transferring data. For more details, see [TagSession](js-apis-tagSession.md).
......@@ -110,7 +109,7 @@ console.log("appData:" +appData);
getRespProtocol(): number[]
Obtains protocol information of this NFC-B tag.
Obtains the protocol information of this NFC-B tag.
**Required permissions**: ohos.permission.NFC_TAG
......@@ -134,7 +133,7 @@ console.log("appData:" +protocol);
## NfcFTag
Provides access to NFC-F(JIS 6319-4) properties and I/O operations. **NfcFTag** inherits from **TagSession**.
Provides access to NFC-F (JIS 6319-4) properties and I/O operations. This class inherits from **TagSession**.
**TagSession** is the base class of all NFC tag technologies. It provides common interfaces for establishing connections and transferring data. For more details, see [TagSession](js-apis-tagSession.md).
......@@ -144,7 +143,7 @@ The following describes the unique interfaces of **NfcFTag**.
getSystemCode(): number[]
Obtains the system code from the tag instance.
Obtains the system code from this NFC-F tag.
**Required permissions**: ohos.permission.NFC_TAG
......@@ -170,7 +169,7 @@ console.log("systemCode:" +systemCode);
getPmm(): number[]
Obtains the PMm (consisting of the IC code and manufacturer parameters) information from the tag instance.
Obtains the PMm (consisting of the IC code and manufacturer parameters) information from this NFC-F tag.
**Required permissions**: ohos.permission.NFC_TAG
......@@ -194,7 +193,7 @@ console.log("pmm:" +pmm);
## NfcVTag
Provides access to NFC-V (ISO 15693) properties and I/O operations. **NfcVTag** inherits from **TagSession**.
Provides access to NFC-V (ISO 15693) properties and I/O operations. This class inherits from **TagSession**.
**TagSession** is the base class of all NFC tag technologies. It provides common interfaces for establishing connections and transferring data. For more details, see [TagSession](js-apis-tagSession.md).
......@@ -204,7 +203,7 @@ The following describes the unique interfaces of **NfcVTag**.
getResponseFlags(): number
Obtains the response flags from the tag instance.
Obtains the response flags from this NFC-V tag.
**Required permissions**: ohos.permission.NFC_TAG
......@@ -230,7 +229,7 @@ console.log("flags:" +flags);
getDsfId(): number
Obtains the data storage format identifier (DSFID) from the tag instance.
Obtains the data storage format identifier (DSFID) from this NFC-V tag.
**Required permissions**: ohos.permission.NFC_TAG
......@@ -254,7 +253,7 @@ console.log("dsfId:" +dsfId);
## IsoDepTag<sup>9+</sup>
Provides access to ISO-DEP (ISO 14443-4) properties and I/O operations. **IsoDepTag** inherits from **TagSession**.
Provides access to ISO-DEP (ISO 14443-4) properties and I/O operations. This class inherits from **TagSession**.
**TagSession** is the base class of all NFC tag technologies. It provides common interfaces for establishing connections and transferring data. For more details, see [TagSession](js-apis-tagSession.md).
......@@ -343,7 +342,7 @@ tag.getIsoDepTag(taginfo).isExtendedApduSupported().then(function (has) {
isExtendedApduSupported(callback: AsyncCallback\<boolean>): void
Checks whether an extended application protocol data unit (APDU) is supported. This API uses an asynchronous callback to return the result.
Checks whether an extended APDU is supported. This API uses an asynchronous callback to return the result.
**Required permissions**: ohos.permission.NFC_TAG
......@@ -367,7 +366,7 @@ tag.getIsoDepTag(taginfo).isExtendedApduSupported(function (error, has) {
## NdefTag<sup>9+</sup>
Provides access to the tags in the NFC Data Exchange Format (NDEF). **NdefTag** inherits from **TagSession**.
Provides access to the tags in the NFC Data Exchange Format (NDEF). This class inherits from **TagSession**.
**TagSession** is the base class of all NFC tag technologies. It provides common interfaces for establishing connections and transferring data. For more details, see [TagSession](js-apis-tagSession.md).
......@@ -596,7 +595,7 @@ Reads the NDEF message from this tag. This API uses a promise to return the resu
| **Type**| **Description** |
| ------------------ | --------------------------|
| Promise\<[NdefMessage](#ndefmessage9)> | Promise used to return the message read.|
| Promise\<[NdefMessage](#ndefmessage9)> | Promise used to return the NDEF message read.|
**Example**
......@@ -641,7 +640,7 @@ tag.NdefTag(taginfo).readNdef(function (error, ndefMessage) {
writeNdef(msg: NdefMessage): Promise\<number>;
Write an NDEF message to this tag. This API uses a promise to return the result.
Writes an NDEF message to this tag. This API uses a promise to return the result.
**Required permissions**: ohos.permission.NFC_TAG
......@@ -674,7 +673,7 @@ NdefTag.writeNdef(msg).then(function (netHandle) {
writeNdef(msg: NdefMessage, callback: AsyncCallback\<number>): void
Write an NDEF message to this tag. This API uses an asynchronous callback to return the result.
Writes an NDEF message to this tag. This API uses an asynchronous callback to return the result.
**Required permissions**: ohos.permission.NFC_TAG
......@@ -728,7 +727,7 @@ tag.NdefTag(taginfo).canSetReadOnly().then(function (has) {
### NdefTag.canSetReadOnly<sup>9+</sup>
canSetReadOnly()(callback: AsyncCallback&lt;boolean&gt;): void;
canSetReadOnly(callback: AsyncCallback&lt;boolean&gt;): void;
Checks whether this NDEF tag can be set to read-only. This API uses an asynchronous callback to return the result.
......@@ -813,7 +812,7 @@ tag.NdefTag(taginfo).setReadOnly(function (error, errcode) {
getNdefTagTypeString(type: [NfcForumType](#nfcforumtype9)): string
Converts the NFC Forum Type to a byte array defined in the NFC Forum.
Converts an NFC Forum Type to a byte array defined in the NFC Forum.
**Required permissions**: ohos.permission.NFC_TAG
......@@ -852,7 +851,7 @@ let ndefTypeString= tag.NdefTag(taginfo).getNdefTagTypeString(type);
## MifareClassicTag <sup>9+</sup>
Provides access to MIFARE Classic properties and I/O operations. **MifareClassicTag** inherits from **TagSession**.
Provides access to MIFARE Classic properties and I/O operations. This class inherits from **TagSession**.
**TagSession** is the base class of all NFC tag technologies. It provides common interfaces for establishing connections and transferring data. For more details, see [TagSession](js-apis-tagSession.md).
......@@ -928,7 +927,7 @@ tag.MifareClassicTag(taginfo).authenticateSector(sectorIndex, key, function (err
readSingleBlock(blockIndex: number): Promise\<string>
Reads a block on the tag. The size of a block is 16 bytes. This API uses a promise to return the result.
Reads a block (16 bytes) on the tag. This API uses a promise to return the result.
**Required permissions**: ohos.permission.NFC_TAG
......@@ -962,7 +961,7 @@ tag.MifareClassicTag(taginfo).readSingleBlock(blockIndex).then(function (data){
readSingleBlock(blockIndex: number, callback: AsyncCallback\<string>): void
Reads a block on the tag. The size of a block is 16 bytes. This API uses an asynchronous callback to return the result.
Reads a block (16 bytes) on the tag. This API uses an asynchronous callback to return the result.
**Required permissions**: ohos.permission.NFC_TAG
......@@ -992,7 +991,7 @@ tag.MifareClassicTag(taginfo).readSingleBlock(blockIndex, function (error, data)
writeSingleBlock(blockIndex: number, data: string): Promise\<number>
Writes data to a block on the tag. The size of a block is 16 bytes. This API uses a promise to return the result.
Writes data to a block on the tag. This API uses a promise to return the result.
**Required permissions**: ohos.permission.NFC_TAG
......@@ -1027,7 +1026,7 @@ tag.MifareClassicTag(taginfo).writeSingleBlock(blockIndex, data).then(function (
writeSingleBlock(blockIndex: number, data: string, callback: AsyncCallback\<number>): void
Writes data to a block on the tag. The size of a block is 16 bytes. This API uses an asynchronous callback to return the result.
Writes data to a block on the tag. This API uses an asynchronous callback to return the result.
**Required permissions**: ohos.permission.NFC_TAG
......@@ -1427,10 +1426,10 @@ let size = tag.MifareClassicTag(taginfo).getTagSize();
| **Name**| **Value**| **Description**|
| -------- | -------- | -------- |
| MC_SIZE_MINI | 320 | Each tag has five sectors, and each sector has four blocks.|
| MC_SIZE_1K | 1024 | Each tag has 16 sectors, and each sector has four blocks.|
| MC_SIZE_2K | 2048 | Each tag has 32 sectors, and each sector has four blocks.|
| MC_SIZE_4K | 4096 | Each tag has 40 sectors, and each sector has four blocks.|
| MC_SIZE_MINI | 320 | Each tag has 5 sectors, and each sector has 4 blocks.|
| MC_SIZE_1K | 1024 | Each tag has 16 sectors, and each sector has 4 blocks.|
| MC_SIZE_2K | 2048 | Each tag has 32 sectors, and each sector has 4 blocks.|
| MC_SIZE_4K | 4096 | Each tag has 40 sectors, and each sector has 4 blocks.|
### MifareClassicTag.isEmulatedTag<sup>9+</sup>
......@@ -1521,7 +1520,7 @@ let index = tag.MifareClassicTag(taginfo).getSectorIndex(blockIndex);
## MifareUltralightTag<sup>9+</sup>
Provides access to MIFARE Ultralight properties and I/O operations. **MifareUltralightTag** inherits from **TagSession**.
Provides access to MIFARE Ultralight properties and I/O operations. This class inherits from **TagSession**.
**TagSession** is the base class of all NFC tag technologies. It provides common interfaces for establishing connections and transferring data. For more details, see [TagSession](js-apis-tagSession.md).
......@@ -1531,7 +1530,7 @@ The following describes the unique interfaces of **MifareUltralightTag**.
readMultiplePages(pageIndex: number): Promise\<string>
Reads multiple pages. The size of each page is 4 bytes. This API uses a promise to return the result.
Reads multiple pages (4 bytes per page). This API uses a promise to return the result.
**Required permissions**: ohos.permission.NFC_TAG
......@@ -1565,7 +1564,7 @@ tag.MifareUltralightTag(taginfo).readMultiplePages(pageIndex).then(function (dat
readMultiplePages(pageIndex: number, callback: AsyncCallback\<string>): void
Reads multiple pages. The size of each page is 4 bytes. This API uses an asynchronous callback to return the result.
Reads multiple pages (4 bytes per page). This API uses an asynchronous callback to return the result.
**Required permissions**: ohos.permission.NFC_TAG
......@@ -1594,7 +1593,7 @@ tag.MifareUltralightTag(taginfo).readMultiplePages(pageIndex, function (error, d
writeSinglePages(pageIndex: number, data: string): Promise\<number>
Writes a page of data. The size of each page is 4 bytes. This API uses a promise to return the result.
Writes a page of data. This API uses a promise to return the result.
**Required permissions**: ohos.permission.NFC_TAG
......@@ -1628,7 +1627,7 @@ tag.MifareUltralightTag(taginfo).writeSinglePages(pageIndex, data).then(function
writeSinglePages(pageIndex: number, data: string, callback: AsyncCallback\<number>): void
Writes a page of data. The size of each page is 4 bytes. This API uses an asynchronous callback to return the result.
Writes a page of data. This API uses an asynchronous callback to return the result.
**Required permissions**: ohos.permission.NFC_TAG
......@@ -1658,7 +1657,7 @@ tag.MifareUltralightTag(taginfo).writeSinglePages(pageIndex, data, function (err
getType(): MifareUltralightType
Obtains the MIFARE Ultralight tag type, in bytes. For details, see [MifareUltralightType](#mifareultralighttype9).
Obtains the MIFARE Ultralight tag type, in bytes.
**Required permissions**: ohos.permission.NFC_TAG
......@@ -1689,7 +1688,7 @@ let type = tag.MifareUltralightType(taginfo).getType();
## NdefFormatableTag<sup>9+</sup>
Provides methods for operating NDEF formattable tags. **NdefFormatableTag** inherits from **TagSession**.
Provides APIs for operating NDEF formattable tags. This class inherits from **TagSession**.
**TagSession** is the base class of all NFC tag technologies. It provides common interfaces for establishing connections and transferring data. For more details, see [TagSession](js-apis-tagSession.md).
......@@ -1709,7 +1708,7 @@ Formats this tag as an NDEF tag, and writes an NDEF message to the tag. This API
| Name | Type | Mandatory| Description |
| -------- | ----------------------- | ---- | -------------------------------------- |
| message | [NdefMessage](#ndefmessage9) | Yes | NDEF message to write when the formatting is successful. If it is **null**, the tag is formatted only and no data will be written.|
| message | [NdefMessage](#ndefmessage9) | Yes | NDEF message to write when the formatting is successful. If this parameter is **null**, the tag is formatted only (no data will be written).|
**Return value**
......@@ -1742,8 +1741,8 @@ Formats this tag as an NDEF tag, and writes an NDEF message to the tag. This API
| Name | Type | Mandatory| Description |
| -------- | ----------------------- | ---- | -------------------------------------- |
| message | [NdefMessage](#ndefmessage9) | Yes | NDEF message to write when the formatting is successful. If it is **null**, the tag is formatted only and no data will be written.|
| callback: AsyncCallback\<number> | Callback invoked to return the result.|
| message | [NdefMessage](#ndefmessage9) | Yes | NDEF message to write when the formatting is successful. If this parameter is **null**, the tag is formatted only.|
| callback | AsyncCallback\<number> |Yes|Callback invoked to return the result.|
**Example**
......@@ -1771,7 +1770,7 @@ Formats this tag as an NDEF tag, writes an NDEF message to the NDEF tag, and the
| Name | Type | Mandatory| Description |
| -------- | ----------------------- | ---- | -------------------------------------- |
| message | [NdefMessage](#ndefmessage9) | Yes | NDEF message to write when the formatting is successful. If it is **null**, the tag is formatted only and no data will be written.|
| message | [NdefMessage](#ndefmessage9) | Yes | NDEF message to write when the formatting is successful. If this parameter is **null**, the tag is formatted only (no data will be written).|
**Return value**
......@@ -1804,8 +1803,8 @@ Formats this tag as an NDEF tag, writes an NDEF message to the NDEF tag, and the
| Name | Type | Mandatory| Description |
| -------- | ----------------------- | ---- | -------------------------------------- |
| message | [NdefMessage](#ndefmessage9) | Yes | NDEF message to write when the formatting is successful. If it is **null**, the tag is formatted only and no data will be written.|
| callback: AsyncCallback\<number> | Callback invoked to return the result.|
| message | [NdefMessage](#ndefmessage9) | Yes | NDEF message to write when the formatting is successful. If this parameter is **null**, the tag is formatted only.|
| callback | AsyncCallback\<number> |Yes|Callback invoked to return the result.|
**Example**
......
......@@ -24,9 +24,10 @@ Checks whether the screen is locked. This API uses an asynchronous callback to r
**System capability**: SystemCapability.MiscServices.ScreenLock
**Parameters**
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| callback | AsyncCallback&lt;boolean&gt; | Yes| Returns **true** if the screen is locked; returns **false** otherwise.|
| callback | AsyncCallback&lt;boolean&gt; | Yes| Callback used to return the result. Returns **true** if the screen is locked; returns **false** otherwise.|
**Example**
......@@ -50,6 +51,7 @@ Checks whether the screen is locked. This API uses a promise to return the resul
**System capability**: SystemCapability.MiscServices.ScreenLock
**Return value**
| Type| Description|
| -------- | -------- |
| Promise&lt;boolean&gt; | Promise used to return the result.|
......@@ -77,9 +79,10 @@ Checks whether a device is in secure mode. This API uses an asynchronous callbac
**Parameters**
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| callback | AsyncCallback&lt;boolean&gt; | Yes| Returns **true** if the device is in secure mode; returns **false** otherwise.|
| callback | AsyncCallback&lt;boolean&gt; | Yes| Callback used to return the result. Returns **true** if the device is in secure mode; returns **false** otherwise.|
**Example**
......@@ -103,6 +106,7 @@ Checks whether a device is in secure mode. This API uses a promise to return the
**System capability**: SystemCapability.MiscServices.ScreenLock
**Return value**
| Type| Description|
| -------- | -------- |
| Promise&lt;boolean&gt; | Promise used to return the result.|
......@@ -130,9 +134,10 @@ Unlocks the screen. This API uses an asynchronous callback to return the result.
**Parameters**
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| callback | AsyncCallback&lt;void&gt; | Yes| Callback used to return the result. If the operation failed, an error message is returned.|
| callback | AsyncCallback&lt;void&gt; | Yes| Callback used to return the result. If the operation fails, an error message is returned.|
**Example**
......@@ -156,6 +161,7 @@ Unlocks the screen. This API uses a promise to return the result.
**System capability**: SystemCapability.MiscServices.ScreenLock
**Return value**
| Type| Description|
| -------- | -------- |
| Promise&lt;void&gt; | Promise used to return the result.|
......@@ -173,7 +179,7 @@ Unlocks the screen. This API uses a promise to return the result.
## screenlock.lockScreen<sup>9+</sup>
lockScreen(callback: AsyncCallback&lt;void&gt;): void
lockScreen(callback: AsyncCallback&lt;boolean&gt;): void
Locks the screen. This API uses an asynchronous callback to return the result.
......@@ -184,9 +190,10 @@ Locks the screen. This API uses an asynchronous callback to return the result.
**System API**: This is a system API and cannot be called by third-party applications.
**Parameters**
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| callback | AsyncCallback&lt;void&gt; | Yes| Callback used to return the result. If the operation failed, an error message is returned.|
| callback | AsyncCallback&lt;void&gt; | Yes| Callback used to return the result. If the operation fails, an error message is returned.|
**Example**
......@@ -202,7 +209,7 @@ Locks the screen. This API uses an asynchronous callback to return the result.
## screenlock.lockScreen<sup>9+</sup>
lockScreen(): Promise&lt;void&gt;
lockScreen(): Promise&lt;boolean&gt;
Locks the screen. This API uses a promise to return the result.
......@@ -238,6 +245,7 @@ Subscribes to screen lock status changes.
**System API**: This is a system API and cannot be called by third-party applications.
**Parameters**
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| type | string | Yes| Event type.<br>- **"beginWakeUp"**: Wakeup starts.<br>- **"endWakeUp"**: Wakeup ends.<br>- **"beginScreenOn"**: Screen turn-on starts.<br>- **"endScreenOn"**: Screen turn-on ends.<br>- **"beginScreenOff"**: Screen turn-off starts.<br>- **"endScreenOff"**: Screen turn-off ends.<br>- **"unlockScreen"**: The screen is unlocked.<br>- **"beginExitAnimation"**: Animation starts to exit.|
......@@ -262,6 +270,7 @@ Subscribes to screen lock status changes.
**System API**: This is a system API and cannot be called by third-party applications.
**Parameters**
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| type | string | Yes| Event type.<br>- **"beginSleep"**: The screen enters sleep mode.<br>- **"endSleep"**: The screen exits sleep mode.<br>- **"changeUser"**: The user is switched.|
......@@ -285,6 +294,7 @@ Subscribes to screen lock status changes.
**System API**: This is a system API and cannot be called by third-party applications.
**Parameters**
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| type | string | Yes| Event type.<br>- **"screenlockEnabled"**: Screen lock is enabled.|
......@@ -310,6 +320,7 @@ Unsubscribes from screen lock status changes.
**System API**: This is a system API and cannot be called by third-party applications.
**Parameters**
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| type | string | Yes| Event type.<br>- **"beginWakeUp"**: Wakeup starts.<br>- **"endWakeUp"**: Wakeup ends.<br>- **"beginScreenOn"**: Screen turn-on starts.<br>- **"endScreenOn"**: Screen turn-on ends.<br>- **"beginScreenOff"**: Screen turn-off starts.<br>- **"endScreenOff"**: Screen turn-off ends.<br>- **"unlockScreen"**: The screen is unlocked.<br>- **"beginExitAnimation"**: Animation starts to exit.<br>- **"screenlockEnabled"**: Screen lock is enabled.<br>- **"beginSleep"**: The screen enters sleep mode.<br>- **"endSleep"**: The screen exits sleep mode.<br>- **"changeUser"**: The user is switched.|
......@@ -334,6 +345,7 @@ Sends an event to the screen lock service. This API uses an asynchronous callbac
**System API**: This is a system API and cannot be called by third-party applications.
**Parameters**
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| event | String | Yes| Event type.<br>- **"unlockScreenResult"**: Screen unlock result.<br>- **"screenDrawDone"**: Screen drawing is complete.|
......@@ -359,12 +371,14 @@ Sends an event to the screen lock service. This API uses a promise to return the
**System API**: This is a system API and cannot be called by third-party applications.
**Parameters**
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| event | String | Yes| Event type.<br>- **"unlockScreenResult"**: Screen unlock result.<br>- **"screenDrawDone"**: Screen drawing is complete.|
| parameter | number | Yes| Screen unlock status.<br>- **0**: The unlock is successful.<br>- **1**: The unlock failed.<br>- **2**: The unlock was canceled.|
**Return value**
| Type| Description|
| -------- | -------- |
| Promise\<boolean\> | Promise used to return the result.|
......
# Standard NFC Tag Session
# NFC Tag Session
The **tagSession** module provides common APIs for establishing connections and transferring data.
> **NOTE**
>
> **NOTE**<br>
> The initial APIs of this module are supported since API version 7. Newly added APIs will be marked with a superscript to indicate their earliest API version.
## **Modules to Import**
......@@ -18,7 +17,7 @@ Provides common APIs for establishing connections and transferring data. **tagSe
A child class instance is required to access the following interfaces. You can use **get**XX**Tag()** to obtain a child class instance.
The specific method varies with the NFC tag technology in use. For details, see [nfcTag](js-apis-nfcTag.md).
The specific API varies with the NFC tag technology in use. For details, see [NFC Tags](js-apis-nfcTag.md).
### tagSession.connectTag
......@@ -26,7 +25,7 @@ connectTag(): boolean;
Connects to this tag.
Call this method to set up a connection before reading data from or writing data to a tag.
Call this API to set up a connection before reading data from or writing data to a tag.
**Required permissions**: ohos.permission.NFC_TAG
......@@ -95,7 +94,7 @@ Checks whether the tag is connected.
```js
import tag from '@ohos.nfc.tag';
// tagInfo is an Object given by nfc service when tag is dispatched.
// tagInfo is an object given by the NFC service when a tag is dispatched.
let isTagConnected = tag.getXXXTag(taginfo).isTagConnected();
console.log("isTagConnected:" +isTagConnected);
```
......
......@@ -8,12 +8,13 @@ The system executes Work Scheduler tasks at an appropriate time, subject to the
>
> - 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.
> - For details about the constraints on the Work Scheduler usage, see [Work Scheduler Overview](../../task-management/work-scheduler-overview.md).
## Modules to Import
```js
import workScheduler from '@ohos.workScheduler'
import workScheduler from '@ohos.workScheduler';
```
## workScheduler.startWork
......@@ -53,7 +54,7 @@ Instructs the **WorkSchedulerService** to add the specified task to the executio
}
}
var res = workScheduler.startWork(workInfo);
console.info("workschedulerLog res:" + res);
console.info(`workschedulerLog res: ${res}`);
```
## workScheduler.stopWork
......@@ -94,7 +95,7 @@ Instructs the **WorkSchedulerService** to stop the specified task.
}
}
var res = workScheduler.stopWork(workInfo, false);
console.info("workschedulerLog res:" + res);
console.info(`workschedulerLog res: ${res}`);
```
## workScheduler.getWorkStatus
......@@ -116,10 +117,10 @@ Obtains the latest task status. This API uses an asynchronous callback to return
```js
workScheduler.getWorkStatus(50, (err, res) => {
if (err) {
console.info('workschedulerLog getWorkStatus failed, because:' + err.code);
console.info(`workschedulerLog getWorkStatus failed, because: ${err.code}`);
} else {
for (let item in res) {
console.info('workschedulerLog getWorkStatus success,' + item + ' is:' + res[item]);
console.info(`workschedulerLog getWorkStatus success, ${item} is: ${res[item]}`);
}
}
});
......@@ -149,10 +150,10 @@ Obtains the latest task status. This API uses a promise to return the result.
```js
workScheduler.getWorkStatus(50).then((res) => {
for (let item in res) {
console.info('workschedulerLog getWorkStatus success,' + item + ' is:' + res[item]);
console.info(`workschedulerLog getWorkStatus success, ${item} is: ${res[item]}`);
}
}).catch((err) => {
console.info('workschedulerLog getWorkStatus failed, because:' + err.code);
console.info(`workschedulerLog getWorkStatus failed, because: ${err.code}`);
})
```
......@@ -167,7 +168,7 @@ Obtains all tasks associated with this application. This API uses an asynchronou
| Name | Type | Mandatory | Description |
| -------- | -------------------- | ---- | ------------------------------- |
| callback | AsyncCallback\<void> | Yes | Callback used to return all tasks associated with the current application.|
| callback | AsyncCallback\<void> | Yes | Callback used to return all tasks associated with the current application. |
**Return value**
......@@ -180,9 +181,9 @@ Obtains all tasks associated with this application. This API uses an asynchronou
```js
workScheduler.obtainAllWorks((err, res) =>{
if (err) {
console.info('workschedulerLog obtainAllWorks failed, because:' + err.code);
console.info(`workschedulerLog obtainAllWorks failed, because: ${err.code}`);
} else {
console.info('workschedulerLog obtainAllWorks success, data is:' + JSON.stringify(res));
console.info(`workschedulerLog obtainAllWorks success, data is: ${JSON.stringify(res)}`);
}
});
```
......@@ -198,15 +199,15 @@ Obtains all tasks associated with this application. This API uses a promise to r
| Type | Description |
| -------------------------------------- | ------------------------------ |
| Promise<Array\<[WorkInfo](#workinfo)>> | Promise used to return all tasks associated with the current application.|
| Promise<Array\<[WorkInfo](#workinfo)>> | Promise used to return all tasks associated with the current application. |
**Example**
```js
workScheduler.obtainAllWorks().then((res) => {
console.info('workschedulerLog obtainAllWorks success, data is:' + JSON.stringify(res));
console.info(`workschedulerLog obtainAllWorks success, data is: ${JSON.stringify(res)}`);
}).catch((err) => {
console.info('workschedulerLog obtainAllWorks failed, because:' + err.code);
console.info(`workschedulerLog obtainAllWorks failed, because: ${err.code}`);
})
```
......@@ -221,7 +222,7 @@ Stops and cancels all tasks associated with the current application.
```js
let res = workScheduler.stopAndClearWorks();
console.info("workschedulerLog res:" + res);
console.info(`workschedulerLog res: ${res}`);
```
## workScheduler.isLastWorkTimeOut
......@@ -249,9 +250,9 @@ Checks whether the last execution of the specified task timed out. This API uses
```js
workScheduler.isLastWorkTimeOut(500, (err, res) =>{
if (err) {
console.info('workschedulerLog isLastWorkTimeOut failed, because:' + err.code);
console.info(`workschedulerLog isLastWorkTimeOut failed, because: ${err.code}`);
} else {
console.info('workschedulerLog isLastWorkTimeOut success, data is:' + res);
console.info(`workschedulerLog isLastWorkTimeOut success, data is: ${res}`);
}
});
```
......@@ -280,10 +281,10 @@ Checks whether the last execution of the specified task timed out. This API uses
```js
workScheduler.isLastWorkTimeOut(500)
.then(res => {
console.info('workschedulerLog isLastWorkTimeOut success, data is:' + res);
console.info(`workschedulerLog isLastWorkTimeOut success, data is: ${res}`);
})
.catch(err => {
console.info('workschedulerLog isLastWorkTimeOut failed, because:' + err.code);
console.info(`workschedulerLog isLastWorkTimeOut failed, because: ${err.code}`);
});
```
......
......@@ -20,23 +20,23 @@ Not supported
In addition to the [universal attributes](../arkui-js/js-components-common-attributes.md), the following attributes are supported.
| Name | Type | Default Value | Mandatory| Description |
| -------------------------------- | ----------------------- | --------- | ---- | ------------------------------------------------------------ |
| type | string | text<br>| No | Type of the input component. Available values include **text**, **email**, **date**, **time**, **number**, **password**, **button**, **checkbox**, and **radio**.<br>The **text**, **email**, **date**, **time**, **number**, and **password** types can be dynamically switched and modified.<br>The **button**, **checkbox**, and **radio** types cannot be dynamically modified. <br>- **button**: a button that can be clicked.<br>- **checkbox**: a check box.<br>- **radio**: a radio button that allows users to select one from multiple others with the same name.<br>- **text**: a single-line text field.<br>- **email**: a field used for an email address.<br>- **date**: date component, including the year, month, and day, but excluding time.<br>- **time**: time component, without the time zone.<br>- **number**: field for entering digits.<br>- **password**: password field, in which characters will be shielded.|
| checked | boolean | false | No | Whether the **\<input>** component is selected. This attribute is valid only when **type** is set to **checkbox** or **radio**. |
| name | string | - | No | Name of the **\<input>** component.<br>This attribute is mandatory when **type** is set to **radio**. |
| value | string | - | No | Value of the **\<input>** component. When **type** is **radio**, this attribute is mandatory and the value must be unique for radio buttons with the same name.|
| placeholder | string | - | No | Content of the hint text. This attribute is available only when the component type is set to **text**, **email**, **date**, **time**, **number**, or **password**.|
| maxlength | number | - | No | Maximum number of characters that can be entered in the input box. The empty value indicates no limit.|
| enterkeytype | string | default | No | Type of the **Enter** key on the soft keyboard. The value cannot be dynamically updated.<br>Available values include:<br>- default<br>- next<br>- go<br>- done<br>- send<br>- search<br>Except for the **next** type, clicking the Enter key hides the soft keyboard.|
| headericon | string | - | No | Icon resource path before text input. This icon does not support click events and is unavailable for **button**, **checkbox**, and **radio** types. The supported icon image formats are JPG, PNG, and SVG.|
| showcounter<sup>5+</sup> | boolean | false | No | Whether to display the character counter for an input box. This attribute takes effect only when **maxlength** is set. |
| menuoptions<sup>5+</sup> | Array&lt;MeunOption&gt; | - | No | Menu options displayed after users click the **More** button. |
| autofocus<sup>6+</sup> | boolean | false | No | Whether to automatically obtain focus.<br>This attribute setting does not take effect on the application home page. You can enable a text box on the home page to automatically obtain focus, by delaying the **focus** method call (for about 100–500 ms) in **onActive**.|
| selectedstart<sup>6+</sup> | number | -1 | No | Start position for text selection. |
| selectedend<sup>6+</sup> | number | -1 | No | End position for text selection. |
| softkeyboardenabled<sup>6+</sup> | boolean | true | No | Whether to display the soft keyboard during editing. |
| showpasswordicon<sup>6+</sup> | boolean | true | No | Whether to display the icon at the end of the password text box. This attribute is available only when **type** is set to **password**. |
| Name | Type | Default Value | Mandatory | Description |
| -------------------------------- | ----------------------- | --------- | ---- | ---------------------------------------- |
| type | string | text<br>| No | Type of the input component. Available values include **text**, **email**, **date**, **time**, **number**, **password**, **button**, **checkbox**, and **radio**.<br>The **text**, **email**, **date**, **time**, **number**, and **password** types can be dynamically switched and modified.<br>The **button**, **checkbox**, and **radio** types cannot be dynamically modified. <br>- **button**: a button that can be clicked.<br>- **checkbox**: a check box.<br>- **radio**: a radio button that allows users to select one from multiple others with the same name.<br>- **text**: a single-line text field.<br>- **email**: a field used for an email address.<br>- **date**: date component, including the year, month, and day, but excluding time.<br>- **time**: time component, without the time zone.<br>- **number**: field for entering digits.<br>- **password**: password field, in which characters will be shielded.|
| checked | boolean | false | No | Whether the **\<input>** component is selected. This attribute is valid only when **type** is set to **checkbox** or **radio**. |
| name | string | - | No | Name of the **\<input>** component.<br>This attribute is mandatory when **type** is set to **radio**. |
| value | string | - | No | Value of the **\<input>** component. When **type** is **radio**, this attribute is mandatory and the value must be unique for radio buttons with the same name.|
| placeholder | string | - | No | Content of the hint text. This attribute is available only when the component type is set to **text** \|email\|date\|time\|number\|**password**.|
| maxlength | number | - | No | Maximum number of characters that can be entered in the input box. The empty value indicates no limit. |
| enterkeytype | string | default | No | Type of the **Enter** key on the soft keyboard. The value cannot be dynamically updated.<br>Available values include:<br>- default<br>- next<br>- go<br>- done<br>- send<br>- search<br>Except for the **next** type, clicking the Enter key hides the soft keyboard.|
| headericon | string | - | No | Icon resource path before text input. This icon does not support click events and is unavailable for **button**, **checkbox**, and **radio** types. The supported icon image formats are JPG, PNG, and SVG.|
| showcounter<sup>5+</sup> | boolean | false | No | Whether to display the character counter for an input box. This attribute takes effect only when **maxlength** is set. |
| menuoptions<sup>5+</sup> | Array&lt;MeunOption&gt; | - | No | Menu options displayed after users click the **More** button. |
| autofocus<sup>6+</sup> | boolean | false | No | Whether to automatically obtain focus.<br>This attribute setting does not take effect on the application home page. You can enable a text box on the home page to automatically obtain focus, by delaying the **focus** method call (for about 100–500 ms) in **onActive**.|
| selectedstart<sup>6+</sup> | number | -1 | No | Start position for text selection. |
| selectedend<sup>6+</sup> | number | -1 | No | End position for text selection. |
| softkeyboardenabled<sup>6+</sup> | boolean | true | No | Whether to display the soft keyboard during editing. |
| showpasswordicon<sup>6+</sup> | boolean | true | No | Whether to display the icon at the end of the password text box. This attribute is available only when **type** is set to **password**. |
**Table 1** MenuOption<sup>5+</sup>
......@@ -50,14 +50,14 @@ In addition to the [universal attributes](../arkui-js/js-components-common-attri
In addition to the [universal styles](../arkui-js/js-components-common-styles.md), the following styles are supported.
| Name | Type | Default Value | Mandatory| Description |
| ------------------------ | -------------------------- | ---------- | ---- | ------------------------------------------------------------ |
| color | &lt;color&gt; | \#e6000000 | No | Font color of the single-line text box or button. |
| font-size | &lt;length&gt; | 16px | No | Font size of the single-line text box or button. |
| allow-scale | boolean | true | No | Whether the font size changes with the system's font size settings.<br>If the **config-changes** tag of **fontSize** is configured for abilities in the **config.json** file, the setting takes effect without application restart.|
| placeholder-color | &lt;color&gt; | \#99000000 | No | Color of the hint text in the single-line text box. This attribute is available when **type** is set to **text**, **email**, **date**, **time**, **number**, or **password**.|
| font-weight | number&nbsp;\|&nbsp;string | normal | No | Font weight of the single-line text box or button. For details, see **font-weight** of the [**\<text>** component](../arkui-js/js-components-basic-text.md).|
| caret-color<sup>6+</sup> | &lt;color&gt; | - | No | Color of the input cursor. |
| Name | Type | Default Value | Mandatory | Description |
| ------------------------ | -------------------------- | ---------- | ---- | ---------------------------------------- |
| color | &lt;color&gt; | \#e6000000 | No | Font color of the single-line text box or button. |
| font-size | &lt;length&gt; | 16px | No | Font size of the single-line text box or button. |
| allow-scale | boolean | true | No | Whether the font size changes with the system's font size settings.<br>If the **config-changes** tag of **fontSize** is configured for abilities in the **config.json** file, the setting takes effect without application restart.|
| placeholder-color | &lt;color&gt; | \#99000000 | No | Color of the hint text in the single-line text box. This attribute is available only when **type** is set to **text**, **email**, **date**, **time**, **number**, or **password**. |
| font-weight | number \| string | normal | No | Font weight of the single-line text box or button. For details, see **font-weight** of the [**\<text>**](../arkui-js/js-components-basic-text.md) component. |
| caret-color<sup>6+</sup> | &lt;color&gt; | - | No | Color of the caret. |
## Events
......@@ -65,30 +65,32 @@ In addition to the [universal styles](../arkui-js/js-components-common-styles.md
In addition to the [universal events](../arkui-js/js-components-common-events.md), the following events are supported.
- When **type** is set to **text**, **email**, **date**, **time**, **number**, or **password**, the following events are supported.
| Name | Parameter | Description |
| Name | Parameter | Description |
| ------------------------- | ---------------------------------------- | ---------------------------------------- |
| change | {<br>&nbsp;value: inputValue<br>&nbsp;} | Triggered when the content entered in the input box changes. The most recent content entered by the user is returned.<br>If you change the **value** attribute directly, this event will not be triggered.|
| enterkeyclick | {<br>&nbsp;value: enterKey<br>&nbsp;} | Triggered when the **Enter** key on the soft keyboard is clicked. The type of the **Enter** key is returned, which is of the number type. Available values are as follows:<br>- **2**: returned if **enterkeytype** is **go**.<br>- **3**: returned if **enterkeytype** is **search**.<br>- **4**: returned if **enterkeytype** is **send**.<br>- **5**: returned if **enterkeytype** is **next**.<br>- **6**: returned if **enterkeytype** is **default**, **done**, or is not set.|
| translate<sup>5+</sup> | {<br>&nbsp;value:&nbsp;selectedText<br>&nbsp;} | Triggered when users click the translate button in the menu displayed after they select a text segment. The selected text content is returned.|
| share<sup>5+</sup> | {<br>&nbsp;value:&nbsp;selectedText<br>&nbsp;} | Triggered when users click the share button in the menu displayed after they select a text segment. The selected text content is returned.|
| search<sup>5+</sup> | {<br>&nbsp;value:&nbsp;selectedText<br>&nbsp;} | Triggered when users click the search button in the menu displayed after they select a text segment. The selected text content is returned.|
| optionselect<sup>5+</sup> | {<br>&nbsp;index: optionIndex,<br>&nbsp;value:&nbsp;selectedText<br>&nbsp;} | Triggered when users click a menu option in the menu displayed after they select a text segment. This event is valid only when the **menuoptions** attribute is set. The option index and selected text content are returned.|
| selectchange<sup>6+</sup> | {<br>start:&nbsp;number,<br>end:&nbsp;number<br>&nbsp;} | Triggered when the text selection changes. |
| change | {<br> value: inputValue<br> } | Triggered when the content entered in the input box changes. The most recent content entered by the user is returned.<br>If you change the **value** attribute directly, this event will not be triggered.|
| enterkeyclick | {<br> value: enterKey<br> } | Triggered when the **Enter** key on the soft keyboard is clicked. The type of the **Enter** key is returned, which is of the number type. Available values are as follows:<br>- **2**: returned if **enterkeytype** is **go**.<br>- **3**: returned if **enterkeytype** is **search**.<br>- **4**: returned if **enterkeytype** is **send**.<br>- **5**: returned if **enterkeytype** is **next**.<br>- **6**: returned if **enterkeytype** is **default**, **done**, or is not set.|
| translate<sup>5+</sup> | {<br> value: selectedText<br> } | Triggered when users click the translate button in the menu displayed after they select a text segment. The selected text content is returned.|
| share<sup>5+</sup> | {<br> value: selectedText<br> } | Triggered when users click the share button in the menu displayed after they select a text segment. The selected text content is returned.|
| search<sup>5+</sup> | {<br> value: selectedText<br> } | Triggered when users click the search button in the menu displayed after they select a text segment. The selected text content is returned.|
| optionselect<sup>5+</sup> | {<br> index: optionIndex,<br> value: selectedText<br> } | Triggered when users click a menu option in the menu displayed after they select a text segment. This event is valid only when the **menuoptions** attribute is set. The option index and selected text content are returned.|
| selectchange<sup>6+</sup> | {<br>start: number,<br>end: number<br> } | Triggered when the text selection changes. |
- When **type** is set to **checkbox** or **radio**, the following events are supported.
| Name | Parameter | Description |
| ------ | ---------------------------------------- | ---------------------------------------- |
| change | {<br>&nbsp;checked:true&nbsp;\|&nbsp;false&nbsp;<br>} | Triggered when the checked status of the **checkbox** or **radio** button changes.|
| change | {<br> checked:true \| false <br>} | Triggered when the checked status of the **checkbox** or **radio** button changes.|
## Methods
In addition to the [universal methods](../arkui-js/js-components-common-methods.md), the following methods are supported.
| Name | Parameter | Description |
| ------------------- | ------------------------------------------------------------ | ------------------------------------------------------------ |
| focus | {<br>&nbsp;focus:&nbsp;true\|false<br>&nbsp;}:<br>If **focus** is not passed, the default value **true** is used.| Obtains or loses focus. When **type** is set to **text**, **email**, **date**, **time**, **number**, or password, the input method can be displayed or hidden.|
| showError | {<br>&nbsp;error:&nbsp;string&nbsp;<br>} | Displays the error message. This attribute is available when **type** is set to **text**, **email**, **date**, **time**, **number**, or **password**.|
| delete<sup>6+</sup> | - | Deletes the text content based on the current cursor position when **type** is set to **text**, **email**, **date**, **time**, **number**, or **password**; deletes the last character and displays the cursor if the current input component does not have a cursor.|
| Name | Parameter | Description |
| ------------------- | ---------------------------------------- | ---------------------------------------- |
| focus | {<br> focus: true\|false<br> }:<br>If **focus** is not passed, the default value **true** is used.| Obtains or loses focus. When **type** is set to **text**, **email**, **date**, **time**, **number**, or **password**, the input method can be displayed or collapsed. |
| showError | {<br> error: string <br>} | Displays the error message. This method is available when **type** is set to **text**, **email**, **date**, **time**, **number**, or **password**. |
| delete<sup>6+</sup> | - | Deletes text based on the current caret position when **type** is set to **text**, **email**, **date**, **time**, **number**, or **password**; deletes the last character and displays the caret if the current input component does not have a caret. |
## Example
......
# web
The **\<web>** component displays web page content.
>![](../../public_sys-resources/icon-note.gif) **NOTE**
> This component is supported since API version 6. Updates will be marked with a superscript to indicate their earliest API version.
>**NOTE**
>
>This component is supported since API version 6. Updates will be marked with a superscript to indicate their earliest API version.
## Required Permissions
ohos.permission.INTERNET, required only for accessing online web pages.
......@@ -25,6 +26,7 @@ Universal style settings are not supported.
## Events
The following events are supported.
| Name| Parameter| Description|
| -------- | -------- | -------- |
| pagestart | {url: string} | Triggered when web page loading starts.|
......@@ -33,12 +35,13 @@ The following events are supported.
## Methods
The following methods are supported.
| Name| Parameter| Description|
| -------- | -------- | -------- |
| reload | - | Reloads a page.|
## Example
```
```html
<!-- xxx.hml -->
<div style="height: 500px; width: 500px; flex-direction: column;">
<button onclick="reloadWeb">click to reload</button>
......@@ -46,7 +49,7 @@ The following methods are supported.
</div>
```
```
```js
// xxx.js
export default {
reloadWeb() {
......
......@@ -4,7 +4,7 @@
>
> This component is supported since API version 4. Updates will be marked with a superscript to indicate their earliest API version.
**CanvasGradient** provides a gradient object.
**CanvasGradient** provides a gradient object.
## addColorStop
......@@ -20,6 +20,7 @@ Adds a color stop for the **CanvasGradient** object based on the specified offse
| color | string | Gradient color to set. |
**Example**
```html
<!-- xxx.hml -->
<div>
......
......@@ -34,7 +34,7 @@ Scroll(scroller?: Scroller)
| scrollBarWidth | Length | - | Width of the scrollbar.|
| edgeEffect | EdgeEffect | EdgeEffect.Spring | Scroll effect. For details, see **EdgeEffect**.|
## ScrollDirection enums
## ScrollDirection
| Name | Description |
| ---------- | ---------- |
| Horizontal | Only horizontal scrolling is supported.|
......
......@@ -19,13 +19,8 @@ Circle(options?: {width?: string | number, height?: string | number})
- Parameters
| Name| Type| Mandatory| Default Value| Description|
| -------- | -------- | -------- | -------- | -------- |
| width | string \| number | No| 0 | Width of the circle. |
| height | string \| number | No| 0 | Height of the circle. |
| Name| Type| Mandatory| Default Value| Description|
| -------- | -------- | -------- | -------- | -------- |
| width | string \| number | Yes| - | Width.|
| height | string \| number | Yes| - | Height.|
| width | string \| number | No| 0 | Width of the circle.|
| height | string \| number | No| 0 | Height of the circle.|
## Attributes
......
......@@ -78,7 +78,7 @@ The part name must be in the format of <Domain\>/<Subsystem\>/<Part\>, for examp
│ └── inner_api # Internal APIs of parts
├── frameworks # Implementation of the part without independent processes (optional)
│ ├── native # C/C++ API implementation (optional)
│ └── js # JS API implementation (optional)
│ └── js # JS API implementation (optional)
│ ├── napi # Native API implementation (optional)
│ ├── builtin # Specific to LiteOS-M (optional)
│ └── plugin # Specific to ArkUI (optional)
......
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册