How can I set an image to a ImageView from a URL?
Using Firebase authentication, I get the photo URL of the signed in user:
Uri uri = firebaseUser.getProviderData().get(0).getPhotoUrl();
You can use Picasso Library to show images in ImageView.
You just need to pass the url, uri or resource to Picasso with image view.
like
Picasso.with(this).load(/* url of image */).into(/*your imageview id*/);
To use the picasso you need to add the following in Gradle
compile 'com.squareup.picasso:picasso:2.5.2'
Read the documentation on http://square.github.io/picasso/
Also There are other libraries to display image in ImageView.
Like Fresco, Glide, Universal Image Loader etc
Related
Getting image from fire base using glide and set into recycler view but image not load
upload uploadCurrent = mUploads.get(position);
Glide.with(mContext).load(uploadCurrent.getFilePathUri()).into(holder.mimageView);
holder.textViewname.setText(uploadCurrent.getProductName());
holder.textViewcontact.setText(uploadCurrent.getContactNumber());
holder.textViewprice.setText(uploadCurrent.getPrice());
You may use picasso instead of glide,
in your build.gradle app
compile 'com.squareup.picasso:picasso:2.5.2'
then
Picasso.with(mContext).load(uploadCurrent.getFilePathUri()).into(holder.mimageView);
If it didn't work try making sure that uploadCurrent.getFilePathUri() returns a valid uri.
if it returns a valid uri then the problem is with the context maybe
try
Picasso.with(getApplicationContext()).load(uploadCurrent.getFilePathUri()).into(holder.mimageView);
if still no luck then the best way is to remove picasso and glide and write
holder.imageView.setImageUri(uploadCurrent.getFilePathUri());
That's it.
I am loading an image from "HTTP" URL and it's working well, but now that my image URL comes with "HTTPS" my image is not loading in imageview.
I tried picasso as well as glide but both failed to load the image with URL "HTTPS". If URL is with "HTTP" then there is no any issue, but it is not working with HTTPS.
So is there any final solution to load an image with HTTPS URL with only using picasso or glide?
I read so many article and tell us to use custom picasso class or use image loader library but no solutions.
Following are picasso example to load image:
picasso.with(getActivity())
.load("https://example_image_url.jpg")
.fit()
.noFade()
.placeholder(image_here)
.error(error_image_here)
.into(my_image_view);
My drive url is -
https://drive.google.com/file/d/0B3DFHb2-MdGYa2NMUkVtVkZ1V1k/view?usp=sharing
I want to show it in android imageview using glide. I have tried many ways to show it.
Following is my code to show -
Glide.with(getActivity()).load(readExcelFeed.getImage().toString()).into(ivQueImage);
Please let me know what is the issue in it.
Steps for loads image from Google drive into ImageView by Glide Library
Step 1 : In your Drive which image you want to display on ImageView. You need to get shareable link from the three dots from the google drive. like this "https://drive.google.com/open?id=139jBj_GUfmFi_pZN38SS9RMB5wNXMEy9"
Step 2: Then the base url for display the image. link is
public static String BASE_URL = "https://drive.google.com/uc?id=";
Step 3 : In the Step 1 you see the id of the image then add this id in the base URL. Like this type
"https://drive.google.com/uc?id=139jBj_GUfmFi_pZN38SS9RMB5wNXMEy9"
Step 4 : Use Glide library for display the image on ImageView Like this:
Glide.with(mContext)
.load("https://drive.google.com/uc?id=139jBj_GUfmFi_pZN38SS9RMB5wNXMEy9")
.into(holder.user_image);
Now you can see your image on your ImageView.
Unless I'm missing something, you want to show just that single image using Glide. Just right click on it, select "Copy image address", then use that as your url String for Glide.
String url = "https://lh3.googleusercontent.com/s6-0yxPhDS4Os7SYbP66RCNp-mDwuKr72mLJx9ekuTWYFPgXahCvj-oVatwXELyVfyZzD80YTaiYde4=w1278-h954-rw";
Glide.with(getActivity()).load(url).into(ivQueImage);
For request image source you must use executeMediaAndDownloadTo()
service.files().get(fileId).executeMediaAndDownloadTo(outputStream);
Then you can get byte[] from output stream
byte[] data = outputStream.toByteArray();
and insert it to Glid
RequestOptions options = new RequestOptions();
options.skipMemoryCache(true);
options.diskCacheStrategy(DiskCacheStrategy.NONE);
Glide
.with(this)
.load(data)
.apply(options)
.transition(DrawableTransitionOptions.withCrossFade())
.into(imageView);
Add image in RecyclerView from api using picasso
Image loading using Picasso is very easy, you can do it like this way Picasso.get().load("http://i.imgur.com/DvpvklR.png").into(imageView); and in their website you can get every details. In your case you can parse every image URL and use RecyclerView to show them along with Picasso.
Picasso.get().load("http://i.imgur.com/DvpvklR.png").into(imageView)
In the new versions of Picasso you don't need the context anymore.
I'm using:
implementation 'com.squareup.picasso:picasso:2.71828'
In the new versions of Picasso used get()
Picasso latest version Picasso library: 2.71828
Picasso
.get()
.load("You Img Path Place Here")
.resize(width, height)
.noFade()
.into("Path set ImageView");
Used latest picasso version
implementation 'com.squareup.picasso:picasso:2.71828'
Try this
String img_url = "YOUR IMAGE URL";
if (!img_url.equalsIgnoreCase(""))
Picasso.with(context).load(img_url).placeholder(R.drawable.user_image)// Place holder image from drawable folder
.error(R.drawable.user_image).resize(110, 110).centerCrop()
.into("IMAGE VIEW ID WHERE YOU WANT TO SET IMAGE");
Happy coding.
You can load image using picasso like this way
Picasso.with(context).load(android_versions.get(i).getAndroid_image_url()).resize(120, 60).into(viewHolder.img_android);
https://www.learn2crack.com/2016/02/image-loading-recyclerview-picasso.html
Here ctx is context, list.getImage_full_path()) is image coming from server, in placeholder a static image is placed if image is not loaded, on error kent is name of image and into(servicecart_image) is placed in XML so image is loaded there
Picasso.with(ctx).load(list.getImage_full_path()).resize(160, 200).placeholder(R.drawable.kent)
.error(R.drawable.kent).into(servicecart_image);
I'm looking into using Glide to access gifs off an image hosting website instead of having them all stored in the app within the assets folder. I have Glide working in the sense that it will load the image I specify when the original URL fails.
ImageView imageViewGif = (ImageView) findViewById(R.id.gif);
String gifUrl = "http://imgur.com/gallery/XgbZdeA";
Glide
.with(this)
.load(gifUrl)
.asGif()
.error(R.drawable.alternator_pic)
.into(imageViewGif);
So it loads up alternator pic just fine but I am unable to get it to load an image or gif from the specified URL. What am I missing?