Reputation: 267
The following steps allow me to fetch an image kept on my TomCat server. but i am unable to access an image from google's web site . What could be the reason ?
URL aURL = new URL(url);
URLConnection con = aURL.openConnection();
con.connect();
InputStream is = con.getInputStream();
/* Buffered is always good for a performance plus. */
BufferedInputStream bis = new BufferedInputStream(is);
/* Decode url-data to a bitmap. */
bm = BitmapFactory.decodeStream(bis);
bitmapDrawable = new BitmapDrawable(bm);
My URL :http://172.29.26.34:8080/MyService/hb.gif
Google image :
Upvotes: 1
Views: 241
Reputation: 1
Set User-Agent
URLConnection con = aURL.openConnection(); con.setRequestProperty("User-Agent","");
Upvotes: 0
Reputation: 35341
It is because the google link you pasted is the link for an image viewer in a frame, not for the picture itself. (And actually, strictly speaking the image is not from google website, it was just indexed and displayed by google)
In the right column there is a link 'view full size picture' to go to the real image.
If you use pictures from the web on your website, be sure to check the license if it is acceptable to do so or seek permission.
Upvotes: 3