uploadTask
.addOnSuccessListener(AdminDisplayProductActivity.this, new OnSuccessListener<UploadTask.TaskSnapshot>() {
@Override
public void onSuccess(final UploadTask.TaskSnapshot taskSnapshot) {
new Handler().postDelayed(new Runnable() {
@Override
public void run() {
mProgressBar.setProgress(0);
downloadUrl = taskSnapshot.getMetadata().getReference().getDownloadUrl().toString();
AddProduct(downloadUrl);
Toast.makeText(AdminDisplayProductActivity.this, "Uploaded !" + downloadUrl, Toast.LENGTH_SHORT).show();
}
}, 500);
Toast.makeText(AdminDisplayProductActivity.this, "File Uploaded"
, Toast.LENGTH_SHORT).show();
}
})
.addOnFailureListener(new OnFailureListener() {
@Override
public void onFailure(@NonNull Exception e) {
Toast.makeText(AdminDisplayProductActivity.this, "Upload Fail !", Toast.LENGTH_SHORT).show();
}
})
.addOnProgressListener(new OnProgressListener<UploadTask.TaskSnapshot>() {
@Override
public void onProgress(UploadTask.TaskSnapshot taskSnapshot) {
double progress = (100.0 * taskSnapshot.getBytesTransferred() / taskSnapshot.getTotalByteCount());
mProgressBar.setProgress((int) progress);
}
});
答案 0 :(得分:0)
getDownloadUrl()返回一个Task对象,您需要在该对象上附加完成侦听器。 getDownloadUrl()上的toString()将最终为您提供firebase用于下载URL的类的名称。
请在听众中附上听众,您将获得Uri格式的下载网址。