@Override public InputStream getStream(String imageUri, Object extra) throws IOException { InputStream imageStream = wrappedDownloader.getStream(imageUri, extra); switch (Scheme.ofUri(imageUri)) { case HTTP: case HTTPS: return new FlushedInputStream(imageStream); default: return imageStream; } } }
InputStream in = null; try { in = new java.net.URL(imageUrl).openStream(); } catch (MalformedURLException e) { e.printStackTrace(); } catch (IOException e) { e.printStackTrace(); } Bitmap image = BitmapFactory.decodeStream(new FlushedInputStream(in));
String url = server url; InputStream ins = null; try { ins = new java.net.URL(url).openStream(); } catch (MalformedURLException e) { e.printStackTrace(); } catch (IOException e) { e.printStackTrace(); } Bitmap b = BitmapFactory.decodeStream(new FlushedInputStream(ins)); imageview.setImageBitmap(b);
//I'm not sure whether this line works, but just in case I use another approach //InputStream is = (InputStream)new URL(image).getContent() DefaultHttpClient client = new DefaultHttpClient(); HttpGet request = new HttpGet(imageUrl); HttpResponse response = client.execute(request); InputStream is = response.getEntity().getContent(); //Use another stream FlushedInputStream fis = new FlushedInputStream(is); bmp = BitmapFactory.decodeStream(fis);
private Bitmap loadImageFromNetwork(String url) throws MalformedURLException, IOException { HttpURLConnection conn = (HttpURLConnection) (new URL(url)).openConnection(); conn.connect(); return BitmapFactory.decodeStream(new FlushedInputStream(conn.getInputStream())); }
HttpGet httpRequest = new HttpGet(new URL(params[0]).toURI()); HttpClient httpClient = new DefaultHttpClient(); HttpResponse response = (HttpResponse) httpClient.execute(httpRequest); HttpEntity entity = response.getEntity(); BufferedHttpEntity bufHttpEntity = new BufferedHttpEntity(entity); InputStream is = bufHttpEntity.getContent(); //image_value = new URL("image Url is here"); bm = BitmapFactory.decodeStream(new FlushedInputStream(is)); //imageLoader is object of iamge view imageLoader.setImageBitmap(bm);
public static Bitmap getBitmap(String url) { Bitmap bm = null; try { URL aURL = new URL(url); URLConnection conn = aURL.openConnection(); conn.connect(); InputStream is = conn.getInputStream(); BufferedInputStream bis = new BufferedInputStream(is); bm = BitmapFactory.decodeStream(new FlushedInputStream(is)); bis.close(); is.close(); } catch (Exception e) { e.printStackTrace(); } return bm; }
public Bitmap getBitmap(String url) { Log.d("getBitmap", "getBitmap"); Bitmap bm = null; try { URL aURL = new URL(url); URLConnection conn = aURL.openConnection(); conn.connect(); InputStream is = conn.getInputStream(); BufferedInputStream bis = new BufferedInputStream(is); bm = BitmapFactory.decodeStream(new FlushedInputStream(is)); bis.close(); is.close(); } catch (Exception e) { e.printStackTrace(); } finally { } return bm; }
public static Bitmap loadImageFromUri(URI uri) { URL url; try { url = uri.toURL(); } catch (MalformedURLException e) { Log.v("URL Exception", "MalformedURLException"); return null; } try { HttpURLConnection connection = (HttpURLConnection)url.openConnection(); connection.setDoInput(true); connection.connect(); InputStream input = connection.getInputStream(); return BitmapFactory.decodeStream(new FlushedInputStream(input)); } catch (IOException e) { e.printStackTrace(); return null; } }
content = sb.toString(); //the fetched link String myCookie = ""; //get session cookie from other call. List<Cookie> cookies = ((DefaultHttpClient)httpClient).getCookieStore().getCookies(); for(Cookie c : cookies){ if(c.getName().equals("PHPSESSID")){ myCookie = c.getName() + "=" + c.getValue(); break; } } URL url = new URL(Html.fromHtml("http://vocublablair.nl" + content).toString()); URLConnection connection = url.openConnection(); connection.setDoInput(true); connection.setRequestProperty("Cookie", myCookie); connection.connect(); Bitmap bit = BitmapFactory.decodeStream(new FlushedInputStream((InputStream) connection.getContent()));
public class URLConnectionImageDownloader extends ImageDownloader { @Override public InputStream getStreamFromNetwork(URI imageUri) throws IOException { URLConnection conn = imageUri.toURL().openConnection(); // check etag/last-modification-date/... params // if image was changed then we should delete cached image from memory cache and disc cache // Delete image from caches String uri = imageUri.toString(); File imageFile = ImageLoader.getDiscCache().get(uri) if (imageFile.exists()) { imageFile.delete(); } MemoryCacheAware<String, Bitmap memoryCache = ImageLoader.getMemoryCache(); for (String cacheKey : memoryCache.keys()) { if (cacheKey.contains(uri) { memoryCache.remove(cacheKey); } } return new FlushedInputStream(new BufferedInputStream(conn.getInputStream())); } }
Bitmap downloadBitmap(String url) { Bitmap image = null; InputStream in = null; try { in = new java.net.URL(url).openStream(); BitmapFactory.Options opts = new BitmapFactory.Options(); opts.inSampleSize = 2; image = BitmapFactory.decodeStream(new FlushedInputStream(in),null,opts); in.close(); } catch (MalformedURLException e) { e.printStackTrace(); } catch (IOException e) { e.printStackTrace(); } return image; }
@Override public InputStream getStream(String imageUri, Object extra) throws IOException { InputStream imageStream = wrappedDownloader.getStream(imageUri, extra); switch (Scheme.ofUri(imageUri)) { case HTTP: case HTTPS: return new FlushedInputStream(imageStream); default: return imageStream; } } }
@Override public InputStream getStream(String imageUri, Object extra) throws IOException { InputStream imageStream = wrappedDownloader.getStream(imageUri, extra); switch (Scheme.ofUri(imageUri)) { case HTTP: case HTTPS: return new FlushedInputStream(imageStream); default: return imageStream; } } }
@Override public InputStream getStream(String imageUri, Object extra) throws IOException { InputStream imageStream = wrappedDownloader.getStream(imageUri, extra); switch (Scheme.ofUri(imageUri)) { case HTTP: case HTTPS: return new FlushedInputStream(imageStream); default: return imageStream; } } }
@Override public InputStream getStream(String imageUri, Object extra) throws IOException { InputStream imageStream = wrappedDownloader.getStream(imageUri, extra); switch (Scheme.ofUri(imageUri)) { case HTTP: case HTTPS: return new FlushedInputStream(imageStream); default: return imageStream; } } }
URL url = new URL(imgBaseUrl + ss.getString("foto")); URLConnection connection = url.openConnection(); FlushedInputStream fis = new FlushedInputStream(connection.getInputStream()); ByteArrayBuffer baf = new ByteArrayBuffer(100); int current = 0; while((current = fis.read()) != -1){ baf.append((byte)current); } fis.close(); holder.resim.setImageBitmap(BitmapFactory.decodeByteArray(baf, 0, baf.length()));
inputStream = entity.getContent(); Bitmap bm = BitmapFactory.decodeStream(new FlushedInputStream(inputStream)); try { FileOutputStream out = new FileOutputStream(f.getAbsolutePath());
BitmapFactory.Options options = new BitmapFactory.Options(); options.inSampleSize = 4; // might try 8 also return BitmapFactory.decodeStream(new FlushedInputStream(inputStream),null,options);
@Override public InputStream getStreamFromNetwork(String imageUri, Object extra) throws IOException { NetworkProfile activeProfile = NetworkProfileManager.instance().getCurrentProfile(); if (activeProfile.getConnectionType() == NetworkProfile.Type.NO_CONNECTION || activeProfile.getConnectionHealth() == NetworkProfile.Health.NO_CONNECTION) { Log.e(TAG, "Slow network, bypassed downloading url=" + imageUri); return null; } else { URLConnection conn = new URL(imageUri).openConnection(); conn.setConnectTimeout(connectTimeout); conn.setReadTimeout(readTimeout); FlushedInputStream fis; try { fis = new FlushedInputStream(new BufferedInputStream(conn.getInputStream())); return fis; } catch (FileNotFoundException e) { Log.e(TAG, "Couldn't get image from network", e); NetworkProfileManager.instance().failedFetchingData( null, NetworkProfile.Failure.NETWORK); return null; } } } }