openharmony 鸿蒙 arkts-apis-photoAccessHelper-f

2026-08-25 浏览 (1)

Functions

NOTE

The initial APIs of this module are supported since API version 10. Newly added APIs will be marked with a superscript to indicate their earliest API version.

Modules to Import

import { photoAccessHelper } from '@kit.MediaLibraryKit';

photoAccessHelper.getPhotoAccessHelper

getPhotoAccessHelper(context: Context): PhotoAccessHelper

Obtains a PhotoAccessHelper instance for accessing and modifying media files in the album.

Model restriction: This API can be used only in the stage model.

Atomic service API: This API can be used in atomic services since API version 11.

System capability: SystemCapability.FileManagement.PhotoAccessHelper.Core

Parameters

NameTypeMandatoryDescription
contextContextYesContext of the ability instance.

Return value

TypeDescription
PhotoAccessHelperPhotoAccessHelper instance obtained.

Error codes

For details about the error codes, see Universal Error Codes.

IDError Message
401Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. Parameter verification failed.

Example

// The phAccessHelper instance obtained is a global object. It is used by default in subsequent operations. If the code snippet is not added, an error will be reported indicating that phAccessHelper is not defined.
// Obtain the context from the component and ensure that the return value of this.getUIContext().getHostContext() is UIAbilityContext.
import { common } from '@kit.AbilityKit';

@Entry
@Component
struct Index {
  build() {
    Row() {
      Button("example").onClick(async () => {
        let context: Context = this.getUIContext().getHostContext() as common.UIAbilityContext;
        let phAccessHelper = photoAccessHelper.getPhotoAccessHelper(context);
      }).width('100%')
    }
    .height('90%')
  }
}

你可能感兴趣的鸿蒙文章

openharmony 鸿蒙 capi-mediaassetmanager-oh-mediaassetmanager

openharmony 鸿蒙 arkts-apis-photoAccessHelper-MediaAssetProgressHandler

openharmony 鸿蒙 arkts-apis-photoAccessHelper-AbsAlbum

openharmony 鸿蒙 arkts-apis-photoAccessHelper-PhotoAccessHelper

openharmony 鸿蒙 arkts-apis-photoAccessHelper-QuickImageDataHandler

openharmony 鸿蒙 capi-media-access-helper-capi-h

openharmony 鸿蒙 arkts-apis-photoAccessHelper-PhotoAsset

openharmony 鸿蒙 capi-mediaassetmanager-oh-movingphoto

openharmony 鸿蒙 capi-mediaassetmanager

openharmony 鸿蒙 capi-mediaassetmanager-medialibrary-requestid

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