openharmony 鸿蒙 get-pastedata-permission-guidelines

2025-06-06 浏览 (1)

Requesting Permissions to Access the Pasteboard

Overview

In API version 12 and later, permission control is added to the pasteboard reading API to enhance user privacy protection.

Related APIs:

NameDescription
getData( callback: AsyncCallback<PasteData>): voidReads a PasteData object from the pasteboard. This API uses an asynchronous callback to return the result.
getData(): Promise<PasteData>Reads a PasteData object from the pasteboard. This API uses a promise to return the result.
getDataSync(): PasteDataReads data from the system pasteboard. This API returns the result synchronously.
getUnifiedData(): Promise<udc.UnifiedData>Reads the data of a unified data object from the system pasteboard.
getUnifiedDataSync(): udc.UnifiedDataReads the data of a unified data object from the system pasteboard. This API returns the result synchronously.
OH_UdmfData * OH_Pasteboard_GetData (OH_Pasteboard *pasteboard, int *status)Obtains data from the pasteboard.

Accessing Pasteboard Content

Applications can access the pasteboard content in either of the following ways:

  • Using security components

    Applications that use the security components to access the pasteboard content do not need to request the permission.

    Applications that use the security components can access the pasteboard content without any adaptation.

  • Requesting the ohos.permission.READ_PASTEBOARD permission

    ohos.permission.READ_PASTEBOARD is a restricted user_grant permission. Applications that use customized components can request the ohos.permission.READ_PASTEBOARD permission to access the pasteboard content with user authorization.

    How to request permissions:

    1. Apply for high-level permissions through ACL.

    2. Declare permissions in the module.json5 configuration file.

    3. Request user authorization in a dialog box.

你可能感兴趣的鸿蒙文章

harmony 鸿蒙Pasteboard Service

harmony 鸿蒙Using the Pasteboard to Copy and Paste (C/C++)

harmony 鸿蒙Using the Delayed Copy and Paste Function of the Pasteboard

harmony 鸿蒙Using the Pasteboard to Copy and Paste

  • 所属分类: 后端技术
  • 本文标签: 鸿蒙 软件
  • 版权声明: 本文链接 https://seaxiang.com/blog/qht6qH