How to avoid all the pictures from loading, in WebView?
Also I need to get the URL of those pictures.
Thanks in advance!
If you are developing for API level 11 or later, you can use the WebViewClient.shouldInterceptRequest to handle the request for loading an image. The second parameter of the method is the URL of the resource.
You would have to return the WebResourceResponse object, possibly a placeholder/error image if you do not want the original image to be loaded.
Related
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.
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.
Issues Faced
I was able to get image url data using Okhttp but then store it on an arraylist but was faced with an issue because this processes takes time so when my activity start the view is seen before the data is received.
I am querying image urls from the server then displaying/loading them to a recycler view using picasso help please...?
Loading the data from the api should be an asynchronous process, if you want to notify the user while that is happening, you can show a progress bar.
Upon receiving the data from the server, hide the progress bar and then load the images in the picasso, you can also specify a default image to picasso, which will be shown while the image itself is being loaded.
Use a progressDialog until receive your image urls from server and then dismiss it and then load it with picasso.
//before starting connection
progressDialog.show();
//on Connection complete:
progressDialog.dismiss();
You can show image using Picasso library using this code :
Picasso.with(context)
.load(post_pic_url)
.placeholder(R.drawable.placeholder_post) // use a placeholder image here
.fit() // to fit image on image view
.centerCrop()
.into(imgPost); // your image view object
If any explaination then please let me know in comments
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
I have a quick question how to receive a jpg image from a web api call.
String result = webApiManager.getBarcode(dataStorageManager.currentUser.CustomerID);
This method returns a jpg image but I am unsure how to handle it and display it in an ImageView. Furthermore, what data type is a jpg image and how do I convert it into an image that I can display using an ImageView. Can someone point me in the right direction on how to accomplish this. Thanks for your time.
Regards,
Ryan
instead of returning the image as a jpg...why not just return the URL to the image and then use AsyncTask in processing it...
It will be easier and faster that way... just my 2cents