This getDownloadUrl()
method showed deprecated after updating to
\'com.google.firebase:firebase-storage:15.0.2\'
In the docs it says this:
The
getDownloadUrl()
andgetDownloadUrls()
methods of theStorageMetadata
class are now deprecated. UsegetDownloadUrl()
fromStorageReference
instead.
So you need to use getDownloadUrl()
that is inside the StorageReference
public Task<Uri> getDownloadUrl ()
Asynchronously retrieves a long lived download URL with a revokable token. This can be used to share the file with others, but can be revoked by a developer in the Firebase Console if desired.
more information here:
https://firebase.google.com/docs/reference/android/com/google/firebase/storage/StorageReference#getDownloadUrl()
final UploadTask uploadTask = thumb_file.putBytes(thumb_bite); uploadTask.addOnSuccessListener(new OnSuccessListener() { @Override public void onSuccess(UploadTask.TaskSnapshot taskSnapshot) {
//Url laden
taskSnapshot.getStorage().getDownloadUrl().addOnSuccessListener(new OnSuccessListener<Uri>() {
@Override
public void onSuccess(Uri uri) {
Map imageUrls = new HashMap();
imageUrls.put("image", fullImageUrl);
imageUrls.put("thumb_image", uri.toString());
//In database
mAlarmsDatabaseReference.updateChildren(imageUrls).addOnCompleteListener(new OnCompleteListener<Void>() {
@Override
public void onComplete(@NonNull Task<Void> task) {
//Progressbar beende + Bild wieder anzeigen
progressBar.setVisibility(View.GONE);
circleProfilePicture.setVisibility(View.VISIBLE);
if(task.isSuccessful()){
Toast.makeText(SettingsActivity.this, getResources().getString(R.string.ProfilbildUpdate), Toast.LENGTH_SHORT).show();
}else{
Toast.makeText(SettingsActivity.this, "FAILED", Toast.LENGTH_SHORT).show();
}
}
});
}
});
}
});
final StorageReference filePath = mImageStore.child("profile_images").child("full_image").child(userId + ".jpg");
filePath.getDownloadUrl().addOnSuccessListener(new OnSuccessListener<Uri>() {
@Override
public void onSuccess(Uri uri) {
//Bitmap hochladen
uploadBitMap(uri.toString());
}
});strong text
Or
final UploadTask uploadTask = thumb_file.putBytes(thumb_bite);
uploadTask.addOnSuccessListener(new OnSuccessListener<UploadTask.TaskSnapshot>() {
@Override
public void onSuccess(UploadTask.TaskSnapshot taskSnapshot) {
//Url laden
taskSnapshot.getStorage().getDownloadUrl().addOnSuccessListener(new OnSuccessListener<Uri>() {
@Override
public void onSuccess(Uri uri) {
Map imageUrls = new HashMap();
imageUrls.put("image", fullImageUrl);
imageUrls.put("thumb_image", uri.toString());
//In database
mAlarmsDatabaseReference.updateChildren(imageUrls).addOnCompleteListener(new OnCompleteListener<Void>() {
@Override
public void onComplete(@NonNull Task<Void> task) {
//Progressbar beende + Bild wieder anzeigen
progressBar.setVisibility(View.GONE);
circleProfilePicture.setVisibility(View.VISIBLE);
if(task.isSuccessful()){
Toast.makeText(SettingsActivity.this, getResources().getString(R.string.ProfilbildUpdate), Toast.LENGTH_SHORT).show();
}else{
Toast.makeText(SettingsActivity.this, "FAILED", Toast.LENGTH_SHORT).show();
}
}
});
}
});
}
});