HarmonyOS 使用cameraPicker.pick调用相机,却在APP站外打开?

static async camera(options?: CameraOptions): Promise<string> {
  try {
  if (!options) {
  options = new CameraOptions();
}
if (!options.mediaTypes || options.mediaTypes.length == 0) {
  options.mediaTypes = [cameraPicker.PickerMediaType.PHOTO, cameraPicker.PickerMediaType.VIDEO];
}
let pickerProfile: cameraPicker.PickerProfile = {
  cameraPosition: options.cameraPosition ? options.cameraPosition : camera.CameraPosition.CAMERA_POSITION_BACK,
  videoDuration: options.videoDuration,
  saveUri: options.saveUri
};

let context = getContext() as common.Context;
let pickerResult: cameraPicker.PickerResult = await cameraPicker.pick(context,
  options.mediaTypes, pickerProfile);
if (pickerResult && pickerResult.resultUri) {
  return pickerResult.resultUri;
}
} catch (err) {
  let error = err as BusinessError;
  console.error(`camera-异常 ~ code: ${error.code} -·- message: ${error.message}`);
}
return "";
}

请问如何适配不同系统,让其都是在APP站内打开系统相机?

阅读 392
1 个回答

需要自己去适配,该接口按规格已修改为多窗口。

logo
HarmonyOS
子站问答
访问
宣传栏