Uri resultUri = result.getUri();
String current_userID = firebaseUser.getUid();
StorageReference filePath = mImageStorage.child("profile_images").child( current_userID + ".jpg");
filePath.putFile(resultUri).addOnCompleteListener(new OnCompleteListener<UploadTask.TaskSnapshot>() {
@Override
public void onComplete(@NonNull Task<UploadTask.TaskSnapshot> task) {
if (task.isSuccessful()) {
String downloadUrl = task.getResult().getDownloadUrl.toString();
databaseReference.child("image").setValue(downloadUrl).addOnCompleteListener(new OnCompleteListener<Void>() {
@Override
public void onComplete(@NonNull Task<Void> task) {
if (task.isSuccessful()) {
mProgressDialog.dismiss();
Toast.makeText(AccountSettings.this, "Success Uploading", Toast.LENGTH_SHORT).show();
}
}
});
} else {
Toast.makeText(AccountSettings.this, "Error in Uploading", Toast.LENGTH_SHORT).show();
mProgressDialog.dismiss();
}
}
});
getDownloadUrl不能在其下方显示红线,或者是downloadUrl需要为其添加一种方法
答案 0 :(得分:0)
String downloadUrl = task.getResult().getDownloadUrl.toString();
应该是
String downloadUrl = task.getResult().getDownloadUrl().toString();