小编Pat*_*ill的帖子

expo-camera takePictureAsync() 不适用于 Android

我最近在一个托管博览会项目中更新了几行代码,与相机功能无关。iOS 上还是可以的,只是 Android 不行。我一个月前发布了一个运行良好的先前版本。但是,当我恢复到旧的提交时,它也无法在 Android 上运行(iOS 很好)。

  • 世博会 44.0.6
  • 世博相机 12.1.2
  • 反应17.0.1
  • 反应本机 0.64.3

启动相机等没有问题。相反,问题发生在 takePictureAsync 处,它挂起,然后不返回任何内容。

const snapPic = async () => {
    const { status } = await Camera.getCameraPermissionsAsync();
    if (status != 'granted') {
        alert('Please grant access to camera and retry.');
        await Camera.requestCameraPermissionsAsync();
        return;
    }
    const options = { quality: 0.1 };
    const photo = await this.camera.takePictureAsync(options);
    this.camera.pausePreview();
    this.setState({imageSource: photo.uri});
};

<Camera style={styles.cameraBox} ref={ref => {this.camera = ref}} />
Run Code Online (Sandbox Code Playgroud)

如有必要,请告诉我我可以提供哪些其他信息。提前致谢!

android react-native expo expo-camera

6
推荐指数
1
解决办法
1423
查看次数

标签 统计

android ×1

expo ×1

expo-camera ×1

react-native ×1