使用ACTION_SEND_MULTIPLE与Facebook共享

时间:2017-09-11 10:01:48

标签: android facebook android-intent share

我一直试图使用ACTION_SEND_MULTIPLE Intent向Facebook分享一些图片。

我为此写的代码是。

ArrayList<Uri> imageUris = new ArrayList<Uri>();
    for (DeviceImage image : catchImagesURI) {
        Log.d(TAG, "onClickShareFB: image uri " + image.getImageURI());
        imageUris.add(image.getImageURI());
    }
    Intent shareIntent = new Intent();
    shareIntent.setAction(Intent.ACTION_SEND_MULTIPLE);
    shareIntent.putParcelableArrayListExtra(Intent.EXTRA_STREAM, imageUris);
    shareIntent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION);
    shareIntent.setType("image/png");
    startActivity(Intent.createChooser(shareIntent, "Share images to.."));
}

图片的Uri为/storage/emulated/0/DCIM/Screenshot_1497529599.png/storage/emulated/0/DCIM/calendar.png

当我从我得到的选项中选择Facebook时

enter image description here

Image Uri的格式有问题,还是我完全错了?

1 个答案:

答案 0 :(得分:0)

  

Image Uri的格式是否有问题

它们不是有效的Uri值。 Uri有一个方案。例如,https://stackoverflow.com/questions/46152988/sharing-to-facebook-with-action-send-multipleUri,方案为https。鉴于您使用的路径,大概该方案应为file

Facebook是否可以使用指向外部存储的file Uri值是另一回事。可能它可以。