How to download a file and open it in imageView? - android

The URL do not ends in .png or .jpg or any image format
URL is like this:https://www.abcdef.com/funlearn/downloadFile?id=27
and it is an image.If I paste the URL in any browser it starts downloading the file with .jpg extension as food.jpg.
Picasso.with(getApplicationContext())
.load("http://i.imgur.com/DvpvklR.png")//working
// .load("https://www.abcdef.com/funlearn/downloadFile?id=27")//Not working
.into(image);
getting this error :D/skia: --- SkImageDecoder::Factory returned null

Reason is whatever you put inside a" load" should be a file. End thing should be a file. Picasso try to load that file for you. You can use it to load a file in your device sdcard etc. Specifically file should be a image or video. Hope it helps

Related

android Picasso load image from storage

i am using Picasso for load image from web and local storage
for load image from web
Picasso.with(context).load("http://i.imgur.com/DvpvklR.png").into(imageView);
and for load image from storage i add file:// before path for load image
Picasso.with(context).load("file:///android_asset/DvpvklR.png").into(imageView2);
but when file path have utf-8 charchter with file name its not load the image like file:///android_asset/۲۰۱٧.png
any idea how to solve it every time i want to use picaso its must string path not Uri or File because its saved in sqlite as string
Try this code:
String url = "file:///android_asset/۲۰۱٧.png";
URLEncoder.encode(url, "UTF-8");
Picasso.with(context).load(url).into(imageView2);
try doing
URIUtil.encodeQuery(url)
see the issue at:
https://github.com/square/picasso/issues/652

How to display .cms image file in android activity

I am trying to display an image in an activity after parsing it's URL in JSON format from the web. The image string thus obtained has a cms file extention. I know that Volley's image loader toolbox can be used to display jpg images but with this extention it is unable to inflate the view. What should i do?
Try replacing .cms with .jpeg in the url itsel. It worked for me.

error in `Image` download In `Universal Image Loader`

I am using Universal Image-loader,but sometime i am getting error while loading image.
"Image can't be decoded http:/***************/assets/images/NorthernMockingbird1.jpg_600x1024".
i am not getting any solution please suggest me what to do.
thanks in advance
Error:
Image can't be decoded
http:/***************/assets/images/NorthernMockingbird1.jpg_600x1024
From Error i can see that image file extension is .jpg_600x1024 which is not standard image extension so Universal Image Loader is not able to decode Image.
Try to get Image file name with proper extension.
I hope it helps you.

Android loading local image with space in path and with universal image loader

I am developing android application in which I want to display local image with the help of universal image loader. But when I try to display image which has space in it's local image path then it not able to display image. I tried it in following manner:
Uri.fromFile(new File(newImagePath)).toString();
I am getting following error:
java.io.FileNotFoundException: /storage/emulated/0/WhatsApp/Media/WhatsApp%20Images/IMG-20150421-WA0002.jpg: open failed: ENOENT (No such file or directory)
at libcore.io.IoBridge.open(IoBridge.java:456)
If tried to load image which has no space in its local path then it works fine but image with space in its path cause issue. Need some help. Thank you.
Actually its problem with universal image loader. https://github.com/nostra13/Android-Universal-Image-Loader/issues/371
So you just have decode your image path to remove space.
As per discussion in above link I got the solution :
final String uri = Uri.fromFile(file).toString();
final String decoded = Uri.decode(uri);
ImageLoader.getInstance().displayImage(decoded, imageView);
Can you try to replace space with "\u0020";
path = path.replace(" ","\u0020");

Android display image from sdcard using AQuery or Picasso

message="file:///storage/sdcard0/My Folder/images/Camera_1415795981117.jpg"// image is available at this location
Picasso.with(context).load( message+"")
.into(holder.iv_message_image);
have also tried
message="storage/sdcard0/Fresh IM/images/Camera_1415795981117.jpg";
also tried
message="file://storage/sdcard0/My Folder/images/Camera_1415795981117.jpg";
and also tried with AQuery
aQuery.id(holder.iv_message_image).image(message)
.progress(R.id.pb_loading);
both picasso and AQuery load images from url properly but not from local Please help!
Using Picasso-2.2.0 jar
Thanks in Advance,
Pragna
For your solution this will help. To display image from SDcard you need to convert it to URI first.
Uri uri = Uri.fromFile(new File(message));
Picasso.with(context).load(uri)
.into(holder.iv_message_image);
Must check your image path message is not wrong.
The following code would be very helpful and make sure that you are loading file when you want to load an image from SD card.
Picasso.with(context).load(new File(path)).into(imageView);

Categories

Resources