无法解析方法getDownloadUrl()

时间:2019-07-08 18:59:48

标签: android firebase firebase-storage

getDownloadUrl()无法用于我的项目

StorageReference image_path = storageReference.child("profile_images").child(user_id + ".jpg");
                image_path.putFile(mainImageURI).addOnCompleteListener(new OnCompleteListener<UploadTask.TaskSnapshot>() {
                    @Override
                    public void onComplete(@NonNull Task<UploadTask.TaskSnapshot> task) {

                        if(task.isSuccessful()){

                            Uri download_uri = task.getResult().getDownloadUrl();

                            Map<String, String> userMap = new HashMap<>();
                            userMap.put("name", user_name);
                            userMap.put("image", download_uri.toString());

1 个答案:

答案 0 :(得分:0)

尝试使用它。

Task<Uri> task = taskSnapshot.getMetadata().getReference().getDownloadUrl();
 task.addOnSuccessListener(new OnSuccessListener<Uri>() {
     @Override
     public void onSuccess(Uri uri) {
         String photoLink = uri.toString();
         }
 });