Android how to display and image from URL - android

I'm having trouble displaying SOME images on my android app. Just normal display image from certain URL. Some images works, some just doesn't work. For instance try displaying this image from URL:
http://img191.imageshack.us/img191/7379/tronlegacys7i7wsjf.jpg
It doesn't work. Doesn't even work in emulator.
Could it be the EXIF info for the image is problematic? Can anyone try to see they are able to display that image on android app, and share the code/method to display that image on screen?
Thank you!

Or you can try this ImageDownloader class from google. It´s works nice :) Is an AsynkTask that handle the download and set the bitmap to an ImageView.
ImageDownloader
Usage:
private final ImageDownloader mDownload = new ImageDownloader();
mDownload.download("URL", imageView);

You will have no problems displayin that image in a webview
WebView myWebView = (WebView) findViewById(R.id.webview);
myWebView.loadUrl("http://img191.imageshack.us/img191/7379/tronlegacys7i7wsjf.jpg");
where are your image being displayed?

Make sure you have <uses-permission android:name="android.permission.INTERNET" /> in your AndroidManifest.xml. What code are you using to load the image?

Related

Download image and use Zoom library

I have an activity that I'm going to display an image and I need to zoom in on it, so I found this lib
https://github.com/davemorrissey/subsampling-scale-image-view
But my picture comes from a URL I'm using Volley.
How could I use this zoom lib by downloading the image?
Intent callIntent = getIntent();
Bundle callBundle = callIntent.getBundleExtra("package");
SubsamplingScaleImageView imageView = (SubsamplingScaleImageView)findViewById(R.id.imageView);
//imageView.setImage(ImageSource.resource(R.drawable.monkey));
GlideApp.with(this).load(callBundle.getString("img")).into(imageView);
Glide does not fill the object "SubsamplingScaleImageView"
I know your question pertains to Volley but you didn't mention that it was a strict requirement. You could use Fresco image library developer by facebook and at that repo they have an example of a Zoomable Image View:
https://github.com/facebook/fresco/blob/master/samples/zoomable/src/main/java/com/facebook/samples/zoomable/ZoomableDraweeView.java

displaying image in the imageview directly from the internet

I want to load an image which is located at the url "http://www.Karnatakatourism.org/mm/slide/chickmaglur_home.jpg" onto the imageview in Android.
Can anyone help me with the code to do the same?
You can use android query lib. http://code.google.com/p/android-query/wiki/ImageLoading
You just need to write
aq.id(R.id.imageview_profilee).image("your path");
You can use this one...
There many libs to do this, You can use Picasso.
Here an example of usage:
Picasso.with(context).load("http://www.karnatakatourism.org/mm/slide/chickmaglur_home.jpg").into(imageView);
Or you can use Universal Image Loader class
in which you can use by this one.
imageLoader.displayImage("http://www.karnatakatourism.org/mm/slide/chickmaglur_home.jpg", imageView, options);

Android ViewFlipper change background with image from URL how to

I'm trying to change a background image on my ViewFlipper... But can't get it to work... Do I have to download the image before set it to the ViewFlipper? .. I saw an example where the URL is used.. But I can't! .
this.vf.setBackgroundDrawable("http://path_to_background_image");
I found the solution myself...
Bitmap bg_img = BitmapFactory.decodeStream((InputStream) new
URL(webservice.getString("background_image_url")).getContent());
vf.setBackgroundDrawable(new BitmapDrawable(bg_img));

Novoda ImageLoader - loaded same image

I'm using Novoda ImageLoader (https://github.com/novoda/ImageLoader) and when I use this loader in CursorAdapter everything is fine. But when I want to use without any Adapter in Activity with one ImageView, I get same image for different URLs.
//onCreate in Activity
imageManager = MyApplication.getImageLoader();
imageTagFactory = new ImageTagFactory(this, R.drawable.ic_refresh_inverse);
imgView = (ImageView) findViewById(R.id.imgIV);
//fillData - when I finish loading img URL from DB with CursorLoader
imgView.setTag(imageTagFactory.build(imgURL));
imageManager.getLoader().load(imgView);
//code in onCreate Application
LoaderSettings settings = new SettingsBuilder().withDisconnectOnEveryCall(true).withCacheManager(new LruBitmapCache(this)).build(this);
imageManager = new ImageManager(this, settings);
When I looked to the cache directory, the different image is loaded, but not used.
Any idea where can be problem or how to properly use this library to simply load only one image?
Thank you!
The issue is probably similar to this https://github.com/novoda/ImageLoader/issues/41
do you have query parameters in the url? if so try to add this
.withEnableQueryInHashGeneration(false) on the setting builder
This is a bug that is inverting the logic behind the parameter enableQueryInHashGeneration. This parameter should enable/disable (by default should be enable) the query part of the url in the generation of the hashname of the image. This is useful when you have session token in the url as a parameter and you don't want to download the same image over and over.
The problem will be solved in the 1.5.6 version

JSOUP to display images in Image view using the URL

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.

Categories

Resources