android - CameraRoll 不显示 Android 上的图像

标签 android react-native

我的react-native项目中有这段代码

    CameraRoll.getPhotos({
    first: 20,
    assetType: "Photos",
  }).then((answer) => {
      dispatch({
        type: PHOTOS_LIBRARY,
        photos: answer.edges,
      });
      console.log(answer.edges);
    })
    .catch((err) => {
      console.log(err);
    });

它在我的旧 Android 设备上运行良好,但不适用于模拟器和更强大的设备,它不显示照片,事实上,它返回照片对象,但尺寸为空。 这个console.log:

    [{"fileSize": null, "filename": null, "height": null, "id": 0, "playableDuration": null,
 "uri": "file:///storage/emulated/0/DCIM/Camera/IMG_20200902_153713.jpg", "width": null}, 
{"fileSize": null, "filename": null, "height": null, "id": 1, "playableDuration": null, "uri":
 "file:///storage/emulated/0/DCIM/Camera/IMG_20200902_153653.jpg", "width": null}]

最佳答案

您是否尝试过在 CameraRoll.getPhotos () 方法中使用 include ? 例如:

 CameraRoll.getPhotos({
  first: 25,
  assetType: 'Photos',
  include: ['filename', 'imageSize'],
})

关于android - CameraRoll 不显示 Android 上的图像,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/63708533/

相关文章:

react-native - 如果你想使用reanimated 2,请完成你的安装

javascript - 在 React Native 上使用 Expo 发送多个推送通知

react-native - 将 native react 升级到最新版本

android - constraint set connect中的margin是什么意思

android - Kotlin fragment NullPointerException

android - 如何调整 ScrollView 的大小以适合底部 60% 的屏幕?

java - 什么时候是在 android 中获取 View 尺寸的正确时间

android - 如何跟踪人们从哪里来到我的谷歌游戏市场游戏页面

ios - 如何让 Expo 提示我的应用程序输入 "Always"位置权限?

javascript - 无法让 shouldComponentUpdate() 在 native react 中工作