android Picasso load image from storage - android

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

Related

How to download a file and open it in imageView?

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

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.

Load Image with Universal Image Loader using the Path of Image

I am trying to load an image with UniversalImageLoader. I tried this way:
String path = "/storage/emulated/0/BlackHole/Black Hole/1gatopan0000.png"
ImageLoader.getInstance().displayImage(path, viewHolder.imageView);
But nothing happened. Is it possible to load the image using UniversalImageLoader with the path of the image as a string?
Firstly, you have to add a backslash before any space character in your path.
String path = "/storage/emulated/0/BlackHole/Black\ Hole/1gatopan0000.png"
Then, Picasso is a great library that allows you to load images easily. I personally find it prettier than the UIL. In order to load an image into your ImageView, you simply have to :
Picasso.with(context).load("/your/path/here").into(yourImageView);
Try this:
String path = "/storage/emulated/0/BlackHole/Black\ Hole/1gatopan0000.png"

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);

Android: load image from local storage to webview

I download the image and store in the local storage. I load this image from the html file from local storage.
<img src="file:///data/data/com.example/imagefiles/photo.jpg"/>
I load the html file from WebView.
webView.loadUrl("file:///android_asset/show_download_image.html");
But the image didn't shown. I am sure the downloading image is successful.
I want to know that is it possible to load the image from local storage into the html file or is there any way to load the image from local?
Thanks.
Why not try to load image directly like this:
String base = Environment.getExternalStorageDirectory().getAbsolutePath().toString();
String imagePath = "file://"+ base + "/photo.jpg";
String html = "<html><head></head><body><img src=\""+ imagePath + "\"></body></html>";
webView.loadDataWithBaseURL("", html, "text/html","utf-8", "");
Here the image is in sd card. You can change the code for keeping image in asset also.
check your webview javaScriptEnabled is true?
WebView.getSettings().setJavaScriptEnabled(true);

Categories

Resources