在task.getResult()。getDownloadUrl()中显示为错误

时间:2020-05-13 10:43:36

标签: java android firebase-storage

在以下行中download_uri = task.getResult()。getDownloadUrl();, getDownloadUrl();显示错误。请帮助我解决此错误。

private void storeData(Task<UploadTask.TaskSnapshot> task, String username, String userfullname, String usercountry) {

        Uri download_uri;
        if (task != null) {
            download_uri = task.getResult().getDownloadUrl();

        } else {
            download_uri = imageUri;
        }

        Map<String, String> userData = new HashMap<>();

        userData.put("userName",username);
        userData.put("userFullname",userfullname);
        userData.put("userCountry",usercountry);
        userData.put("profileImage",download_uri.toString());

        firebaseFirestore.collection("Users").document(user_id).set(userData).addOnCompleteListener(new OnCompleteListener<Void>() {
            @Override
            public void onComplete(@NonNull Task<Void> task) {
                if (task.isSuccessful()) {

                    progressDialog.dismiss();
                    Toast.makeText(SetupActivity.this, "User Data is Stored Successfully", Toast.LENGTH_LONG).show();
                    Intent mainIntent = new Intent(SetupActivity.this, HomeActivity.class);
                    startActivity(mainIntent);
                    finish();
                } else {
                    String error = task.getException().getMessage();
                    Toast.makeText(SetupActivity.this, "(Error occurred) : " + error, Toast.LENGTH_LONG).show();
                }
                progressDialog.dismiss();

            }

        });



    }

0 个答案:

没有答案