The **CommonEvent** module provides common event capabilities, including the capabilities to publish, subscribe to, and unsubscribe from common events, as well obtaining and setting the common event result code and result data.
The **CommonEvent** module provides common event capabilities, including the capabilities to publish, subscribe to, and unsubscribe from common events, as well obtaining and setting the common event result code and result data.
> **NOTE**
> **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.
> - The APIs provided by this module are no longer maintained since API version 9. You are advised to use [@ohos.commonEventManager](js-apis-commonEventManager.md).
> - 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
## Modules to Import
...
@@ -14,7 +15,7 @@ import CommonEvent from '@ohos.commonEvent';
...
@@ -14,7 +15,7 @@ import CommonEvent from '@ohos.commonEvent';
## Support
## Support
Provides the event types supported by the **CommonEvent** module. The name and value indicate the macro and name of a common event, respectively.
The table below lists the event types supported by the **CommonEvent** module. The name and value indicate the macro and name of a common event, respectively.
@@ -167,8 +168,8 @@ Provides the event types supported by the **CommonEvent** module. The name and v
...
@@ -167,8 +168,8 @@ Provides the event types supported by the **CommonEvent** module. The name and v
| COMMON_EVENT_ACCOUNT_DELETED | usual.event.data.ACCOUNT_DELETED | ohos.permission.INTERACT_ACROSS_LOCAL_ACCOUNTS | Indicates the common event that the account was deleted. |
| COMMON_EVENT_ACCOUNT_DELETED | usual.event.data.ACCOUNT_DELETED | ohos.permission.INTERACT_ACROSS_LOCAL_ACCOUNTS | Indicates the common event that the account was deleted. |
| COMMON_EVENT_FOUNDATION_READY | usual.event.data.FOUNDATION_READY | ohos.permission.RECEIVER_STARTUP_COMPLETED | Indicates the common event that the foundation is ready. |
| COMMON_EVENT_FOUNDATION_READY | usual.event.data.FOUNDATION_READY | ohos.permission.RECEIVER_STARTUP_COMPLETED | Indicates the common event that the foundation is ready. |
| COMMON_EVENT_AIRPLANE_MODE_CHANGED | usual.event.AIRPLANE_MODE | - | Indicates the common event that the airplane mode of the device has changed. |
| COMMON_EVENT_AIRPLANE_MODE_CHANGED | usual.event.AIRPLANE_MODE | - | Indicates the common event that the airplane mode of the device has changed. |
| COMMON_EVENT_SPLIT_SCREEN<sup>8+<sup> | usual.event.SPLIT_SCREEN | - | Indicates the common event of screen splitting. |
| COMMON_EVENT_SPLIT_SCREEN<sup>8+<sup> | usual.event.SPLIT_SCREEN | - | Indicates the common event of screen splitting. |
| COMMON_EVENT_SLOT_CHANGE<sup>9+<sup> | usual.event.SLOT_CHANGE | ohos.permission.NOTIFICATION_CONTROLLER | Indicates the common event that the notification slot has changed. |
| COMMON_EVENT_SLOT_CHANGE<sup>9+<sup> | usual.event.SLOT_CHANGE | ohos.permission.NOTIFICATION_CONTROLLER | Indicates the common event that the notification slot has been updated. |
| COMMON_EVENT_SPN_INFO_CHANGED <sup>9+<sup> | usual.event.SPN_INFO_CHANGED | - | Indicates the common event that the SPN displayed has been updated. |
| COMMON_EVENT_SPN_INFO_CHANGED <sup>9+<sup> | usual.event.SPN_INFO_CHANGED | - | Indicates the common event that the SPN displayed has been updated. |
| COMMON_EVENT_QUICK_FIX_APPLY_RESULT <sup>9+<sup> | usual.event.QUICK_FIX_APPLY_RESULT | - | Indicates the common event that a quick fix is applied to the application. |
| COMMON_EVENT_QUICK_FIX_APPLY_RESULT <sup>9+<sup> | usual.event.QUICK_FIX_APPLY_RESULT | - | Indicates the common event that a quick fix is applied to the application. |
...
@@ -192,7 +193,7 @@ Publishes a common event. This API uses an asynchronous callback to return the r
...
@@ -192,7 +193,7 @@ Publishes a common event. This API uses an asynchronous callback to return the r
| code | Yes | No | number | Result code of the common event. |
| code | number | Yes | No | Result code of the common event. |
| data | Yes | No | string | Custom result data of the common event.|
| data | string | Yes | No | Custom result data of the common event.|
| subscriberPermissions | Yes | No | Array\<string> | Permissions required for subscribers to receive the common event. |
| subscriberPermissions | Array\<string> | Yes | No | Permissions required for subscribers to receive the common event. |
| isOrdered | Yes | No | boolean | Whether the common event is an ordered one. |
| isOrdered | boolean | Yes | No | Whether the common event is an ordered one. |
| isSticky | Yes | No | boolean | Whether the common event is a sticky one. |
| isSticky | boolean | Yes | No | Whether the common event is a sticky one. Only system applications and system services are allowed to send sticky events.|
| parameters | Yes | No | {[key: string]: any} | Additional information about the common event. |
| parameters | {[key: string]: any} | Yes | No | Additional information about the common event. |
| events | Yes | No | Array\<string> | Name of the common event to publish. |
| events | Array\<string> | Yes | No | Name of the common event to publish. |
| publisherPermission | Yes | No | string | Permissions required for publishers to publish the common event. |
| publisherPermission | string | Yes | No | Permissions required for publishers to publish the common event. |
| publisherDeviceId | Yes | No | string | Device ID. The value must be the ID of an existing device on the same network. |
| publisherDeviceId | string | Yes | No | Device ID. The value must be the ID of an existing device on the same network. |
| userId | Yes | No | number | User ID. The default value is the ID of the current user. If this parameter is specified, the value must be an existing user ID in the system.|
| userId | number | Yes | No | User ID. The default value is the ID of the current user. If this parameter is specified, the value must be an existing user ID in the system.|
| priority | Yes | No | number | Subscriber priority. The value ranges from -100 to 1000. |
| priority | number | Yes | No | Subscriber priority. The value ranges from -100 to +1000. |
The **CommonEventManager** module provides common event capabilities, including the capabilities to publish, subscribe to, and unsubscribe from common events, as well obtaining and setting the common event result code and result data.
> **NOTE**
>
> The initial APIs of this module are supported since API version 9. Newly added APIs will be marked with a superscript to indicate their earliest API version.
The table below lists the event types supported by the **CommonEventManager** module. The name and value indicate the macro and name of a common event, respectively.
| COMMON_EVENT_BOOT_COMPLETED | usual.event.BOOT_COMPLETED | ohos.permission.RECEIVER_STARTUP_COMPLETED | Indicates the common event that the user has finished booting and the system has been loaded. |
| COMMON_EVENT_LOCKED_BOOT_COMPLETED | usual.event.LOCKED_BOOT_COMPLETED | ohos.permission.RECEIVER_STARTUP_COMPLETED | Indicates the common event that the user has finished booting and the system has been loaded but the screen is still locked. |
| COMMON_EVENT_SHUTDOWN | usual.event.SHUTDOWN | - | Indicates the common event that the device is being shut down and the final shutdown will proceed. |
| COMMON_EVENT_BATTERY_CHANGED | usual.event.BATTERY_CHANGED | - | Indicates the common event that the charging state, level, and other information about the battery have changed. |
| COMMON_EVENT_BATTERY_LOW | usual.event.BATTERY_LOW | - | Indicates the common event that the battery level is low. |
| COMMON_EVENT_BATTERY_OKAY | usual.event.BATTERY_OKAY | - | Indicates the common event that the battery exits the low state. |
| COMMON_EVENT_POWER_CONNECTED | usual.event.POWER_CONNECTED | - | Indicates the common event that the device is connected to an external power supply. |
| COMMON_EVENT_POWER_DISCONNECTED | usual.event.POWER_DISCONNECTED | - | Indicates the common event that the device is disconnected from the external power supply. |
| COMMON_EVENT_SCREEN_OFF | usual.event.SCREEN_OFF | - | Indicates the common event that the device screen is off and the device is sleeping. |
| COMMON_EVENT_SCREEN_ON | usual.event.SCREEN_ON | - | Indicates the common event that the device screen is on and the device is in interactive state. |
| COMMON_EVENT_THERMAL_LEVEL_CHANGED | usual.event.THERMAL_LEVEL_CHANGED | - | Indicates the common event that the device's thermal level has changed. |
| COMMON_EVENT_USER_PRESENT | usual.event.USER_PRESENT | - | Indicates the common event that the user unlocks the device. |
| COMMON_EVENT_TIME_TICK | usual.event.TIME_TICK | - | Indicates the common event that the system time has changed. |
| COMMON_EVENT_TIME_CHANGED | usual.event.TIME_CHANGED | - | Indicates the common event that the system time is set. |
| COMMON_EVENT_DATE_CHANGED | usual.event.DATE_CHANGED | - | Indicates the common event that the system time has changed. |
| COMMON_EVENT_TIMEZONE_CHANGED | usual.event.TIMEZONE_CHANGED | - | Indicates the common event that the system time zone has changed. |
| COMMON_EVENT_CLOSE_SYSTEM_DIALOGS | usual.event.CLOSE_SYSTEM_DIALOGS | - | Indicates the common event that a user closes a temporary system dialog box. |
| COMMON_EVENT_PACKAGE_ADDED | usual.event.PACKAGE_ADDED | - | Indicates the common event that a new application package has been installed on the device. |
| COMMON_EVENT_PACKAGE_REPLACED | usual.event.PACKAGE_REPLACED | - | Indicates the common event that a later version of an installed application package has replaced the previous one on the device. |
| COMMON_EVENT_MY_PACKAGE_REPLACED | usual.event.MY_PACKAGE_REPLACED | - | Indicates the common event that a later version of your application package has replaced the previous one.
| COMMON_EVENT_PACKAGE_REMOVED | usual.event.PACKAGE_REMOVED | - | Indicates the common event that an installed application has been uninstalled from the device with the application data retained. |
| COMMON_EVENT_BUNDLE_REMOVED | usual.event.BUNDLE_REMOVED | - | Indicates the common event that an installed bundle has been uninstalled from the device with the application data retained. |
| COMMON_EVENT_PACKAGE_FULLY_REMOVED | usual.event.PACKAGE_FULLY_REMOVED | - | Indicates the common event that an installed application, including both the application data and code, has been completely uninstalled from the device. |
| COMMON_EVENT_PACKAGE_CHANGED | usual.event.PACKAGE_CHANGED | - | Indicates the common event that an application package has been changed (for example, a component in the package has been enabled or disabled). |
| COMMON_EVENT_PACKAGE_RESTARTED | usual.event.PACKAGE_RESTARTED | - | Indicates the common event that the user has restarted the application package and killed all its processes. |
| COMMON_EVENT_PACKAGE_DATA_CLEARED | usual.event.PACKAGE_DATA_CLEARED | - | Indicates the common event that the user has cleared the application package data. |
| COMMON_EVENT_PACKAGE_CACHE_CLEARED<sup>9+</sup> | usual.event.PACKAGE_CACHE_CLEARED | - | Indicates the common event that the user has cleared the application package data. |
| COMMON_EVENT_PACKAGES_SUSPENDED | usual.event.PACKAGES_SUSPENDED | - | Indicates the common event that application packages have been suspended. |
| COMMON_EVENT_PACKAGES_UNSUSPENDED | usual.event.PACKAGES_UNSUSPENDED | - | Indicates the common event that application package has not been suspended. |
| COMMON_EVENT_MY_PACKAGE_SUSPENDED | usual.event.MY_PACKAGE_SUSPENDED | - | Indicates the common event that an application package has been suspended. |
| COMMON_EVENT_MY_PACKAGE_UNSUSPENDED | usual.event.MY_PACKAGE_UNSUSPENDED | - | Indicates the common event that application package has not been suspended. |
| COMMON_EVENT_UID_REMOVED | usual.event.UID_REMOVED | - | Indicates the common event that a user ID has been removed from the system. |
| COMMON_EVENT_PACKAGE_FIRST_LAUNCH | usual.event.PACKAGE_FIRST_LAUNCH | - | Indicates the common event that an installed application is started for the first time. |
| COMMON_EVENT_PACKAGE_NEEDS_VERIFICATION | usual.event.PACKAGE_NEEDS_VERIFICATION | - | Indicates the common event that an application requires system verification. |
| COMMON_EVENT_PACKAGE_VERIFIED | usual.event.PACKAGE_VERIFIED | - | Indicates the common event that an application has been verified by the system. |
| COMMON_EVENT_EXTERNAL_APPLICATIONS_AVAILABLE | usual.event.EXTERNAL_APPLICATIONS_AVAILABLE | - | Indicates the common event that applications installed on the external storage become available for the system. |
| COMMON_EVENT_EXTERNAL_APPLICATIONS_UNAVAILABLE | usual.event.EXTERNAL_APPLICATIONS_UNAVAILABLE | - | Indicates the common event that applications installed on the external storage become unavailable for the system. |
| COMMON_EVENT_CONFIGURATION_CHANGED | usual.event.CONFIGURATION_CHANGED | - | Indicates the common event that the device state (for example, orientation and locale) has changed. |
| COMMON_EVENT_LOCALE_CHANGED | usual.event.LOCALE_CHANGED | - | Indicates the common event that the device locale has changed. |
| COMMON_EVENT_MANAGE_PACKAGE_STORAGE | usual.event.MANAGE_PACKAGE_STORAGE | - | Indicates the common event that the device storage is insufficient. |
| COMMON_EVENT_DRIVE_MODE | common.event.DRIVE_MODE | - | Indicates the common event that the system is in driving mode. |
| COMMON_EVENT_HOME_MODE | common.event.HOME_MODE | - | Indicates the common event that the system is in home mode. |
| COMMON_EVENT_OFFICE_MODE | common.event.OFFICE_MODE | - | Indicates the common event that the system is in office mode. |
| COMMON_EVENT_USER_STARTED | usual.event.USER_STARTED | - | Indicates the common event that the user has been started. |
| COMMON_EVENT_USER_BACKGROUND | usual.event.USER_BACKGROUND | - | Indicates the common event that the user has been brought to the background. |
| COMMON_EVENT_USER_FOREGROUND | usual.event.USER_FOREGROUND | - | Indicates the common event that the user has been brought to the foreground. |
| COMMON_EVENT_USER_SWITCHED | usual.event.USER_SWITCHED | ohos.permission.MANAGE_LOCAL_ACCOUNTS | Indicates the common event that user switching is happening. |
| COMMON_EVENT_USER_STARTING | usual.event.USER_STARTING | ohos.permission.INTERACT_ACROSS_LOCAL_ACCOUNTS | Indicates the common event that the user is going to be started. |
| COMMON_EVENT_USER_UNLOCKED | usual.event.USER_UNLOCKED | - | Indicates the common event that the credential-encrypted storage has been unlocked for the current user when the device is unlocked after being restarted. |
| COMMON_EVENT_USER_STOPPING | usual.event.USER_STOPPING | ohos.permission.INTERACT_ACROSS_LOCAL_ACCOUNTS | Indicates the common event that the user is going to be stopped. |
| COMMON_EVENT_USER_STOPPED | usual.event.USER_STOPPED | - | Indicates the common event that the user has been stopped. |
| COMMON_EVENT_DISTRIBUTED_ACCOUNT_LOGIN | usual.event.DISTRIBUTED_ACCOUNT_LOGIN | - | Indicates the action of successful login using a distributed account. |
| COMMON_EVENT_DISTRIBUTED_ACCOUNT_LOGOUT | usual.event.DISTRIBUTED_ACCOUNT_LOGOUT | - | Indicates the action of successful logout of a distributed account. |
| COMMON_EVENT_DISTRIBUTED_ACCOUNT_TOKEN_INVALID | usual.event.DISTRIBUTED_ACCOUNT_TOKEN_INVALID | - | Indicates the action when the token of a distributed account is invalid. |
| COMMON_EVENT_DISTRIBUTED_ACCOUNT_LOGOFF | usual.event.DISTRIBUTED_ACCOUNT_LOGOFF | - | Indicates the action of deregistering a distributed account. |
| COMMON_EVENT_WIFI_POWER_STATE | usual.event.wifi.POWER_STATE | - | Indicates the common event about the Wi-Fi network state, such as enabled and disabled. |
| COMMON_EVENT_WIFI_SCAN_FINISHED | usual.event.wifi.SCAN_FINISHED | ohos.permission.LOCATION | Indicates the common event that the Wi-Fi access point has been scanned and proven to be available. |
| COMMON_EVENT_WIFI_RSSI_VALUE | usual.event.wifi.RSSI_VALUE | ohos.permission.GET_WIFI_INFO | Indicates the common event that the Wi-Fi signal strength (RSSI) has changed. |
| COMMON_EVENT_WIFI_CONN_STATE | usual.event.wifi.CONN_STATE | - | Indicates the common event that the Wi-Fi connection state has changed. |
| COMMON_EVENT_WIFI_HOTSPOT_STATE | usual.event.wifi.HOTSPOT_STATE | - | Indicates the common event about the Wi-Fi hotspot state, such as enabled or disabled. |
| COMMON_EVENT_WIFI_AP_STA_JOIN | usual.event.wifi.WIFI_HS_STA_JOIN | ohos.permission.GET_WIFI_INFO | Indicates the common event that a client has joined the Wi-Fi hotspot of the current device. |
| COMMON_EVENT_WIFI_AP_STA_LEAVE | usual.event.wifi.WIFI_HS_STA_LEAVE | ohos.permission.GET_WIFI_INFO |Indicates the common event that a client has disconnected from the Wi-Fi hotspot of the current device. |
| COMMON_EVENT_WIFI_MPLINK_STATE_CHANGE | usual.event.wifi.mplink.STATE_CHANGE | ohos.permission.MPLINK_CHANGE_STATE | Indicates the common event that the state of MPLINK (an enhanced Wi-Fi feature) has changed. |
| COMMON_EVENT_WIFI_P2P_CONN_STATE | usual.event.wifi.p2p.CONN_STATE_CHANGE | ohos.permission.GET_WIFI_INFO and ohos.permission.LOCATION | Indicates the common event that the Wi-Fi P2P connection state has changed. |
| COMMON_EVENT_WIFI_P2P_STATE_CHANGED | usual.event.wifi.p2p.STATE_CHANGE | ohos.permission.GET_WIFI_INFO | Indicates the common event about the Wi-Fi P2P state, such as enabled and disabled. |
| COMMON_EVENT_WIFI_P2P_PEERS_STATE_CHANGED | usual.event.wifi.p2p.DEVICES_CHANGE | ohos.permission.GET_WIFI_INFO | Indicates the common event about the status change of Wi-Fi P2P peer devices. |
| COMMON_EVENT_WIFI_P2P_PEERS_DISCOVERY_STATE_CHANGED | usual.event.wifi.p2p.PEER_DISCOVERY_STATE_CHANGE | ohos.permission.GET_WIFI_INFO | Indicates the common event about the Wi-Fi P2P discovery status change. |
| COMMON_EVENT_WIFI_P2P_CURRENT_DEVICE_STATE_CHANGED | usual.event.wifi.p2p.CURRENT_DEVICE_CHANGE | ohos.permission.GET_WIFI_INFO | Indicates the common event about the status change of the Wi-Fi P2P local device. |
| COMMON_EVENT_WIFI_P2P_GROUP_STATE_CHANGED | usual.event.wifi.p2p.GROUP_STATE_CHANGED | ohos.permission.GET_WIFI_INFO | Indicates the common event that the Wi-Fi P2P group information has changed. |
| COMMON_EVENT_BLUETOOTH_HANDSFREE_AG_CONNECT_STATE_UPDATE | usual.event.bluetooth.handsfree.ag.CONNECT_STATE_UPDATE | ohos.permission.USE_BLUETOOTH | Indicates the common event about the connection state of Bluetooth handsfree communication. |
| COMMON_EVENT_BLUETOOTH_HANDSFREE_AG_CURRENT_DEVICE_UPDATE | usual.event.bluetooth.handsfree.ag.CURRENT_DEVICE_UPDATE | ohos.permission.USE_BLUETOOTH | Indicates the common event that the device connected to the Bluetooth handsfree is active. |
| COMMON_EVENT_BLUETOOTH_HANDSFREE_AG_AUDIO_STATE_UPDATE | usual.event.bluetooth.handsfree.ag.AUDIO_STATE_UPDATE | ohos.permission.USE_BLUETOOTH | Indicates the common event that the connection state of Bluetooth A2DP has changed. |
| COMMON_EVENT_BLUETOOTH_A2DPSOURCE_CONNECT_STATE_UPDATE | usual.event.bluetooth.a2dpsource.CONNECT_STATE_UPDATE | ohos.permission.USE_BLUETOOTH | Indicates the common event about the connection state of Bluetooth A2DP. |
| COMMON_EVENT_BLUETOOTH_A2DPSOURCE_CURRENT_DEVICE_UPDATE | usual.event.bluetooth.a2dpsource.CURRENT_DEVICE_UPDATE | ohos.permission.USE_BLUETOOTH | Indicates the common event that the device connected using Bluetooth A2DP is active. |
| COMMON_EVENT_BLUETOOTH_A2DPSOURCE_PLAYING_STATE_UPDATE | usual.event.bluetooth.a2dpsource.PLAYING_STATE_UPDATE | ohos.permission.USE_BLUETOOTH | Indicates the common event that the playing state of Bluetooth A2DP has changed. |
| COMMON_EVENT_BLUETOOTH_A2DPSOURCE_AVRCP_CONNECT_STATE_UPDATE | usual.event.bluetooth.a2dpsource.AVRCP_CONNECT_STATE_UPDATE | ohos.permission.USE_BLUETOOTH | Indicates the common event that the AVRCP connection state of Bluetooth A2DP has changed. |
| COMMON_EVENT_BLUETOOTH_A2DPSOURCE_CODEC_VALUE_UPDATE | usual.event.bluetooth.a2dpsource.CODEC_VALUE_UPDATE | ohos.permission.USE_BLUETOOTH | Indicates the common event that the audio codec state of Bluetooth A2DP has changed. |
| COMMON_EVENT_BLUETOOTH_REMOTEDEVICE_DISCOVERED | usual.event.bluetooth.remotedevice.DISCOVERED | ohos.permission.LOCATION and ohos.permission.USE_BLUETOOTH | Indicates the common event that a remote Bluetooth device is discovered. |
| COMMON_EVENT_BLUETOOTH_REMOTEDEVICE_CLASS_VALUE_UPDATE | usual.event.bluetooth.remotedevice.CLASS_VALUE_UPDATE | ohos.permission.USE_BLUETOOTH | Indicates the common event that the Bluetooth class of a remote Bluetooth device has changed. |
| COMMON_EVENT_BLUETOOTH_REMOTEDEVICE_ACL_CONNECTED | usual.event.bluetooth.remotedevice.ACL_CONNECTED | ohos.permission.USE_BLUETOOTH | Indicates the common event that a low-ACL connection has been established with a remote Bluetooth device. |
| COMMON_EVENT_BLUETOOTH_REMOTEDEVICE_ACL_DISCONNECTED | usual.event.bluetooth.remotedevice.ACL_DISCONNECTED | ohos.permission.USE_BLUETOOTH | Indicates the common event that a low-ACL connection has been disconnected from a remote Bluetooth device. |
| COMMON_EVENT_BLUETOOTH_REMOTEDEVICE_NAME_UPDATE | usual.event.bluetooth.remotedevice.NAME_UPDATE | ohos.permission.USE_BLUETOOTH | Indicates the common event that the friendly name of a remote Bluetooth device is retrieved for the first time or is changed since the last retrieval. |
| COMMON_EVENT_BLUETOOTH_REMOTEDEVICE_PAIR_STATE | usual.event.bluetooth.remotedevice.PAIR_STATE | ohos.permission.USE_BLUETOOTH | Indicates the common event that the connection state of a remote Bluetooth device has changed. |
| COMMON_EVENT_BLUETOOTH_REMOTEDEVICE_BATTERY_VALUE_UPDATE | usual.event.bluetooth.remotedevice.BATTERY_VALUE_UPDATE | ohos.permission.USE_BLUETOOTH | Indicates the common event that the battery level of a remote Bluetooth device is retrieved for the first time or is changed since the last retrieval. |
| COMMON_EVENT_BLUETOOTH_REMOTEDEVICE_SDP_RESULT | usual.event.bluetooth.remotedevice.SDP_RESULT | - | Indicates the common event about the SDP state of a remote Bluetooth device. |
| COMMON_EVENT_BLUETOOTH_REMOTEDEVICE_UUID_VALUE | usual.event.bluetooth.remotedevice.UUID_VALUE | ohos.permission.DISCOVER_BLUETOOTH | Indicates the common event about the UUID connection state of a remote Bluetooth device. |
| COMMON_EVENT_BLUETOOTH_REMOTEDEVICE_PAIRING_REQ | usual.event.bluetooth.remotedevice.PAIRING_REQ | ohos.permission.DISCOVER_BLUETOOTH | Indicates the common event about the pairing request from a remote Bluetooth device. |
| COMMON_EVENT_BLUETOOTH_REMOTEDEVICE_PAIRING_CANCEL | usual.event.bluetooth.remotedevice.PAIRING_CANCEL | - | Indicates the common event that Bluetooth pairing is canceled. |
| COMMON_EVENT_BLUETOOTH_REMOTEDEVICE_CONNECT_REQ | usual.event.bluetooth.remotedevice.CONNECT_REQ | - | Indicates the common event about the connection request from a remote Bluetooth device. |
| COMMON_EVENT_BLUETOOTH_REMOTEDEVICE_CONNECT_REPLY | usual.event.bluetooth.remotedevice.CONNECT_REPLY | - | Indicates the common event about the response to the connection request from a remote Bluetooth device. |
| COMMON_EVENT_BLUETOOTH_REMOTEDEVICE_CONNECT_CANCEL | usual.event.bluetooth.remotedevice.CONNECT_CANCEL | - | Indicates the common event that the connection to a remote Bluetooth device has been canceled. |
| COMMON_EVENT_BLUETOOTH_HANDSFREEUNIT_CONNECT_STATE_UPDATE | usual.event.bluetooth.handsfreeunit.CONNECT_STATE_UPDATE | - | Indicates the common event that the connection state of a Bluetooth handsfree has changed. |
| COMMON_EVENT_BLUETOOTH_HANDSFREEUNIT_AUDIO_STATE_UPDATE | usual.event.bluetooth.handsfreeunit.AUDIO_STATE_UPDATE | - | Indicates the common event that the audio state of a Bluetooth handsfree has changed. |
| COMMON_EVENT_BLUETOOTH_HANDSFREEUNIT_AG_COMMON_EVENT | usual.event.bluetooth.handsfreeunit.AG_COMMON_EVENT | - | Indicates the common event that the audio gateway state of a Bluetooth handsfree has changed. |
| COMMON_EVENT_BLUETOOTH_HANDSFREEUNIT_AG_CALL_STATE_UPDATE | usual.event.bluetooth.handsfreeunit.AG_CALL_STATE_UPDATE | - | Indicates the common event that the calling state of a Bluetooth handsfree has changed. |
| COMMON_EVENT_BLUETOOTH_HOST_STATE_UPDATE | usual.event.bluetooth.host.STATE_UPDATE | ohos.permission.USE_BLUETOOTH | Indicates the common event that the state of a Bluetooth adapter has been changed, for example, Bluetooth has been enabled or disabled. |
| COMMON_EVENT_BLUETOOTH_HOST_REQ_DISCOVERABLE | usual.event.bluetooth.host.REQ_DISCOVERABLE | - | Indicates the common event about the request for the user to allow Bluetooth device scanning. |
| COMMON_EVENT_BLUETOOTH_HOST_REQ_ENABLE | usual.event.bluetooth.host.REQ_ENABLE | ohos.permission.USE_BLUETOOTH | Indicates the common event about the request for the user to enable Bluetooth. |
| COMMON_EVENT_BLUETOOTH_HOST_REQ_DISABLE | usual.event.bluetooth.host.REQ_DISABLE | ohos.permission.USE_BLUETOOTH | Indicates the common event about the request for the user to disable Bluetooth. |
| COMMON_EVENT_BLUETOOTH_HOST_SCAN_MODE_UPDATE | usual.event.bluetooth.host.SCAN_MODE_UPDATE | ohos.permission.USE_BLUETOOTH | Indicates the common event that the Bluetooth scanning mode of a device has changed. |
| COMMON_EVENT_BLUETOOTH_HOST_DISCOVERY_STARTED | usual.event.bluetooth.host.DISCOVERY_STARTED | ohos.permission.USE_BLUETOOTH | Indicates the common event that the Bluetooth scanning has been started on the device. |
| COMMON_EVENT_BLUETOOTH_HOST_DISCOVERY_FINISHED | usual.event.bluetooth.host.DISCOVERY_FINISHED | ohos.permission.USE_BLUETOOTH | Indicates the common event that the Bluetooth scanning is finished on the device. |
| COMMON_EVENT_BLUETOOTH_HOST_NAME_UPDATE | usual.event.bluetooth.host.NAME_UPDATE | ohos.permission.USE_BLUETOOTH | Indicates the common event that the Bluetooth adapter name of the device has changed. |
| COMMON_EVENT_BLUETOOTH_A2DPSINK_CONNECT_STATE_UPDATE | usual.event.bluetooth.a2dpsink.CONNECT_STATE_UPDATE | ohos.permission.USE_BLUETOOTH | Indicates the common event that the connection state of Bluetooth A2DP Sink has changed. |
| COMMON_EVENT_BLUETOOTH_A2DPSINK_PLAYING_STATE_UPDATE | usual.event.bluetooth.a2dpsink.PLAYING_STATE_UPDATE | ohos.permission.USE_BLUETOOTH | Indicates the common event that the playing state of Bluetooth A2DP Sink has changed. |
| COMMON_EVENT_BLUETOOTH_A2DPSINK_AUDIO_STATE_UPDATE | usual.event.bluetooth.a2dpsink.AUDIO_STATE_UPDATE | ohos.permission.USE_BLUETOOTH | Indicates the common event that the audio state of Bluetooth A2DP Sink has changed. |
| COMMON_EVENT_NFC_ACTION_ADAPTER_STATE_CHANGED | usual.event.nfc.action.ADAPTER_STATE_CHANGED | - | Indicates the common event that the state of the device's NFC adapter has changed. |
| COMMON_EVENT_NFC_ACTION_RF_FIELD_ON_DETECTED | usual.event.nfc.action.RF_FIELD_ON_DETECTED | ohos.permission.MANAGE_SECURE_SETTINGS | Indicates the action of a common event that the NFC RF field is detected to be in the enabled state. |
| COMMON_EVENT_NFC_ACTION_RF_FIELD_OFF_DETECTED | usual.event.nfc.action.RF_FIELD_OFF_DETECTED | ohos.permission.MANAGE_SECURE_SETTINGS | Indicates the common event that the NFC RF field is detected to be in the disabled state. |
| COMMON_EVENT_DISCHARGING | usual.event.DISCHARGING | - | Indicates the common event that the system stops charging the battery. |
| COMMON_EVENT_CHARGING | usual.event.CHARGING | - | Indicates the common event that the system starts charging the battery. |
| COMMON_EVENT_DEVICE_IDLE_MODE_CHANGED | usual.event.DEVICE_IDLE_MODE_CHANGED | - | Indicates the common event that the system idle mode has changed. |
| COMMON_EVENT_POWER_SAVE_MODE_CHANGED | usual.event.POWER_SAVE_MODE_CHANGED | - | Indicates the common event that the power saving mode of the system has changed. |
| COMMON_EVENT_USER_ADDED | usual.event.USER_ADDED | ohos.permission.MANAGE_LOCAL_ACCOUNTS | Indicates the common event that a user has been added to the system. |
| COMMON_EVENT_USER_REMOVED | usual.event.USER_REMOVED | ohos.permission.MANAGE_LOCAL_ACCOUNTS | Indicates the common event that a user has been removed from the system. |
| COMMON_EVENT_ABILITY_ADDED | usual.event.ABILITY_ADDED | ohos.permission.LISTEN_BUNDLE_CHANGE | Indicates the common event that an ability has been added. |
| COMMON_EVENT_ABILITY_REMOVED | usual.event.ABILITY_REMOVED | ohos.permission.LISTEN_BUNDLE_CHANGE | Indicates the common event that an ability has been removed. |
| COMMON_EVENT_ABILITY_UPDATED | usual.event.ABILITY_UPDATED | ohos.permission.LISTEN_BUNDLE_CHANGE | Indicates the common event that an ability has been updated. |
| COMMON_EVENT_LOCATION_MODE_STATE_CHANGED | usual.event.location.MODE_STATE_CHANGED | - | Indicates the common event that the location mode of the system has changed. |
| COMMON_EVENT_IVI_SLEEP | common.event.IVI_SLEEP | - | Indicates the common event that the in-vehicle infotainment (IVI) system of a vehicle is sleeping. |
| COMMON_EVENT_IVI_PAUSE | common.event.IVI_PAUSE | - | Indicates the common event that the IVI system of a vehicle has entered sleep mode and the playing application is instructed to stop playback. |
| COMMON_EVENT_IVI_STANDBY | common.event.IVI_STANDBY | - | Indicates the common event that a third-party application is instructed to pause the current work. |
| COMMON_EVENT_IVI_LASTMODE_SAVE | common.event.IVI_LASTMODE_SAVE | - | Indicates the common event that a third-party application is instructed to save its last mode. |
| COMMON_EVENT_IVI_VOLTAGE_ABNORMAL | common.event.IVI_VOLTAGE_ABNORMAL | - | Indicates the common event that the voltage of the vehicle's power system is abnormal. |
| COMMON_EVENT_IVI_HIGH_TEMPERATURE | common.event.IVI_HIGH_TEMPERATURE | - | Indicates the common event that the temperature of the IVI system is high. |
| COMMON_EVENT_IVI_EXTREME_TEMPERATURE | common.event.IVI_EXTREME_TEMPERATURE | - | Indicates the common event that the temperature of the IVI system is extremely high. |
| COMMON_EVENT_IVI_TEMPERATURE_ABNORMAL | common.event.IVI_TEMPERATURE_ABNORMAL | - | Indicates the common event that the IVI system has an extreme temperature. |
| COMMON_EVENT_IVI_VOLTAGE_RECOVERY | common.event.IVI_VOLTAGE_RECOVERY | - | Indicates the common event that the voltage of the vehicle's power system is restored to normal. |
| COMMON_EVENT_IVI_TEMPERATURE_RECOVERY | common.event.IVI_TEMPERATURE_RECOVERY | - | Indicates the common event that the temperature of the IVI system is restored to normal. |
| COMMON_EVENT_IVI_ACTIVE | common.event.IVI_ACTIVE | - | Indicates the common event that the battery service is active. |
|COMMON_EVENT_USB_STATE<sup>9+</sup> | usual.event.hardware.usb.action.USB_STATE | - | Indicates a common event indicating that the USB device status changes. |
|COMMON_EVENT_USB_PORT_CHANGED<sup>9+</sup> | usual.event.hardware.usb.action.USB_PORT_CHANGED | - | Indicates the public event that the USB port status of the user device changes. |
| COMMON_EVENT_USB_DEVICE_ATTACHED | usual.event.hardware.usb.action.USB_DEVICE_ATTACHED | - | Indicates the common event that a USB device has been attached when the user device functions as a USB host. |
| COMMON_EVENT_USB_DEVICE_DETACHED | usual.event.hardware.usb.action.USB_DEVICE_DETACHED | - | Indicates the common event that a USB device has been detached when the user device functions as a USB host. |
| COMMON_EVENT_USB_ACCESSORY_ATTACHED | usual.event.hardware.usb.action.USB_ACCESSORY_ATTACHED | - | Indicates the common event that a USB accessory was attached. |
| COMMON_EVENT_USB_ACCESSORY_DETACHED | usual.event.hardware.usb.action.USB_ACCESSORY_DETACHED | - | Indicates the common event that a USB accessory was detached. |
| COMMON_EVENT_DISK_REMOVED | usual.event.data.DISK_REMOVED | ohos.permission.STORAGE_MANAGER | Indicates the common event that an external storage device was removed. |
| COMMON_EVENT_DISK_UNMOUNTED | usual.event.data.DISK_UNMOUNTED | ohos.permission.STORAGE_MANAGER | Indicates the common event that an external storage device was unmounted. |
| COMMON_EVENT_DISK_MOUNTED | usual.event.data.DISK_MOUNTED | ohos.permission.STORAGE_MANAGER | Indicates the common event that an external storage device was mounted. |
| COMMON_EVENT_DISK_BAD_REMOVAL | usual.event.data.DISK_BAD_REMOVAL | ohos.permission.STORAGE_MANAGER | Indicates the common event that an external storage device was removed without being unmounted. |
| COMMON_EVENT_DISK_UNMOUNTABLE | usual.event.data.DISK_UNMOUNTABLE | ohos.permission.STORAGE_MANAGER | Indicates the common event that an external storage device becomes unmountable. |
| COMMON_EVENT_DISK_EJECT | usual.event.data.DISK_EJECT | ohos.permission.STORAGE_MANAGER | Indicates the common event that an external storage device was ejected. |
| COMMON_EVENT_VOLUME_REMOVED<sup>9+<sup> | usual.event.data.VOLUME_REMOVED | ohos.permission.STORAGE_MANAGER | Indicates the common event that an external storage device was removed. |
| COMMON_EVENT_VOLUME_UNMOUNTED<sup>9+<sup> | usual.event.data.VOLUME_UNMOUNTED | ohos.permission.STORAGE_MANAGER | Indicates the common event that an external storage device was unmounted. |
| COMMON_EVENT_VOLUME_MOUNTED<sup>9+<sup> | usual.event.data.VOLUME_MOUNTED | ohos.permission.STORAGE_MANAGER | Indicates the common event that an external storage device was mounted. |
| COMMON_EVENT_VOLUME_BAD_REMOVAL<sup>9+<sup> | usual.event.data.VOLUME_BAD_REMOVAL | ohos.permission.STORAGE_MANAGER | Indicates the common event that an external storage device was removed without being unmounted. |
| COMMON_EVENT_VOLUME_EJECT<sup>9+<sup> | usual.event.data.VOLUME_EJECT | ohos.permission.STORAGE_MANAGER | Indicates the common event that an external storage device was ejected. |
| COMMON_EVENT_VISIBLE_ACCOUNTS_UPDATED | usual.event.data.VISIBLE_ACCOUNTS_UPDATED | ohos.permission.GET_APP_ACCOUNTS | Indicates the common event that the account visibility changed. |
| COMMON_EVENT_ACCOUNT_DELETED | usual.event.data.ACCOUNT_DELETED | ohos.permission.INTERACT_ACROSS_LOCAL_ACCOUNTS | Indicates the common event that the account was deleted. |
| COMMON_EVENT_FOUNDATION_READY | usual.event.data.FOUNDATION_READY | ohos.permission.RECEIVER_STARTUP_COMPLETED | Indicates the common event that the foundation is ready. |
| COMMON_EVENT_AIRPLANE_MODE_CHANGED | usual.event.AIRPLANE_MODE | - | Indicates the common event that the airplane mode of the device has changed. |
| COMMON_EVENT_SPLIT_SCREEN | usual.event.SPLIT_SCREEN | ohos.permission.RECEIVER_SPLIT_SCREEN | Indicates the common event of screen splitting. |
| COMMON_EVENT_SLOT_CHANGE<sup>9+<sup> | usual.event.SLOT_CHANGE | ohos.permission.NOTIFICATION_CONTROLLER | Indicates the common event that the notification slot has been updated. |
| COMMON_EVENT_SPN_INFO_CHANGED <sup>9+<sup> | usual.event.SPN_INFO_CHANGED | - | Indicates the common event that the SPN displayed has been updated. |
| COMMON_EVENT_QUICK_FIX_APPLY_RESULT <sup>9+<sup> | usual.event.QUICK_FIX_APPLY_RESULT | - | Indicates the common event that a quick fix is applied to the application. |
| callback | AsyncCallback\<boolean> | Yes | Callback used to return the result. The value **true** means that the common event is an ordered one; and **false** means the opposite.|
| Promise\<boolean> | Promise used to return the result. The value **true** means that the common event is an ordered one; and **false** means the opposite.|
| callback | AsyncCallback\<boolean> | Yes | Callback used to return the result. The value **true** means that the common event is a sticky one; and **false** means the opposite.|
| Promise\<boolean> | Promise used to return the result. The value **true** means that the common event is a sticky one; and **false** means the opposite.|
Aborts this common event. After the abort, the common event is not sent to the next subscriber. This API takes effect only for ordered common events. It uses an asynchronous callback to return the result.
Aborts this common event. After the abort, the common event is not sent to the next subscriber. This API takes effect only for ordered common events. It uses a promise to return the result.
Clears the aborted state of this common event. This API takes effect only for ordered common events. It uses an asynchronous callback to return the result.
Checks whether this common event is in the aborted state. This API takes effect only for ordered common events. It uses an asynchronous callback to return the result.
| callback | AsyncCallback\<boolean> | Yes | Callback used to return the result. The value **true** means that the ordered common event is in the aborted state; and **false** means the opposite.|
Checks whether this common event is in the aborted state. This API takes effect only for ordered common events. It uses a promise to return the result.
| Promise\<boolean> | Promise used to return the result. The value **true** means that the ordered common event is in the aborted state; and **false** means the opposite.|
| code | number | Yes | No | Result code of the common event. |
| data | string | Yes | No | Custom result data of the common event.|
| subscriberPermissions | Array\<string> | Yes | No | Permissions required for subscribers to receive the common event. |
| isOrdered | boolean | Yes | No | Whether the common event is an ordered one. |
| isSticky | boolean | Yes | No | Whether the common event is a sticky one. Only system applications and system services are allowed to send sticky events.|
| parameters | {[key: string]: any} | Yes | No | Additional information about the common event. |
| events | Array\<string> | Yes | No | Name of the common event to publish. |
| publisherPermission | string | Yes | No | Permissions required for publishers to publish the common event. |
| publisherDeviceId | string | Yes | No | Device ID. The value must be the ID of an existing device on the same network. |
| userId | number | Yes | No | User ID. The default value is the ID of the current user. If this parameter is specified, the value must be an existing user ID in the system.|
| priority | number | Yes | No | Subscriber priority. The value ranges from -100 to +1000. |
The **<Web\>** component can be used to display web pages.
> **NOTE**
> **NOTE**
>
>
> - This component is supported since API version 8. Updates will be marked with a superscript to indicate their earliest API version.
> - This component is supported since API version 8. Updates will be marked with a superscript to indicate their earliest API version.
> - You can preview how this component looks on a real device. The preview is not yet available in the DevEco Studio Previewer.
> - You can preview how this component looks on a real device. The preview is not yet available in the DevEco Studio Previewer.
The **<Web\>** component can be used to display web pages.
## Required Permissions
## Required Permissions
To use online resources, the application must have the **ohos.permission.INTERNET** permission. For details about how to apply for a permission, see [Declaring Permissions](../../security/accesstoken-guidelines.md).
To use online resources, the application must have the **ohos.permission.INTERNET** permission. For details about how to apply for a permission, see [Declaring Permissions](../../security/accesstoken-guidelines.md).
Only the following universal attributes are supported: [width](ts-universal-attributes-size.md#Attributes), [height](ts-universal-attributes-size.md#attributes), [padding](ts-universal-attributes-size.md#Attributes), [margin](ts-universal-attributes-size.md#attributes), and [border](ts-universal-attributes-border.md#attributes).
### domStorageAccess
### domStorageAccess
...
@@ -98,8 +98,8 @@ Sets whether to enable the DOM Storage API. By default, this feature is disabled
...
@@ -98,8 +98,8 @@ Sets whether to enable the DOM Storage API. By default, this feature is disabled
**Parameters**
**Parameters**
| Name | Type | Mandatory | Default Value | Description |
| Name | Type | Mandatory | Default Value | Description |
| domStorageAccess | boolean | Yes | false | Whether to enable the DOM Storage API.|
| domStorageAccess | boolean | Yes | false | Whether to enable the DOM Storage API.|
**Example**
**Example**
...
@@ -123,12 +123,12 @@ Sets whether to enable the DOM Storage API. By default, this feature is disabled
...
@@ -123,12 +123,12 @@ Sets whether to enable the DOM Storage API. By default, this feature is disabled
fileAccess(fileAccess: boolean)
fileAccess(fileAccess: boolean)
Sets whether to enable access to the file system in the application. Access to the files in **rawfile** specified through [$rawfile(filepath/filename)](../../quick-start/resource-categories-and-access.md) are not affected by the setting.
Sets whether to enable access to the file system in the application. This setting does not affect the access to the files specified through [$rawfile(filepath/filename)](../../quick-start/resource-categories-and-access.md).
**Parameters**
**Parameters**
| Name | Type | Mandatory | Default Value | Description |
| Name | Type | Mandatory | Default Value | Description |
| fileAccess | boolean | Yes | true | Whether to enable access to the file system in the application. By default, this feature is enabled.|
| fileAccess | boolean | Yes | true | Whether to enable access to the file system in the application. By default, this feature is enabled.|
**Example**
**Example**
...
@@ -148,35 +148,6 @@ Sets whether to enable access to the file system in the application. Access to t
...
@@ -148,35 +148,6 @@ Sets whether to enable access to the file system in the application. Access to t
}
}
```
```
### fileFromUrlAccess<sup>9+</sup>
fileFromUrlAccess(fileFromUrlAccess: boolean)
Sets whether to allow the use of JavaScript scripts on web pages for access to content in the application file system. By default, this feature is disabled. Access to the files in **rawfile** specified through [$rawfile(filepath/filename)](../../quick-start/resource-categories-and-access.md) are not affected by the setting.
**Parameters**
| Name | Type | Mandatory | Default Value | Description |
| fileFromUrlAccess | boolean | Yes | false | Whether to allow the use of JavaScript scripts on web pages for access to content in the application file system. By default, this feature is disabled.|
@@ -496,13 +467,13 @@ Sets whether to enable geolocation access. By default, this feature is enabled.
...
@@ -496,13 +467,13 @@ Sets whether to enable geolocation access. By default, this feature is enabled.
mediaPlayGestureAccess(access: boolean)
mediaPlayGestureAccess(access: boolean)
Sets whether a manual click is required for video playback.
Sets whether video playback must be started by user gestures. This API is not applicable to videos that do not have an audio track or whose audio track is muted.
**Parameters**
**Parameters**
| Name | Type | Mandatory | Default Value | Description |
| Name | Type | Mandatory | Default Value | Description |
| webDebuggingAccess | boolean | Yes | false | Whether to enable web debugging.|
| webDebuggingAccess | boolean | Yes | false | Whether to enable web debugging.|
**Example**
**Example**
...
@@ -701,10 +672,6 @@ Sets whether to enable web debugging.
...
@@ -701,10 +672,6 @@ Sets whether to enable web debugging.
}
}
```
```
> **NOTE**<br>
>
> Only the following universal attributes are supported: [width](ts-universal-attributes-size.md#Attributes), [height](ts-universal-attributes-size.md#attributes), [padding](ts-universal-attributes-size.md#Attributes), [margin](ts-universal-attributes-size.md#attributes), and [border](ts-universal-attributes-border.md#attributes).
## Events
## Events
The universal events are not supported.
The universal events are not supported.
...
@@ -721,7 +688,7 @@ Triggered when **alert()** is invoked to display an alert dialog box on the web
...
@@ -721,7 +688,7 @@ Triggered when **alert()** is invoked to display an alert dialog box on the web
Triggered when the current page is about to exit after the user refreshes or closes the page. If the user refreshes the page, this callback is invoked only when the page has obtained focus.
Triggered when this page is about to exit after the user refreshes or closes the page. This callback is triggered only when the page has obtained focus.
**Parameters**
**Parameters**
...
@@ -779,7 +746,7 @@ Triggered when the current page is about to exit after the user refreshes or clo
...
@@ -779,7 +746,7 @@ Triggered when the current page is about to exit after the user refreshes or clo
| isRefreshed | boolean | Whether the page is reloaded. The value **true** means that the page is reloaded by invoking the [refresh](#refresh) API, and **false** means the opposite.|
| isRefreshed | boolean | Whether the page is reloaded. The value **true** means that the page is reloaded by invoking the [refresh](#refresh) API, and **false** means the opposite.|
**Example**
**Example**
...
@@ -1287,7 +1254,7 @@ Triggered when loading of the web page is complete. This API is used by an appli
...
@@ -1287,7 +1254,7 @@ Triggered when loading of the web page is complete. This API is used by an appli
| boolean | The value **true** means that the pop-up window provided by the system is displayed. The value **false** means that the default web pop-up window is displayed.|
| boolean | The value **true** means that the pop-up window provided by the system is displayed. The value **false** means that the default web pop-up window is displayed.|
**Example**
**Example**
...
@@ -1383,9 +1350,9 @@ Invoked to notify the **\<Web>** component of the URL of the loaded resource fil
...
@@ -1383,9 +1350,9 @@ Invoked to notify the **\<Web>** component of the URL of the loaded resource fil
| [WebResourceResponse](#webresourceresponse) | If response data is returned, the data is loaded based on the response data. If no response data is returned, null is returned, indicating that the data is loaded in the original mode.|
| [WebResourceResponse](#webresourceresponse) | If response data is returned, the data is loaded based on the response data. If no response data is returned, null is returned, indicating that the data is loaded in the original mode.|
**Example**
**Example**
...
@@ -1554,7 +1521,7 @@ Invoked when an HTTP authentication request is received.
...
@@ -1554,7 +1521,7 @@ Invoked when an HTTP authentication request is received.
| isAlert | boolean | Whether to open the target URL in a new window. The value **true** means to open the target URL in a new window, and **false** means to open the target URL in a new tab.|
| isAlert | boolean | Whether to open the target URL in a new window. The value **true** means to open the target URL in a new window, and **false** means to open the target URL in a new tab.|
| isUserTrigger | boolean | Whether the creation is triggered by the user. The value **true** means that the creation is triggered by the user, and **false** means the opposite.|
| isUserTrigger | boolean | Whether the creation is triggered by the user. The value **true** means that the creation is triggered by the user, and **false** means the opposite. |
| targetUrl | string | Target URL.|
| targetUrl | string | Target URL. |
| handler | [ControllerHandler](#controllerhandler9) | **WebController** instance for setting the new window.|
| handler | [ControllerHandler](#controllerhandler9) | **WebController** instance for setting the new window. |
**Example**
**Example**
...
@@ -2011,14 +1978,14 @@ Registers a callback for window creation.
...
@@ -2011,14 +1978,14 @@ Registers a callback for window creation.
| activeMatchOrdinal | number | Sequence number of the current match, which starts from 0. |
| numberOfMatches | number | Total number of matches. |
| isDoneCounting | boolean | Whether the search operation on the current page is complete. This API may be called multiple times until **isDoneCounting** is **true**.|
Implements the **ConsoleMessage** object. For details about the sample code, see [onConsole](#onconsole).
Implements the **ConsoleMessage** object. For the sample code, see [onConsole](#onconsole).
### getLineNumber
### getLineNumber
...
@@ -2111,7 +2113,7 @@ Obtains the path and name of the web page source file.
...
@@ -2111,7 +2113,7 @@ Obtains the path and name of the web page source file.
## JsResult
## JsResult
Implements the **JsResult** object, which indicates the result returned to the **\<Web>** component to indicate the user operation performed in the dialog box. For details about the sample code, see [onAlert Event](#onalert).
Implements the **JsResult** object, which indicates the result returned to the **\<Web>** component to indicate the user operation performed in the dialog box. For the sample code, see [onAlert Event](#onalert).
### handleCancel
### handleCancel
...
@@ -2139,7 +2141,7 @@ Notifies the **\<Web>** component of the user's confirm operation in the dialog
...
@@ -2139,7 +2141,7 @@ Notifies the **\<Web>** component of the user's confirm operation in the dialog
## FullScreenExitHandler<sup>9+</sup>
## FullScreenExitHandler<sup>9+</sup>
Defines a **FullScreenExitHandler** for listening for exiting full screen mode. For the sample code, see [onFullScreenEnter](#onfullscreenenter9).
Implements a **FullScreenExitHandler** object for listening for exiting full screen mode. For the sample code, see [onFullScreenEnter](#onfullscreenenter9).
### exitFullScreen<sup>9+</sup>
### exitFullScreen<sup>9+</sup>
...
@@ -2149,23 +2151,23 @@ Exits full screen mode.
...
@@ -2149,23 +2151,23 @@ Exits full screen mode.
## ControllerHandler<sup>9+</sup>
## ControllerHandler<sup>9+</sup>
Defines a **WebController** for new web components. For the sample code, see [onWindowNew](#onwindownew9).
Implements a **WebviewController** object for new **\<Web>** components. For the sample code, see [onWindowNew](#onwindownew9).
| data | string | Yes | - | Resource response data to set.|
| data | string | Yes | - | Resource response data to set. When set to a number, the value indicates a file handle.|
### setResponseEncoding<sup>9+</sup>
### setResponseEncoding<sup>9+</sup>
...
@@ -2415,7 +2417,7 @@ Sets the status code of the resource response.
...
@@ -2415,7 +2417,7 @@ Sets the status code of the resource response.
## FileSelectorResult<sup>9+</sup>
## FileSelectorResult<sup>9+</sup>
Notifies the **\<Web>** component of the file selection result. For details about the sample code, see [onShowFileSelector](#onshowfileselector9).
Notifies the **\<Web>** component of the file selection result. For the sample code, see [onShowFileSelector](#onshowfileselector9).
### handleFileList<sup>9+</sup>
### handleFileList<sup>9+</sup>
...
@@ -2431,7 +2433,7 @@ Instructs the **\<Web>** component to select a file.
...
@@ -2431,7 +2433,7 @@ Instructs the **\<Web>** component to select a file.
## FileSelectorParam<sup>9+</sup>
## FileSelectorParam<sup>9+</sup>
Implements the **FileSelectorParam** object. For details about the sample code, see [onShowFileSelector](#onshowfileselector9).
Implements the **FileSelectorParam** object. For the sample code, see [onShowFileSelector](#onshowfileselector9).
### getTitle<sup>9+</sup>
### getTitle<sup>9+</sup>
...
@@ -2483,7 +2485,7 @@ Checks whether multimedia capabilities are invoked.
...
@@ -2483,7 +2485,7 @@ Checks whether multimedia capabilities are invoked.
## HttpAuthHandler<sup>9+</sup>
## HttpAuthHandler<sup>9+</sup>
Implements the **HttpAuthHandler** object. For details about the sample code, see [onHttpAuthRequest](#onhttpauthrequest9).
Implements the **HttpAuthHandler** object. For the sample code, see [onHttpAuthRequest](#onhttpauthrequest9).
### cancel<sup>9+</sup>
### cancel<sup>9+</sup>
...
@@ -2524,7 +2526,7 @@ Uses the password cached on the server for authentication.
...
@@ -2524,7 +2526,7 @@ Uses the password cached on the server for authentication.
## SslErrorHandler<sup>9+</sup>
## SslErrorHandler<sup>9+</sup>
Implements an **SslErrorHandler** object. For details about the sample code, see [onSslErrorEventReceive Event](#onsslerroreventreceive9).
Implements an **SslErrorHandler** object. For the sample code, see [onSslErrorEventReceive Event](#onsslerroreventreceive9).
### handleCancel<sup>9+</sup>
### handleCancel<sup>9+</sup>
...
@@ -2540,7 +2542,7 @@ Continues using the SSL certificate.
...
@@ -2540,7 +2542,7 @@ Continues using the SSL certificate.
## ClientAuthenticationHandler<sup>9+</sup>
## ClientAuthenticationHandler<sup>9+</sup>
Defines a **ClientAuthenticationHandler** object returned by the **\<Web>** component. For details about the sample code, see [onClientAuthenticationRequest](#onclientauthenticationrequest9).
Implements a **ClientAuthenticationHandler** object returned by the **\<Web>** component. For the sample code, see [onClientAuthenticationRequest](#onclientauthenticationrequest9).
### confirm<sup>9+</sup>
### confirm<sup>9+</sup>
...
@@ -2550,10 +2552,10 @@ Uses the specified private key and client certificate chain.
...
@@ -2550,10 +2552,10 @@ Uses the specified private key and client certificate chain.
| resources | Array\<string\> | Yes | - | List of accessible resources requested by the web page.|
| resources | Array\<string\> | Yes | - | List of resources that can be requested by the web page with the permission to grant.|
## WebContextMenuParam<sup>9+</sup>
## WebContextMenuParam<sup>9+</sup>
Provides the information about the context menu that is displayed when a page element is long pressed. For details about the sample code, see [onContextMenuShow](#oncontextmenushow9).
Implements a context menu, which is displayed after the user long presses a specific element, such as an image or a link. For the sample code, see [onContextMenuShow](#oncontextmenushow9).
### x<sup>9+</sup>
### x<sup>9+</sup>
...
@@ -2625,8 +2627,8 @@ Obtains the X coordinate of the context menu.
...
@@ -2625,8 +2627,8 @@ Obtains the X coordinate of the context menu.
**Return value**
**Return value**
| Type | Description |
| Type | Description |
| --------------- | ----------------------- |
| ------ | ------------------ |
| number | If the display is normal, a non-negative integer is returned. Otherwise, **-1** is returned.|
| number | If the display is normal, a non-negative integer is returned. Otherwise, **-1** is returned.|
### y<sup>9+</sup>
### y<sup>9+</sup>
...
@@ -2637,8 +2639,8 @@ Obtains the Y coordinate of the context menu.
...
@@ -2637,8 +2639,8 @@ Obtains the Y coordinate of the context menu.
**Return value**
**Return value**
| Type | Description |
| Type | Description |
| --------------- | ----------------------- |
| ------ | ------------------ |
| number | If the display is normal, a non-negative integer is returned. Otherwise, **-1** is returned.|
| number | If the display is normal, a non-negative integer is returned. Otherwise, **-1** is returned.|
### getLinkUrl<sup>9+</sup>
### getLinkUrl<sup>9+</sup>
...
@@ -2649,20 +2651,20 @@ Obtains the URL of the destination link.
...
@@ -2649,20 +2651,20 @@ Obtains the URL of the destination link.
**Return value**
**Return value**
| Type | Description |
| Type | Description |
| --------------- | ----------------------- |
| ------ | ------------------------- |
| string | If it is a link that is being long pressed, the URL that has passed the security check is returned.|
| string | If it is a link that is being long pressed, the URL that has passed the security check is returned.|
### getUnfilterendLinkUrl<sup>9+</sup>
### getUnfilteredLinkUrl<sup>9+</sup>
getUnfilterendLinkUrl(): string
getUnfilteredLinkUrl(): string
Obtains the URL of the destination link.
Obtains the URL of the destination link.
**Return value**
**Return value**
| Type | Description |
| Type | Description |
| --------------- | ----------------------- |
| ------ | --------------------- |
| string | If it is a link that is being long pressed, the original URL is returned.|
| string | If it is a link that is being long pressed, the original URL is returned.|
### getSourceUrl<sup>9+</sup>
### getSourceUrl<sup>9+</sup>
...
@@ -2673,8 +2675,8 @@ Obtain the source URL.
...
@@ -2673,8 +2675,8 @@ Obtain the source URL.
**Return value**
**Return value**
| Type | Description |
| Type | Description |
| --------------- | ----------------------- |
| ------ | ------------------------ |
| string | If the selected element has the **src** attribute, the URL in the **src** is returned.|
| string | If the selected element has the **src** attribute, the URL in the **src** is returned.|
| retain | boolean | Yes | - | Whether the geolocation permission status can be saved to the system. The **[GeolocationPermissions](#geolocationpermissions9)** API can be used to manage the geolocation permission status saved to the system.|
| retain | boolean | Yes | - | Whether the geolocation permission status can be saved to the system. You can manage the geolocation permissions saved to the system through [GeolocationPermissions<sup>9+</sup>](../apis/js-apis-webview.md#geolocationpermissions).|
## WebController
## WebController
Defines a **WebController** to control the behavior of the **\<Web>** component. A **WebController** can control only one **\<Web>** component, and the APIs in the **WebController** can be invoked only after it has been bound to the target **\<Web>** component.
Implements a **WebController** to control the behavior of the **\<Web>** component. A **WebController** can control only one **\<Web>** component, and the APIs in the **WebController** can be invoked only after it has been bound to the target **\<Web>** component.
This API is deprecated since API version 9. You are advised to use [WebviewController<sup>9+</sup>](../apis/js-apis-webview.md#webviewcontroller).
### Creating an Object
### Creating an Object
...
@@ -2733,12 +2737,14 @@ Defines a **WebController** to control the behavior of the **\<Web>** component.
...
@@ -2733,12 +2737,14 @@ Defines a **WebController** to control the behavior of the **\<Web>** component.
webController: WebController = new WebController()
webController: WebController = new WebController()
```
```
### requestFocus
### requestFocus<sup>(deprecated)</sup>
requestFocus()
requestFocus()
Requests focus for this web page.
Requests focus for this web page.
This API is deprecated since API version 9. You are advised to use [requestFocus<sup>9+</sup>](../apis/js-apis-webview.md#requestfocus).
**Example**
**Example**
```ts
```ts
...
@@ -2760,12 +2766,14 @@ Requests focus for this web page.
...
@@ -2760,12 +2766,14 @@ Requests focus for this web page.
}
}
```
```
### accessBackward
### accessBackward<sup>(deprecated)</sup>
accessBackward(): boolean
accessBackward(): boolean
Checks whether going to the previous page can be performed on the current page.
Checks whether going to the previous page can be performed on the current page.
This API is deprecated since API version 9. You are advised to use [accessBackward<sup>9+</sup>](../apis/js-apis-webview.md#accessbackward).
**Return value**
**Return value**
| Type | Description |
| Type | Description |
...
@@ -2794,12 +2802,14 @@ Checks whether going to the previous page can be performed on the current page.
...
@@ -2794,12 +2802,14 @@ Checks whether going to the previous page can be performed on the current page.
}
}
```
```
### accessForward
### accessForward<sup>(deprecated)</sup>
accessForward(): boolean
accessForward(): boolean
Checks whether going to the next page can be performed on the current page.
Checks whether going to the next page can be performed on the current page.
This API is deprecated since API version 9. You are advised to use [accessForward<sup>9+</sup>](../apis/js-apis-webview.md#accessforward).
**Return value**
**Return value**
| Type | Description |
| Type | Description |
...
@@ -2828,12 +2838,14 @@ Checks whether going to the next page can be performed on the current page.
...
@@ -2828,12 +2838,14 @@ Checks whether going to the next page can be performed on the current page.
}
}
```
```
### accessStep
### accessStep<sup>(deprecated)</sup>
accessStep(step: number): boolean
accessStep(step: number): boolean
Performs a specific number of steps forward or backward from the current page.
Performs a specific number of steps forward or backward from the current page.
This API is deprecated since API version 9. You are advised to use [accessStep<sup>9+</sup>](../apis/js-apis-webview.md#accessstep).
**Parameters**
**Parameters**
| Name | Type | Mandatory | Default Value | Description |
| Name | Type | Mandatory | Default Value | Description |
...
@@ -2869,12 +2881,14 @@ Performs a specific number of steps forward or backward from the current page.
...
@@ -2869,12 +2881,14 @@ Performs a specific number of steps forward or backward from the current page.
}
}
```
```
### backward
### backward<sup>(deprecated)</sup>
backward(): void
backward(): void
Goes to the previous page based on the history stack. This API is generally used together with **accessBackward**.
Goes to the previous page based on the history stack. This API is generally used together with **accessBackward**.
This API is deprecated since API version 9. You are advised to use [backward<sup>9+</sup>](../apis/js-apis-webview.md#backward).
**Example**
**Example**
```ts
```ts
...
@@ -2896,12 +2910,14 @@ Goes to the previous page based on the history stack. This API is generally used
...
@@ -2896,12 +2910,14 @@ Goes to the previous page based on the history stack. This API is generally used
}
}
```
```
### forward
### forward<sup>(deprecated)</sup>
forward(): void
forward(): void
Goes to the next page based on the history stack. This API is generally used together with **accessForward**.
Goes to the next page based on the history stack. This API is generally used together with **accessForward**.
This API is deprecated since API version 9. You are advised to use [forward<sup>9+</sup>](../apis/js-apis-webview.md#forward).
**Example**
**Example**
```ts
```ts
...
@@ -2957,12 +2973,14 @@ Performs a specific number of steps forward or backward on the current page base
...
@@ -2957,12 +2973,14 @@ Performs a specific number of steps forward or backward on the current page base
Deletes a specific application JavaScript object that is registered with the window through **registerJavaScriptProxy**. The deletion takes effect immediately, with no need for invoking the [refresh](#refresh) API.
Deletes a specific application JavaScript object that is registered with the window through **registerJavaScriptProxy**. The deletion takes effect immediately, with no need for invoking the [refresh](#refresh) API.
This API is deprecated since API version 9. You are advised to use [deleteJavaScriptRegister<sup>9+</sup>](../apis/js-apis-webview.md#deletejavascriptregister).
**Parameters**
**Parameters**
| Name | Type | Mandatory | Default Value | Description |
| Name | Type | Mandatory | Default Value | Description |
...
@@ -2991,12 +3009,14 @@ Deletes a specific application JavaScript object that is registered with the win
...
@@ -2991,12 +3009,14 @@ Deletes a specific application JavaScript object that is registered with the win
}
}
```
```
### getHitTest
### getHitTest<sup>(deprecated)</sup>
getHitTest(): HitTestType
getHitTest(): HitTestType
Obtains the element type of the area being clicked.
Obtains the element type of the area being clicked.
This API is deprecated since API version 9. You are advised to use [getHitTest<sup>9+</sup>](../apis/js-apis-webview.md#gethittest).
**Return value**
**Return value**
| Type | Description |
| Type | Description |
...
@@ -3191,7 +3211,7 @@ Obtains the default user agent of the current web page.
...
@@ -3191,7 +3211,7 @@ Obtains the default user agent of the current web page.
@@ -3201,6 +3221,8 @@ If **baseUrl** is set to a data URL, the encoded string will be loaded by the **
...
@@ -3201,6 +3221,8 @@ If **baseUrl** is set to a data URL, the encoded string will be loaded by the **
If **baseUrl** is set to an HTTP or HTTPS URL, the encoded string will be processed by the **\<Web>** component as a non-encoded string in a manner similar to **loadUrl**.
If **baseUrl** is set to an HTTP or HTTPS URL, the encoded string will be processed by the **\<Web>** component as a non-encoded string in a manner similar to **loadUrl**.
This API is deprecated since API version 9. You are advised to use [loadData<sup>9+</sup>](../apis/js-apis-webview.md#loaddata).
**Parameters**
**Parameters**
| Name | Type | Mandatory | Default Value | Description |
| Name | Type | Mandatory | Default Value | Description |
...
@@ -3236,7 +3258,7 @@ If **baseUrl** is set to an HTTP or HTTPS URL, the encoded string will be proces
...
@@ -3236,7 +3258,7 @@ If **baseUrl** is set to an HTTP or HTTPS URL, the encoded string will be proces
Registers a JavaScript object and invokes the methods of the object in the window. You must invoke the [refresh](#refresh) API for the registration to take effect.
Registers a JavaScript object with the window. APIs of this object can then be invoked in the window. You must invoke the [refresh](#refresh) API for the registration to take effect.
This API is deprecated since API version 9. You are advised to use [registerJavaScriptProxy<sup>9+</sup>](../apis/js-apis-webview.md#registerjavascriptproxy).
**Parameters**
**Parameters**
...
@@ -3520,11 +3554,13 @@ Registers a JavaScript object and invokes the methods of the object in the windo
...
@@ -3520,11 +3554,13 @@ Registers a JavaScript object and invokes the methods of the object in the windo
Asynchronously executes a JavaScript script. This API uses a callback to return the script execution result. **runJavaScript** can be invoked only after **loadUrl** is executed. For example, it can be executed in **onPageEnd**.
Executes a JavaScript script. This API uses an asynchronous callback to return the script execution result. **runJavaScript** can be invoked only after **loadUrl** is executed. For example, it can be invoked in **onPageEnd**.
This API is deprecated since API version 9. You are advised to use [runJavaScript<sup>9+</sup>](../apis/js-apis-webview.md#runjavascript).
**Parameters**
**Parameters**
...
@@ -3579,12 +3615,14 @@ Asynchronously executes a JavaScript script. This API uses a callback to return
...
@@ -3579,12 +3615,14 @@ Asynchronously executes a JavaScript script. This API uses a callback to return
```
```
### stop
### stop<sup>(deprecated)</sup>
stop()
stop()
Stops page loading.
Stops page loading.
This API is deprecated since API version 9. You are advised to use [stop<sup>9+</sup>](../apis/js-apis-webview.md#stop).
**Example**
**Example**
```ts
```ts
...
@@ -3606,12 +3644,14 @@ Stops page loading.
...
@@ -3606,12 +3644,14 @@ Stops page loading.
}
}
```
```
### clearHistory
### clearHistory<sup>(deprecated)</sup>
clearHistory(): void
clearHistory(): void
Clears the browsing history.
Clears the browsing history.
This API is deprecated since API version 9. You are advised to use [clearHistory<sup>9+</sup>](../apis/js-apis-webview.md#clearhistory).
**Example**
**Example**
```ts
```ts
...
@@ -3664,7 +3704,7 @@ Clears the user operation corresponding to the SSL certificate error event recor
...
@@ -3664,7 +3704,7 @@ Clears the user operation corresponding to the SSL certificate error event recor
clearClientAuthenticationCache(): void
clearClientAuthenticationCache(): void
Clears the user operation corresponding to the client certificate request event recorded by the \<Web> component.
Clears the user operation corresponding to the client certificate request event recorded by the **\<Web>** component.
@@ -3898,8 +3938,115 @@ Obtains the URL of the current page.
...
@@ -3898,8 +3938,115 @@ Obtains the URL of the current page.
}
}
```
```
### searchAllAsync<sup>9+</sup>
searchAllAsync(searchString: string): void
Searches the web page for content that matches the keyword specified by **'searchString'** and highlights the matches on the page. This API returns the result asynchronously through [onSearchResultReceive](#onsearchresultreceive9).
**Parameters**
| Name | Type | Mandatory | Default Value | Description |
| origin | string | Yes | - | Index of the origin.|
| callback | AsyncCallback\<boolean\> | Yes| - | Callback used to return the geolocation permission status of the specified source. If the operation is successful, the value **true** means that the geolocation permission is granted, and **false** means the opposite. If the operation fails, the geolocation permission status of the specified source is not found.|
| Promise\<boolean\> | Promise used to return the geolocation permission status of the specified source. If the operation is successful, the value **true** means that the geolocation permission is granted, and **false** means the opposite. If the operation fails, the geolocation permission status of the specified source is not found.|
@@ -4831,12 +4196,16 @@ Obtains the geolocation permission status of all sources. This API uses a promis
...
@@ -4831,12 +4196,16 @@ Obtains the geolocation permission status of all sources. This API uses a promis
}
}
```
```
## WebStorage<sup>9+</sup>
### saveCookieSync<sup>9+</sup>
Implements the **WebStorage** object, which can be used to manage the Web SQL and the HTML5 Web Storage API. All **\<Web>** components in an application share one **WebStorage**.
saveCookieSync(): boolean
### deleteAllData<sup>9+</sup>
static deleteAllData(): void
Saves the cookies in the memory to the drive. This API returns the result synchronously.
**Return value**
Deletes all data in the Web SQL database.
| Type | Description |
| ------- | -------------------- |
| boolean | Operation result.|
**Example**
**Example**
...
@@ -4847,29 +4216,30 @@ Deletes all data in the Web SQL database.
...
@@ -4847,29 +4216,30 @@ Deletes all data in the Web SQL database.
| callback | AsyncCallback<Array<[WebStorageOrigin](#webstorageorigin9)>> | Yes | Callback used to return the information about the origins. For details, see **WebStorageOrigin**.|
| callback | AsyncCallback\<boolean> | Yes | - | Callback used to return the operation result.|
**Example**
**Example**
...
@@ -4914,40 +4289,31 @@ Obtains information about all origins that are currently using the Web SQL datab
...
@@ -4914,40 +4289,31 @@ Obtains information about all origins that are currently using the Web SQL datab
| Promise<Array<[WebStorageOrigin](#webstorageorigin9)>> | Promise used to return the information about the origins. For details, see **WebStorageOrigin**.|
| boolean | Whether the **WebCookieManager** instance has the permission to send and receive cookies.|
**Example**
**Example**
...
@@ -4958,41 +4324,30 @@ Obtains information about all origins that are currently using the Web SQL datab
...
@@ -4958,41 +4324,30 @@ Obtains information about all origins that are currently using the Web SQL datab
Searches the web page for content that matches the keyword specified by **'searchString'** and highlights the matches on the page. This API returns the result asynchronously through [onSearchResultReceive](#onsearchresultreceive9).
**Parameters**
| Name | Type | Mandatory | Default Value | Description |
| activeMatchOrdinal | number | Sequence number of the current match, which starts from 0.|
| numberOfMatches | number | Total number of matches.|
| isDoneCounting | boolean | Whether the search operation on the current page is complete. This API may be called multiple times until **isDoneCounting** is **true**.|
Loads an animation. Before calling this method, declare the **Animator('\__lottie\_ets')** object and check that the canvas layout is complete. This method can be used together with a lifecycle callback of the **Canvas** component, for example, **onAppear()** and **onPageShow()**.
Loads an animation. Before calling this API, declare the **Animator('__lottie_ets')** object and make sure the canvas layout is complete. This API can be used together with the lifecycle callback **onReady()** of the **Canvas** component.
| path | string | Yes | Path of the animation resource file in the HAP file. The resource file must be in JSON format. Example: **path: "common/lottie/data.json"**|
| path | string | Yes | Path of the animation resource file in the HAP file. The resource file must be in JSON format. Example: **path: "common/lottie/data.json"**|
| container | object | Yes | Canvas drawing context. A **CanvasRenderingContext2D** object must be declared in advance.|
| container | object | Yes | Canvas drawing context. A **CanvasRenderingContext2D** object must be declared in advance.|
| render | string | Yes | Rendering type. The value can only be **"canvas"**. |
| render | string | Yes | Rendering type. The value can only be **"canvas"**. |
| loop | boolean \| number | No | If the value is of the Boolean type, this parameter indicates whether to repeat the animation cyclically after the animation ends; the default value is **true**. If the value is of the number type and is greater than or equal to 1, this parameter indicates the number of times the animation plays.|
| loop | boolean \| number | No | If the value is of the Boolean type, this parameter indicates whether to repeat the animation cyclically after the animation ends; the default value is **true**. If the value is of the number type and is greater than or equal to 1, this parameter indicates the number of times the animation plays.|
| autoplay | boolean | No | Whether to automatically play the animation. The default value is **true**. |
| autoplay | boolean | No | Whether to automatically play the animation.<br>Default value: **true** |
| name | string | No | Custom animation name. In later versions, the name can be used to reference and control the animation. The default value is null. |
| name | string | No | Custom animation name. In later versions, the name can be used to reference and control the animation.<br/>Default value: null |
| initialSegment | [number, number] | No | Start frame and end frame of the animation, respectively. |
| initialSegment | [number, number] | No | Start frame and end frame of the animation, respectively. |
## lottie.destroy
## lottie.destroy
destroy(name: string): void
destroy(name: string): void
Destroys the animation. This method must be called when a page exits. This method can be used together with a lifecycle callback of the **Canvas** component, for example, **onDisappear()** and **onPageHide()**.
Destroys the animation. This API must be called when a page exits. This API can be used together with a lifecycle callback of the **Canvas** component, for example, **onDisappear()** and **onPageHide()**.
| name | string | Yes | Name of the animation to destroy, which is the same as the **name** in the **loadAnimation**interface. By default, all animations are destroyed.|
| name | string | Yes | Name of the animation to destroy, which is the same as the **name** in the **loadAnimation**API. By default, all animations are destroyed. |
**Example**
**Example**
```ts
```ts
// xxx.ets
// xxx.ets
importlottiefrom'@ohos/lottieETS'
importlottiefrom'@ohos/lottieETS'
...
@@ -78,7 +79,7 @@ Destroys the animation. This method must be called when a page exits. This metho
...
@@ -78,7 +79,7 @@ Destroys the animation. This method must be called when a page exits. This metho
| name | string | Yes | Name of the animation to play, which is the same as the **name** in the **loadAnimation**interface. By default, all animations are played.|
| name | string | Yes | Name of the animation to play, which is the same as the **name** in the **loadAnimation**API. By default, all animations are played. |
**Example**
**Example**
...
@@ -152,7 +153,7 @@ Pauses a specified animation. The next time **lottie.play()** is called, the ani
...
@@ -152,7 +153,7 @@ Pauses a specified animation. The next time **lottie.play()** is called, the ani
| name | string | Yes | Name of the animation to pause, which is the same as the **name** in the **loadAnimation**interface. By default, all animations are paused.|
| name | string | Yes | Name of the animation to pause, which is the same as the **name** in the **loadAnimation**API. By default, all animations are paused. |
**Example**
**Example**
...
@@ -165,13 +166,13 @@ Pauses a specified animation. The next time **lottie.play()** is called, the ani
...
@@ -165,13 +166,13 @@ Pauses a specified animation. The next time **lottie.play()** is called, the ani
togglePause(name: string): void
togglePause(name: string): void
Pauses or plays a specified animation. This method is equivalent to the switching between **lottie.play()** and **lottie.pause()**.
Pauses or plays a specified animation. This API is equivalent to the switching between **lottie.play()** and **lottie.pause()**.
| name | string | Yes | Name of the target animation, which is the same as the **name** in the **loadAnimation**interface. By default, all animations are paused.|
| name | string | Yes | Name of the target animation, which is the same as the **name** in the **loadAnimation**API. By default, all animations are paused or played. |
**Example**
**Example**
...
@@ -190,7 +191,7 @@ Stops the specified animation. The next time **lottie.play()** is called, the an
...
@@ -190,7 +191,7 @@ Stops the specified animation. The next time **lottie.play()** is called, the an
| name | string | Yes | Name of the target animation, which is the same as the **name** in the **loadAnimation**interface. By default, all animations are paused.|
| name | string | Yes | Name of the target animation, which is the same as the **name** in the **loadAnimation**API. By default, all animations are stopped. |
**Example**
**Example**
...
@@ -209,8 +210,8 @@ Sets the playback speed of the specified animation.
...
@@ -209,8 +210,8 @@ Sets the playback speed of the specified animation.
| speed | number | Yes | Playback speed. The value is a floating-point number. If the value is greater than 0, the animation plays in forward direction. If the value is less than 0, the animation plays in reversed direction. If the value is 0, the animation is paused. If the value is 1.0 or -1.0, the animation plays at the normal speed.|
| speed | number | Yes | Playback speed. The value is a floating-point number. If the value is greater than 0, the animation plays in forward direction. If the value is less than 0, the animation plays in reversed direction. If the value is **0**, the animation is paused. If the value is **1.0** or **-1.0**, the animation plays at the normal speed. |
| name | string | Yes | Name of the target animation, which is the same as the **name** in the **loadAnimation**interface. By default, all animations are stopped.|
| name | string | Yes | Name of the target animation, which is the same as the **name** in the **loadAnimation**API. By default, all animations are set. |
**Example**
**Example**
...
@@ -230,7 +231,7 @@ Sets the direction in which the specified animation plays.
...
@@ -230,7 +231,7 @@ Sets the direction in which the specified animation plays.
| direction | AnimationDirection | Yes | Direction in which the animation plays. **1**: forwards; **-1**: backwards. When set to play backwards, the animation plays from the current playback progress to the first frame. When this setting is combined with **loop** being set to **true**, the animation plays backwards continuously. When the value of **speed** is less than 0, the animation also plays backwards.<br>AnimationDirection: 1 \| -1 |
| direction | AnimationDirection | Yes | Direction in which the animation plays. **1**: forwards; **-1**: backwards. When set to play backwards, the animation plays from the current playback progress to the first frame. When this setting is combined with **loop** being set to **true**, the animation plays backwards continuously. When the value of **speed** is less than 0, the animation also plays backwards.<br>AnimationDirection: 1 \| -1 |
| name | string | Yes | Name of the target animation, which is the same as the **name** in the **loadAnimation**interface. By default, all animations are set.|
| name | string | Yes | Name of the target animation, which is the same as the **name** in the **loadAnimation**API. By default, all animations are set. |
**Example**
**Example**
...
@@ -241,7 +242,7 @@ Sets the direction in which the specified animation plays.
...
@@ -241,7 +242,7 @@ Sets the direction in which the specified animation plays.
## AnimationItem
## AnimationItem
Defines an **AnimationItem** object, which is returned by the **loadAnimation**interface and has attributes and interfaces. The attributes are described as follows:
Defines an **AnimationItem** object, which is returned by the **loadAnimation**API and has attributes and APIs. The attributes are described as follows:
@@ -253,18 +254,18 @@ Defines an **AnimationItem** object, which is returned by the **loadAnimation**
...
@@ -253,18 +254,18 @@ Defines an **AnimationItem** object, which is returned by the **loadAnimation**
| totalFrames | number | Total number of frames in the animation segment that is being played. |
| totalFrames | number | Total number of frames in the animation segment that is being played. |
| frameRate | number | Frame rate (frame/s). |
| frameRate | number | Frame rate (frame/s). |
| frameMult | number | Frame rate (frame/ms). |
| frameMult | number | Frame rate (frame/ms). |
| playSpeed | number | Playback speed. The value is a floating-point number. If the value is greater than 0, the animation plays forward. If the value is less than 0, the animation plays backward. If the value is 0, the animation is paused.|If the value is **1.0** or **-1.0**, the animation plays at the normal speed.|
| playSpeed | number | Playback speed. The value is a floating-point number. If the value is greater than 0, the animation plays forward. If the value is less than 0, the animation plays backward. If the value is **0**, the animation is paused. If the value is **1.0** or **-1.0**, the animation plays at the normal speed. |
| playDirection | number | Playback direction. The options are **1** (forward) and **-1** (backward). |
| playDirection | number | Playback direction.<br>**1**: forward.<br/>**-1**: backward. |
| playCount | number | Number of times the animation plays. |
| playCount | number | Number of times the animation plays. |
| isPaused | boolean | Whether the current animation is paused. The value **true** means that the animation is paused. |
| isPaused | boolean | Whether the current animation is paused. The value **true** means that the animation is paused. |
| autoplay | boolean | Whether to automatically play the animation upon completion of the loading. The value **false** means that the **play()**interface needs to be called to start playing.|
| autoplay | boolean | Whether to automatically play the animation upon completion of the loading. The value **false** means that the **play()**API needs to be called to start playing. |
| loop | boolean \| number | If the value is of the Boolean type, this parameter indicates whether to repeat the animation cyclically after the animation ends. If the value is of the number type and is greater than or equal to 1, this parameter indicates the number of times the animation plays. |
| loop | boolean \| number | If the value is of the Boolean type, this parameter indicates whether to repeat the animation cyclically after the animation ends. If the value is of the number type and is greater than or equal to 1, this parameter indicates the number of times the animation plays. |
| renderer | any | Animation rendering object, which depends on the rendering type. |
| renderer | any | Animation rendering object, which depends on the rendering type. |
| animationID | string | Animation ID. |
| animationID | string | Animation ID. |
| timeCompleted | number | Number of frames that are played for an animation sequence. The value is affected by the setting of **AnimationSegment** and is the same as the value of **totalFrames**.|
| timeCompleted | number | Number of frames that are played for an animation sequence. The value is affected by the setting of **AnimationSegment** and is the same as the value of **totalFrames**.|
| segmentPos | number | ID of the current animation segment. The value is a positive integer greater than or equal to 0. |
| segmentPos | number | ID of the current animation segment. The value is a positive integer greater than or equal to 0. |
| isSubframeEnabled | boolean | Whether the precision of **currentFrame** is a floating point number. |
| isSubframeEnabled | boolean | Whether the precision of **currentFrame** is a floating point number. |
| segments | AnimationSegment \| AnimationSegment[] | Current segment of the animation. |
| segments | AnimationSegment \| AnimationSegment[] | Current segment of the animation. |
## AnimationItem.play
## AnimationItem.play
...
@@ -309,7 +310,7 @@ Destroys an animation.
...
@@ -309,7 +310,7 @@ Destroys an animation.
pause(name?: string): void
pause(name?: string): void
Pauses an animation. When the **play**interface is called next time, the animation is played from the current frame.
Pauses an animation. When the **play**API is called next time, the animation is played from the current frame.
**Parameters**
**Parameters**
...
@@ -328,7 +329,7 @@ Pauses an animation. When the **play** interface is called next time, the animat
...
@@ -328,7 +329,7 @@ Pauses an animation. When the **play** interface is called next time, the animat
togglePause(name?: string): void
togglePause(name?: string): void
Pauses or plays an animation. This method is equivalent to the switching between **play** and **pause**.
Pauses or plays an animation. This API is equivalent to the switching between **play** and **pause**.
**Parameters**
**Parameters**
...
@@ -347,7 +348,7 @@ Pauses or plays an animation. This method is equivalent to the switching between
...
@@ -347,7 +348,7 @@ Pauses or plays an animation. This method is equivalent to the switching between
stop(name?: string): void
stop(name?: string): void
Stops an animation. When the **play**interface is called next time, the animation is played from the first frame.
Stops an animation. When the **play**API is called next time, the animation is played from the first frame.
**Parameters**
**Parameters**
...
@@ -372,7 +373,7 @@ Sets the playback speed of an animation.
...
@@ -372,7 +373,7 @@ Sets the playback speed of an animation.
| speed | number | Yes | Playback speed. The value is a floating-point number. If the value is greater than 0, the animation plays forward. If the value is less than 0, the animation plays backward. If the value is 0, the animation is paused.|If the value is **1.0** or **-1.0**, the animation plays at the normal speed.|
| speed | number | Yes | Playback speed. The value is a floating-point number. If the value is greater than 0, the animation plays forward. If the value is less than 0, the animation plays backward. If the value is **0**, the animation is paused. If the value is **1.0** or **-1.0**, the animation plays at the normal speed. |
**Example**
**Example**
...
@@ -411,8 +412,8 @@ Sets the animation to stop at the specified frame or time.
...
@@ -411,8 +412,8 @@ Sets the animation to stop at the specified frame or time.
| value | number | Yes | Frame ID (greater than or equal to 0) or time progress (ms) at which the animation will stop. |
| value | number | Yes | Frame ID (greater than or equal to 0) or time progress (ms) at which the animation will stop. |
| isFrame | boolean | No | Whether to set the animation to stop at the specified frame. The value **true** means to set the animation to stop at the specified frame, and **false** means to set the animation to stop at the specified time progress. The default value is **false**.|
| isFrame | boolean | No | Whether to set the animation to stop at the specified frame. The value **true** means to set the animation to stop at the specified frame, and **false** means to set the animation to stop at the specified time progress.<br/>Default value: **false**|
| name | string | No | Name of the target animation. By default, the value is null. |
| name | string | No | Name of the target animation. By default, the value is null. |
**Example**
**Example**
...
@@ -435,8 +436,8 @@ Sets the animation to start from the specified frame or time progress.
...
@@ -435,8 +436,8 @@ Sets the animation to start from the specified frame or time progress.
| value | number | Yes | Frame ID (greater than or equal to 0) or time progress (ms) at which the animation will start. |
| value | number | Yes | Frame ID (greater than or equal to 0) or time progress (ms) at which the animation will start. |
| isFrame | boolean | Yes | Whether to set the animation to start from the specified frame. The value **true** means to set the animation to start from the specified frame, and **false** means to set the animation to start from the specified time progress. The default value is **false**.|
| isFrame | boolean | Yes | Whether to set the animation to start from the specified frame. The value **true** means to set the animation to start from the specified frame, and **false** means to set the animation to start from the specified time progress.<br/>Default value: **false**|
| name | string | No | Name of the target animation. By default, the value is null. |
| name | string | No | Name of the target animation.<br/>Default value: null |
**Example**
**Example**
...
@@ -459,7 +460,7 @@ Sets the animation to play only the specified segment.
...
@@ -459,7 +460,7 @@ Sets the animation to play only the specified segment.
| segments | AnimationSegment = [number, number] \| AnimationSegment[] | Yes | Segment or segment list.<br>If all segments in the segment list are played, only the last segment is played in the next cycle.|
| segments | AnimationSegment = [number, number] \| AnimationSegment[] | Yes | Segment or segment list.<br>If all segments in the segment list are played, only the last segment is played in the next cycle.|
| forceFlag | boolean | Yes | Whether the settings take effect immediately. The value **true** means the settings take effect immediately, and **false** means the settings take effect until the current cycle of playback is completed. |
| forceFlag | boolean | Yes | Whether the settings take effect immediately. The value **true** means the settings take effect immediately, and **false** means the settings take effect until the current cycle of playback is completed. |
**Example**
**Example**
...
@@ -475,7 +476,7 @@ Sets the animation to play only the specified segment.
...
@@ -475,7 +476,7 @@ Sets the animation to play only the specified segment.
resetSegments(forceFlag: boolean): void
resetSegments(forceFlag: boolean): void
Resets the settings configured by the **playSegments**method to play all the frames.
Resets the settings configured by the **playSegments**API to play all the frames.
**Parameters**
**Parameters**
...
@@ -526,13 +527,13 @@ Sets the precision of the **currentFrame** attribute to display floating-point n
...
@@ -526,13 +527,13 @@ Sets the precision of the **currentFrame** attribute to display floating-point n
getDuration(inFrames?: boolean): void
getDuration(inFrames?: boolean): void
Obtains the duration (irrelevant to the playback speed) or number of frames for playing an animation sequence. The settings are related to the input parameter **initialSegment** of the **Lottie.loadAnimation**interface.
Obtains the duration (irrelevant to the playback speed) or number of frames for playing an animation sequence. The settings are related to the input parameter **initialSegment** of the **Lottie.loadAnimation**API.
| inFrames | boolean | No | Whether to obtain the duration or number of frames.<br>**true**: number of frames.<br>**false**: duration, in ms.<br>Default value: **false**|
| inFrames | boolean | No | Whether to obtain the duration or number of frames.<br>**true**: number of frames.<br>**false**: duration, in ms.<br/>Default value: **false**|
**Example**
**Example**
...
@@ -545,7 +546,7 @@ Obtains the duration (irrelevant to the playback speed) or number of frames for
...
@@ -545,7 +546,7 @@ Obtains the duration (irrelevant to the playback speed) or number of frames for
Adds an event listener. After the event is complete, the specified callback function is triggered. This method returns the function object that can delete the event listener.
Adds an event listener. After the event is complete, the specified callback is triggered. This API returns the function object that can delete the event listener.
| name | AnimationEventName | Yes | Animation event type. The available options are as follows:<br>'enterFrame', 'loopComplete', 'complete', 'segmentStart', 'destroy', 'config_ready', 'data_ready', 'DOMLoaded', 'error', 'data_failed', 'loaded_images'|
| name | AnimationEventName | Yes | Animation event type. The available options are as follows:<br>'enterFrame', 'loopComplete', 'complete', 'segmentStart', 'destroy', 'config_ready', 'data_ready', 'DOMLoaded', 'error', 'data_failed', 'loaded_images'|
| callback | AnimationEventCallback<T> | No | Custom callback. By default, the value is null, meaning that all callbacks of the event will be removed. |
| callback | AnimationEventCallback<T> | No | Custom callback. By default, the value is null, meaning that all callbacks of the event will be removed. |