1

I am making an Android App in which i have some user Accounts and linked with each is some data. The data also has a download URL associated with a image stored in Firebase Storage.

I know how to retrieve data from Firebase cloud firestore so I will retrieve value of the download url in app by the line

FirebaseFirestore db = FirebaseFirestore.getInstance();
DocumentReference user = db.collection("School").document("Accouts").collection("students").document(name);

        user.get().addOnCompleteListener(new OnCompleteListener<DocumentSnapshot>() {
            @Override
            public void onComplete(@NonNull Task<DocumentSnapshot> task) {
                if (task.isSuccessful()) {
                    DocumentSnapshot doc = task.getResult();
                    String img_url = (String) doc.get("image");
                }
            }
        });

but I don't know how to load that image and display in ImageView

I want to do it without using external library

The database is

enter image description here

Talha Israr
  • 654
  • 6
  • 17

3 Answers3

1

I'm using Glide. https://github.com/bumptech/glide.

ImageView imageView = findViewById(R.id.image_view);

Glide.with(getApplicationContext())
     .load(img_url)
     .into(imageView);
Ticherhaz FreePalestine
  • 2,738
  • 4
  • 20
  • 46
1

You can use Glide to load your image.

Glide is a fast and efficient open source media management and image loading framework for Android that wraps media decoding, memory and disk caching, and resource pooling into a simple and easy to use interface.

How to use:

ImageView imageView = (ImageView) findViewById(R.id.your_image_view);

Glide.with(this)
.load("your URL goes here")
.into(imageView);
Tamir Abutbul
  • 7,301
  • 7
  • 25
  • 53
1

You can load image using Picasso

add dependency to your app/build.gradle

implementation 'com.squareup.picasso:picasso:2.71828'

then you can load your image like below

Picasso.get().load(yourImageUrl).into(imageView);

For more info check Piccasso

Muhammad Ashfaq
  • 2,359
  • 5
  • 20
  • 46
  • there are so much flaw with `picasso`. It's better if you follow [docs](https://firebase.google.com/docs/storage/android/download-files?authuser=0#downloading_images_with_firebaseui) and firebase expires url token so each time it needs to revoke – Ashish Jul 06 '19 at 09:26
  • 2
    I am using it since last year and it didn't gimme a chance to criticize it. Everyone has it's own preferences – Muhammad Ashfaq Jul 06 '19 at 09:29
  • i am not saying it's bad or something wrong with it but it will take time to get url and other stuff to show image if you know what i means. The above question was get image url by using storage reference and then show image better if he use storage ref to show image will be better and fast – Ashish Jul 06 '19 at 09:32