source
stringlengths
14
113
code
stringlengths
10
21.3k
application-dev\media\medialibrary\movingphotoview-guidelines.md
import { photoAccessHelper, MovingPhotoView, MovingPhotoViewController, MovingPhotoViewAttribute } from '@kit.MediaLibraryKit'; @Entry @Component struct Index { @State src: photoAccessHelper.MovingPhoto | undefined = undefined @State isMuted: boolean = false controller: MovingPhotoViewCon...
application-dev\media\medialibrary\photoAccessHelper-movingphoto.md
import { photoAccessHelper } from '@kit.MediaLibraryKit'; import { common } from '@kit.AbilityKit'; @Entry @Component struct Index { @State message: string = 'Hello World' @State saveButtonOptions: SaveButtonOptions = { icon: SaveIconStyle.FULL_FILLED, text: SaveDescription.SAVE_IMAGE, buttonType: Butt...
application-dev\media\medialibrary\photoAccessHelper-movingphoto.md
import { photoAccessHelper } from '@kit.MediaLibraryKit'; import { dataSharePredicates } from '@kit.ArkData'; import { common } from '@kit.AbilityKit'; // Obtain the context from the component and ensure that the return value of this.getUiContext().getHostContext() is UIAbilityContext. let context: Context = this.getU...
application-dev\media\medialibrary\photoAccessHelper-movingphoto.md
import { photoAccessHelper } from '@kit.MediaLibraryKit'; import { common } from '@kit.AbilityKit'; // Obtain the context from the component and ensure that the return value of this.getUiContext().getHostContext() is UIAbilityContext. let context: Context = this.getUIContext().getHostContext() as common.UIAbilityConte...
application-dev\media\medialibrary\photoAccessHelper-movingphoto.md
import { photoAccessHelper } from '@kit.MediaLibraryKit'; async function example(movingPhoto: photoAccessHelper.MovingPhoto) { try { let imageFileUri = 'file://com.example.temptest/data/storage/el2/base/haps/entry/files/request_moving_photo.jpg'; let videoFileUri = 'file://com.example.temptest/data/storage/e...
application-dev\media\medialibrary\photoAccessHelper-notify-guidelines.md
import { dataSharePredicates } from '@kit.ArkData'; import { photoAccessHelper } from '@kit.MediaLibraryKit'; import { common } from '@kit.AbilityKit'; // Obtain the context from the component and ensure that the return value of this.getUiContext().getHostContext() is UIAbilityContext. let context: Context = this.getU...
application-dev\media\medialibrary\photoAccessHelper-notify-guidelines.md
import { dataSharePredicates } from '@kit.ArkData'; import { photoAccessHelper } from '@kit.MediaLibraryKit'; import { common } from '@kit.AbilityKit'; // Obtain the context from the component and ensure that the return value of this.getUiContext().getHostContext() is UIAbilityContext. let context: Context = this.getU...
application-dev\media\medialibrary\photoAccessHelper-notify-guidelines.md
import { dataSharePredicates } from '@kit.ArkData'; import { photoAccessHelper } from '@kit.MediaLibraryKit'; import { common } from '@kit.AbilityKit'; // Obtain the context from the component and ensure that the return value of this.getUiContext().getHostContext() is UIAbilityContext. let context: Context = this.getU...
application-dev\media\medialibrary\photoAccessHelper-notify-guidelines.md
import { dataSharePredicates } from '@kit.ArkData'; import { photoAccessHelper } from '@kit.MediaLibraryKit'; import { common } from '@kit.AbilityKit'; // Obtain the context from the component and ensure that the return value of this.getUiContext().getHostContext() is UIAbilityContext. let context: Context = this.getU...
application-dev\media\medialibrary\photoAccessHelper-photoviewpicker.md
import { photoAccessHelper } from '@kit.MediaLibraryKit'; import { fileIo } from '@kit.CoreFileKit'; import { BusinessError } from '@kit.BasicServicesKit';
application-dev\media\medialibrary\photoAccessHelper-photoviewpicker.md
const photoSelectOptions = new photoAccessHelper.PhotoSelectOptions();
application-dev\media\medialibrary\photoAccessHelper-photoviewpicker.md
photoSelectOptions.MIMEType = photoAccessHelper.PhotoViewMIMETypes.IMAGE_TYPE; // Select images. photoSelectOptions.maxSelectNumber = 5; // Set the maximum number of images that can be selected.
application-dev\media\medialibrary\photoAccessHelper-photoviewpicker.md
let uris: Array<string> = []; const photoViewPicker = new photoAccessHelper.PhotoViewPicker(); photoViewPicker.select(photoSelectOptions).then((photoSelectResult: photoAccessHelper.PhotoSelectResult) => { uris = photoSelectResult.photoUris; console.info('photoViewPicker.select to file succeed and uris a...
application-dev\media\medialibrary\photoAccessHelper-photoviewpicker.md
let uri: string = ''; let file = fileIo.openSync(uri, fileIo.OpenMode.READ_ONLY); console.info('file fd: ' + file.fd);
application-dev\media\medialibrary\photoAccessHelper-photoviewpicker.md
let buffer = new ArrayBuffer(4096); let readLen = fileIo.readSync(file.fd, buffer); console.info('readSync data to file succeed and buffer size is:' + readLen); fileIo.closeSync(file);
application-dev\media\medialibrary\photoAccessHelper-photoviewpicker.md
import { photoAccessHelper } from '@kit.MediaLibraryKit'; import { dataSharePredicates } from '@kit.ArkData'; import { common } from '@kit.AbilityKit'; // Obtain the context from the component and ensure that the return value of this.getUiContext().getHostContext() is UIAbilityContext. let context: Context = this.getU...
application-dev\media\medialibrary\photoAccessHelper-preparation.md
import { photoAccessHelper } from '@kit.MediaLibraryKit'; import { common } from '@kit.AbilityKit'; // The photoAccessHelper instance obtained here is a global object. Unless otherwise specified, the object obtained here is used in subsequent operations in this document. If an undefined error is reported, add the code...
application-dev\media\medialibrary\photoAccessHelper-resource-guidelines.md
import { dataSharePredicates } from '@kit.ArkData'; import { photoAccessHelper } from '@kit.MediaLibraryKit'; import { common } from '@kit.AbilityKit'; // Obtain the context from the component and ensure that the return value of this.getUiContext().getHostContext() is UIAbilityContext. let context: Context = this.getU...
application-dev\media\medialibrary\photoAccessHelper-resource-guidelines.md
import { dataSharePredicates } from '@kit.ArkData'; import { image } from '@kit.ImageKit'; import { photoAccessHelper } from '@kit.MediaLibraryKit'; import { common } from '@kit.AbilityKit'; // Obtain the context from the component and ensure that the return value of this.getUiContext().getHostContext() is UIAbilityCo...
application-dev\media\medialibrary\photoAccessHelper-resource-guidelines.md
import { photoAccessHelper } from '@kit.MediaLibraryKit'; import { fileIo } from '@kit.CoreFileKit'; import { common } from '@kit.AbilityKit'; // Obtain the context from the component and ensure that the return value of this.getUiContext().getHostContext() is UIAbilityContext. let context: Context = this.getUIContext(...
application-dev\media\medialibrary\photoAccessHelper-resource-guidelines.md
import { dataSharePredicates } from '@kit.ArkData'; import { photoAccessHelper } from '@kit.MediaLibraryKit'; import { common } from '@kit.AbilityKit'; // Obtain the context from the component and ensure that the return value of this.getUiContext().getHostContext() is UIAbilityContext. let context: Context = this.getU...
application-dev\media\medialibrary\photoAccessHelper-resource-guidelines.md
import { dataSharePredicates } from '@kit.ArkData'; import { photoAccessHelper } from '@kit.MediaLibraryKit'; import { common } from '@kit.AbilityKit'; // Obtain the context from the component and ensure that the return value of this.getUiContext().getHostContext() is UIAbilityContext. let context: Context = this.getU...
application-dev\media\medialibrary\photoAccessHelper-savebutton.md
import photoAccessHelper from '@ohos.file.photoAccessHelper'; import { common } from '@kit.AbilityKit'; // Obtain the context from the component and ensure that the return value of this.getUiContext().getHostContext() is UIAbilityContext. let context: Context = this.getUIContext().getHostContext() as common.UIAbilityC...
application-dev\media\medialibrary\photoAccessHelper-savebutton.md
import { photoAccessHelper } from '@kit.MediaLibraryKit'; import { common } from '@kit.AbilityKit'; @Entry @Component struct Index { saveButtonOptions: SaveButtonOptions = { icon: SaveIconStyle.FULL_FILLED, text: SaveDescription.SAVE_IMAGE, buttonType: ButtonType.Capsule } // Set properties of SaveBu...
application-dev\media\medialibrary\photoAccessHelper-savebutton.md
import { photoAccessHelper } from '@kit.MediaLibraryKit'; import { fileIo } from '@kit.CoreFileKit'; import { common } from '@kit.AbilityKit'; // Obtain the context from the component and ensure that the return value of this.getUiContext().getHostContext() is UIAbilityContext. let context: Context = this.getUIContext(...
application-dev\media\medialibrary\photoAccessHelper-systemAlbum-guidelines.md
import { photoAccessHelper } from '@kit.MediaLibraryKit'; import { common } from '@kit.AbilityKit'; // Obtain the context from the component and ensure that the return value of this.getUiContext().getHostContext() is UIAbilityContext. let context: Context = this.getUIContext().getHostContext() as common.UIAbilityConte...
application-dev\media\medialibrary\photoAccessHelper-systemAlbum-guidelines.md
import { dataSharePredicates } from '@kit.ArkData'; import { photoAccessHelper } from '@kit.MediaLibraryKit'; import { common } from '@kit.AbilityKit'; // Obtain the context from the component and ensure that the return value of this.getUiContext().getHostContext() is UIAbilityContext. let context: Context = this.getU...
application-dev\media\medialibrary\photoAccessHelper-systemAlbum-guidelines.md
import { dataSharePredicates } from '@kit.ArkData'; import { photoAccessHelper } from '@kit.MediaLibraryKit'; import { common } from '@kit.AbilityKit'; // Obtain the context from the component and ensure that the return value of this.getUiContext().getHostContext() is UIAbilityContext. let context: Context = this.getU...
application-dev\media\medialibrary\photoAccessHelper-systemAlbum-guidelines.md
import { dataSharePredicates } from '@kit.ArkData'; import { photoAccessHelper } from '@kit.MediaLibraryKit'; import { common } from '@kit.AbilityKit'; // Obtain the context from the component and ensure that the return value of this.getUiContext().getHostContext() is UIAbilityContext. let context: Context = this.getU...
application-dev\media\medialibrary\photoAccessHelper-systemAlbum-guidelines.md
import { photoAccessHelper } from '@kit.MediaLibraryKit'; import { common } from '@kit.AbilityKit'; // Obtain the context from the component and ensure that the return value of this.getUiContext().getHostContext() is UIAbilityContext. let context: Context = this.getUIContext().getHostContext() as common.UIAbilityConte...
application-dev\media\medialibrary\photoAccessHelper-systemAlbum-guidelines.md
import { dataSharePredicates } from '@kit.ArkData'; import { photoAccessHelper } from '@kit.MediaLibraryKit'; import { common } from '@kit.AbilityKit'; // Obtain the context from the component and ensure that the return value of this.getUiContext().getHostContext() is UIAbilityContext. let context: Context = this.getU...
application-dev\media\medialibrary\photoAccessHelper-systemAlbum-guidelines.md
import { photoAccessHelper } from '@kit.MediaLibraryKit'; import { common } from '@kit.AbilityKit'; // Obtain the context from the component and ensure that the return value of this.getUiContext().getHostContext() is UIAbilityContext. let context: Context = this.getUIContext().getHostContext() as common.UIAbilityConte...
application-dev\media\medialibrary\photoAccessHelper-systemAlbum-guidelines.md
import { dataSharePredicates } from '@kit.ArkData'; import { photoAccessHelper } from '@kit.MediaLibraryKit'; import { common } from '@kit.AbilityKit'; // Obtain the context from the component and ensure that the return value of this.getUiContext().getHostContext() is UIAbilityContext. let context: Context = this.getU...
application-dev\media\medialibrary\photoAccessHelper-userAlbum-guidelines.md
import { photoAccessHelper } from '@kit.MediaLibraryKit'; import { common } from '@kit.AbilityKit'; // Obtain the context from the component and ensure that the return value of this.getUiContext().getHostContext() is UIAbilityContext. let context: Context = this.getUIContext().getHostContext() as common.UIAbilityConte...
application-dev\media\medialibrary\photoAccessHelper-userAlbum-guidelines.md
import { dataSharePredicates } from '@kit.ArkData'; import { photoAccessHelper } from '@kit.MediaLibraryKit'; import { common } from '@kit.AbilityKit'; // Obtain the context from the component and ensure that the return value of this.getUiContext().getHostContext() is UIAbilityContext. let context: Context = this.getU...
application-dev\media\medialibrary\photoAccessHelper-userAlbum-guidelines.md
import { dataSharePredicates } from '@kit.ArkData'; import { photoAccessHelper } from '@kit.MediaLibraryKit'; import { common } from '@kit.AbilityKit'; // Obtain the context from the component and ensure that the return value of this.getUiContext().getHostContext() is UIAbilityContext. let context: Context = this.getU...
application-dev\media\medialibrary\photoAccessHelper-userAlbum-guidelines.md
import { dataSharePredicates } from '@kit.ArkData'; import { photoAccessHelper } from '@kit.MediaLibraryKit'; import { common } from '@kit.AbilityKit'; // Obtain the context from the component and ensure that the return value of this.getUiContext().getHostContext() is UIAbilityContext. let context: Context = this.getU...
application-dev\media\medialibrary\photoAccessHelper-userAlbum-guidelines.md
import { dataSharePredicates } from '@kit.ArkData'; import { photoAccessHelper } from '@kit.MediaLibraryKit'; import { common } from '@kit.AbilityKit'; // Obtain the context from the component and ensure that the return value of this.getUiContext().getHostContext() is UIAbilityContext. let context: Context = this.getU...
application-dev\media\medialibrary\photoAccessHelper-userAlbum-guidelines.md
import { dataSharePredicates } from '@kit.ArkData'; import { photoAccessHelper } from '@kit.MediaLibraryKit'; import { common } from '@kit.AbilityKit'; // Obtain the context from the component and ensure that the return value of this.getUiContext().getHostContext() is UIAbilityContext. let context: Context = this.getU...
application-dev\media\medialibrary\photoAccessHelper-userAlbum-guidelines.md
import { dataSharePredicates } from '@kit.ArkData'; import { photoAccessHelper } from '@kit.MediaLibraryKit'; import { common } from '@kit.AbilityKit'; // Obtain the context from the component and ensure that the return value of this.getUiContext().getHostContext() is UIAbilityContext. let context: Context = this.getU...
application-dev\napi\jsvm-data-types-interfaces.md
RunWithOption: success: 1 RunWithOrigin: success: 1
application-dev\napi\napi-guidelines.md
// index.d.ts export const createMyExternal: () => Object; // Application code. import testNapi from 'libentry.so'; import worker from '@ohos.worker'; const mWorker = new worker.ThreadWorker('../workers/Worker'); { const mExternalObj = testNapi.createMyExternal(); mWorker.postMessage(mExternalObj); } // C...
application-dev\napi\native-netmanager-guidelines.md
export const GetDefaultNet: (code: number) => number; export const NetId: () => number;
application-dev\napi\native-netmanager-guidelines.md
import testNetManager from 'libentry.so'; @Entry @Component struct Index { @State message: string = ''; build() { Row() { Column() { Text(this.message) .fontSize(50) .fontWeight(FontWeight.Bold) Button('GetDefaultNet').onClick(event => { this.GetDefaultNet()...
application-dev\napi\use-call-threadsafe-function-with-priority.md
// index.d.ts export const callThreadSafeWithPriority: (cb: (a: number, b: number) => number) => void;
application-dev\napi\use-call-threadsafe-function-with-priority.md
// index.ets import testNapi from 'libentry.so'; let callback = (a: number, b: number) : number => { console.info('result is ' + (a + b)); return a + b; } testNapi.callThreadSafeWithPriority(callback);
application-dev\napi\use-jsvm-about-bigint.md
OH_JSVM_GetValueBigintWords wordCount:1. OH_JSVM_GetValueBigintWords signBit: 0.
application-dev\napi\use-jsvm-about-bigint.md
JSVM OH_JSVM_CreateBigintWords success
application-dev\napi\use-jsvm-about-bigint.md
JSVM OH_JSVM_CreateBigintUint64 success
application-dev\napi\use-jsvm-about-bigint.md
JSVM GetValueBigintUint64 success:1
application-dev\napi\use-jsvm-about-bigint.md
JSVM OH_JSVM_CreateBigintInt64 success
application-dev\napi\use-jsvm-about-bigint.md
JSVM GetBigintInt64 success:1
application-dev\napi\use-jsvm-about-object.md
JSVM GetPrototype success
application-dev\napi\use-jsvm-about-object.md
JSVM CreateObject success
application-dev\napi\use-jsvm-about-object.md
Test JSVM OH_JSVM_ObjectFreeze success
application-dev\napi\use-jsvm-about-object.md
Test JSVM OH_JSVM_ObjectSeal success
application-dev\napi\use-jsvm-about-object.md
JSVM Input type is boolean
application-dev\napi\use-jsvm-about-object.md
JSVM InstanceOf: 1
application-dev\napi\use-jsvm-about-object.md
JSVM SetTypeTagToObject success JSVM SetTypeTagToObject:1
application-dev\napi\use-jsvm-about-object.md
JSVM CreateExternal success
application-dev\napi\use-jsvm-about-object.md
JSVM OH_JSVM_CreateExternal success JSVM GetValueExternal success
application-dev\napi\use-jsvm-about-object.md
JSVM CreateSymbol Success
application-dev\napi\use-jsvm-about-object.md
JSVM OH_JSVM_SymbolFor success
application-dev\napi\use-jsvm-about-property.md
JSVM OH_JSVM_GetPropertyNames success
application-dev\napi\use-jsvm-about-property.md
JSVM OH_JSVM_SetProperty success
application-dev\napi\use-jsvm-about-property.md
JSVM OH_JSVM_GetProperty success
application-dev\napi\use-jsvm-about-property.md
// Output of hasProperty (obj, "data"). JSVM OH_JSVM_HasProperty success:1 // Output of hasProperty (obj, 0). JSVM OH_JSVM_HasProperty success:0
application-dev\napi\use-jsvm-about-property.md
JSVM OH_JSVM_DeleteProperty success:1
application-dev\napi\use-jsvm-about-property.md
// hasOwnProperty (obj, "message") output JSVM OH_JSVM_HasOwnProperty success:1 // hasOwnProperty(obj, "__defineGetter__") output // `__defineGetter__` is the prototype method of the object, not OwnProperty. The expected return value is 0. JSVM OH_JSVM_HasOwnProperty success:0
application-dev\napi\use-jsvm-about-property.md
JSVM OH_JSVM_SetNamedProperty success
application-dev\napi\use-jsvm-about-property.md
JSVM OH_JSVM_GetNamedProperty success
application-dev\napi\use-jsvm-about-property.md
JSVM OH_JSVM_HasNamedProperty success:1
application-dev\napi\use-jsvm-about-property.md
JSVM DefineMethodPropertiesExample success:26 JSVM defineStringPropertiesExample success:Hello! JSVM getterCallback success:Hello world!
application-dev\napi\use-jsvm-about-property.md
JSVM OH_JSVM_GetAllPropertyNames success
application-dev\napi\use-jsvm-create-snapshot.md
@Entry @Component struct Index { @State message: string = 'Hello World'; build() { Row() { Column() { Text(this.message) .fontSize(50) .fontWeight(FontWeight.Bold) .onClick(() => { // runtest napitest.runTest(); }) } .wid...
application-dev\napi\use-jsvm-create-snapshot.md
Test JSVM RunVMSnapshot read file blobSize = : 300064
application-dev\napi\use-jsvm-create-snapshot.md
Test JSVM RunVMSnapshot read file blobSize = : 300176 Test JSVM RunVMSnapshot read file blobSize = : 300064 Test JSVM RunVMSnapshot read file blobSize = : 300160 Test JSVM RunVMSnapshot read file blobSize = : 300032 Test JSVM RunVMSnapshot read file blobSize = : 300176 Test JSVM RunVMSnapshot read file blobSize = : 300...
application-dev\napi\use-jsvm-error.md
JSVM error message: HasError, error code: -1
application-dev\napi\use-jsvm-error.md
JSVM error message: has Error, error code: -1 JSVM error message: self defined error message, error code: self defined error code
application-dev\napi\use-jsvm-error.md
JSVM error message: throwing type error, error code: -1 JSVM error message: self defined error message, error code: self defined error code
application-dev\napi\use-jsvm-error.md
JSVM error message: Expected two numbers as arguments, error code: OH_JSVM_ThrowRangeError
application-dev\napi\use-jsvm-error.md
JSVM error message: throw syntax error, error code: JsVmThrowSyntaxError
application-dev\napi\use-jsvm-error.md
JSVM API call OH_JSVM_IsError success, result is 1
application-dev\napi\use-jsvm-error.md
JSVM API Create TypeError SUCCESS
application-dev\napi\use-jsvm-error.md
JSVM API CreateRangeError SUCCESS
application-dev\napi\use-jsvm-error.md
JSVM API CreateSyntaxError SUCCESS
application-dev\napi\use-jsvm-error.md
JSVM API OH_JSVM_GetAndClearLastException SUCCESS
application-dev\napi\use-jsvm-error.md
JSVM API OH_JSVM_IsExceptionPending: SUCCESS
application-dev\napi\use-jsvm-error.md
JSVM API OH_JSVM_GetLastErrorInfo: SUCCESS, error message is A number was expected, error code is 6
application-dev\napi\use-jsvm-life-cycle.md
JSVM: finalizer added. JSVM: before call gc. JSVM: finalizer called. JSVM: after call gc.
application-dev\napi\use-jsvm-process.md
// entry/src/main/cpp/types/libentry/index.d.ts export const runTest: () => void;
application-dev\napi\use-jsvm-process.md
import hilog from '@ohos.hilog'; // Import the native APIs. import napitest from 'libentry.so'; @Entry @Component struct Index { @State message: string = 'Hello World'; build() { Row() { Column() { Text(this.message) .fontSize(50) .fontWeight(FontWeight.Bold) .onCli...
application-dev\napi\use-jsvm-process.md
JSVM OH_JSVM_StrictEquals: success: 0
application-dev\napi\use-jsvm-strict-equals.md
JSVM OH_JSVM_StrictEquals: success: 1
application-dev\napi\use-napi-about-array.md
// index.d.ts export const createArray: () => number[];
application-dev\napi\use-napi-about-array.md
import hilog from '@ohos.hilog'; import testNapi from 'libentry.so'; hilog.info(0x0000, 'testTag', 'Test Node-API napi_create_array:%{public}s', JSON.stringify(testNapi.createArray()));
application-dev\napi\use-napi-about-array.md
// index.d.ts export const createArrayWithLength: (length: number) => void[];
application-dev\napi\use-napi-about-array.md
import hilog from '@ohos.hilog'; import testNapi from 'libentry.so'; let array = testNapi.createArrayWithLength(6); hilog.info(0x0000, 'testTag', 'Test Node-API napi_create_array_with_length:%{public}d', array.length);
application-dev\napi\use-napi-about-array.md
// index.d.ts export const getArrayLength: (arr: Array<any>) => number | void;
application-dev\napi\use-napi-about-array.md
import hilog from '@ohos.hilog'; import testNapi from 'libentry.so'; const arr = [0, 1, 2, 3, 4, 5]; hilog.info(0x0000, 'testTag', 'Test Node-API get_array_length:%{public}d', testNapi.getArrayLength(arr));