【发布时间】:2018-11-28 22:53:35
【问题描述】:
我有一张图片存储在 Google Cloud Storage 中。我想允许我的应用程序的用户将其分享到 Instagram。因此,我在 Storage 中获得了对它的引用,然后我获得了下载 URL(一个 URI 对象)并将其放入我用来打开 Instagram 的意图的额外数据中。
但 Instagram 表示“图片无法加载”。我认为这是因为 URI 指向 Cloud Storage 返回的 Web URL,而不是指向本地文件的 URI。不? 有什么方法可以让我的程序使用指向 Cloud Storage 返回的 Web URL 的 URI 运行?
来源
代码如下:
final Intent intent_share = new Intent(Intent.ACTION_SEND);
intent_share.setType("image/*");
FirebaseStorage firebase_storage = new SetupFirebaseStorage().getFirebaseStorage();
StorageReference storage_reference = firebase_storage.getReference();
storage_reference.child(image_uuid).getDownloadUrl().addOnSuccessListener(new OnSuccessListener<Uri>() {
@Override
public void onSuccess(Uri uri) {
intent_share.putExtra(Intent.EXTRA_STREAM, uri);
activity.startActivity(Intent.createChooser(intent_share, "Share to"));
}
}).addOnFailureListener(new OnFailureListener() {
@Override
public void onFailure(@NonNull Exception exception) {
Toast.makeText(getContext(), "An error occurred during the publication image's URL retrieving.", Toast.LENGTH_LONG).show();
}
});
【问题讨论】:
标签: android google-cloud-storage instagram share firebase-storage