我正在尝试从Firebase获取下载URL,但它给了我另一个链接,例如“ com.google.android.gms.tasks.zzu@b9761c8”

时间:2018-09-12 04:40:55

标签: android firebase firebase-realtime-database firebase-storage

我正在尝试从firebase获取下载网址,但这给了我另一个链接,例如“ com.google.android.gms.tasks.zzu@b9761c8”

enter image description here

1 个答案:

答案 0 :(得分:0)

检索网址时,您需要添加侦听器。

  

请阅读documentations

taskSnapshot.getDownloadUrl().addOnSuccessListener(new OnSuccessListener<Uri>() {
    @Override
    public void onSuccess(Uri uri) {
        // Got the uri
        ImageUpload imageUpload = new ImageUpload(editText5.getText().toString(), uri.toString());
        // Wrap with Uri.parse() when retrieving

        String uploadId = mDatabaseRef.push().getKey();
        mDatabaseRef.child(uploadId).setValue(imageUpload);
    }
}).addOnFailureListener(new OnFailureListener() {
    @Override
    public void onFailure(@NonNull Exception exception) {
        // Handle any errors
    }
});