JSOUP to display images in Image view using the URL - android

How can i use JSOUP to display images in Image view using the URL. Any sample code is available for that. I searched but i couldn't find out.
Please help me with any link.
Thanks.

fir make the connection with provided link then you can get the image with
imagesRec = document.select("img[src~=(?i)\\.(png|jpe?g|gif)]");
then
String imgSrcUrl = img.attr("abs:src"); // imagePath
the you will use the Picasso lib for displaying the url as image in imageView
Picasso.with(MainActivity.this).load(imgSrcUrl).into(logo);
and thats it

you would have to parse the url of the image from the tag and then put into a string or similar. this string you can then use to load your image into an imageView.

Related

Store images from url in cache and use them as thumbnail or placeholder like whatsapp.

I am developing story feature app like instagram or whatsapp but I got stuck somewhere. I am getting image thumbnail from server as URL but when I try to use it . It take some time to load that image.So I want to Load add thumbnail images from url in previous activity and then set that thumbnail from cache.How I can store url images in cache Hashmap or arraylist to use them in next activity.Please help.I am in trouble right now.
You can use Glide for catching the image from URL.

Glide is not working in my project

I am developing an application in which i am using Glide Library to load image from server. But Unfortunately this is not working and i am completely unaware about this and trying to solve this issue since last two days.
this is my code.
Glide.with(this).load(response.getBank_cash_deposit().getData().getAttributes().getAttachment()).into(mSelectedImage);
Try Log your image response. you're getting correct image URL or not.
If the image URL is correct then check whether there is space in your image URL or not.
If the space is exists then replace space in your URL String with %20 with the help of string.replace() function.
String image=response.getBank_cash_deposit().getData().getAttributes().getAttachment();
Log.d("Image",image);
if space exists
then
image.replace(" ","%20");
Also check image url on web.

Getting error while setting image from parse to imageview

I am using holder to set images from Parse to my image view, below is following code
holder.rank.setText(worldpopulationlist.get(position).getRank());
holder.country.setText(worldpopulationlist.get(position).getCountry());
holder.population.setText(worldpopulationlist.get(position).getPopulation());
holder.flag.setImageResource(Integer.parseInt(worldpopulationlist.get(position).getFlag()));
And below is the error given by android studio
java.lang.NumberFormatException: Invalid int: "http://listview123.herokuapp.com/parse/files/hlkhlkhyuiyemnbbmbackguyweuiyqw/10ad83c5546b993c18be84402e0f2bff_android_1.png"
You can't just say "here is the url of the image, do something"
You have to download the image and set is as the wanted resource.
For a guide look here
Or if you want to use an external library you could, like Azmat said, use Picasso
Picasso.with(context).load(imageURL).into(myImageView);
You can use Picasso to load images from link
Picasso.with(context).load(worldpopulationlist.get(position).getFlag()).into(holder.flag);
p.s: this code works if your worldpopulationlist.get(position).getFlag() returns link for file.

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.

Using webview to load image from rest server in Android

I have a rest server hosted in Amazon written in Delphi with a method returning a jpg Stream image.
I need download the image and show in webview.
The method Rest Server method is something as:
//delphi code
function TSrvServerMetodos.ImagePac(pront:integer): TStream;
var blob:TStream;
begin
...
Result := CreateBlobStream(fieldbyname('PHOTO'),bmRead);
end;
where the Result is a jpeg Stream with a image.
To access the remote rest method I am trying to use the next:
String url = Common.getServerUrl() +"/"+ "\"ImagePac\"";
String URL=url+"/"+"23";
webView.loadUrl(URL);
But no Image is showing in webview.
My image is comming from a rest server and no a website. I have no way to call something as webview.loadUrl("http://www.myserver.com/myimage.jpg");
Is possible load that image with webview?
Regards, Luiz
Yes, It is. To solve the problem I had to save the image to sdcard and create a html string to load the image with webview.
For the new offspring with the same trouble. Just encode image in base64 and place it in src attribute of img tag

Categories

Resources