0

The URL(Image) getting stored in the Firebase database should point to the resource itself that is it should open the image itself But in my database the URL doesn't open up the image. I am cropping an image and saving it in database.

if(task.isSuccessful()) 
{    Toast.makeText(SetupActivity.this, "Photo saved", Toast.LENGTH_SHORT).show();
    final String downloadUrl = task.getResult().getStorage().getDownloadUrl().toString();


  UsersRef.child("profileimage").setValue(downloadUrl).addOnCompleteListener(new OnCompleteListener<Void>() {
                                                        @Override
                                                        public void onComplete(@NonNull Task<Void> task)
                                                        {

StorageReference filepath = UserProfileImageRef.child(currentUserId + ".jpg");


                                        filepath.putFile(imageUriResultCrop).addOnCompleteListener(new OnCompleteListener<UploadTask.TaskSnapshot>() {
                                            @Override
                                            public void onComplete(@NonNull Task<UploadTask.TaskSnapshot> task)
                                            {
                                                if(task.isSuccessful())
                                                {

Expected output :- profileimage:https://firebasestorage.googleapis.somefilename/v0" But what i get is - Real output :-profileimage:"com.google.android.gms.tasks.zzu@dd"

Frank van Puffelen
  • 565,676
  • 79
  • 828
  • 807
  • Please only use the `android-studio` tag for questions about the Android Studio IDE itself. For questions about Android programming in general, use the `android` tag. – Frank van Puffelen Aug 30 '19 at 14:23
  • When you call `getDownloadURL()` you get back a task. You need to add an additional completion listener to that task to get the actual URL. See https://stackoverflow.com/questions/51056397/how-to-use-getdownloadurl-in-recent-versions/51064689#51064689 – Frank van Puffelen Aug 30 '19 at 14:24

0 Answers0