Android Filenotfound Exception - Cannot Getinputstream From Image Url That Does Not Have File Format
The title is pretty self explanatory. the following code...: URL imageUrl = new URL(url); try { HttpURLConnection conn= (HttpURLConnection)imageUrl.openConne
Solution 1:
I was running into problems and I remembered googling around and this was my final solution
try {
URLurl=newURL(imageUrl);
HttpGethttpRequest=null;
httpRequest = newHttpGet(url.toURI());
HttpClienthttpclient=newDefaultHttpClient();
HttpResponseresponse= (HttpResponse) httpclient.execute(httpRequest);
HttpEntityentity= response.getEntity();
BufferedHttpEntitybufHttpEntity=newBufferedHttpEntity(entity);
InputStreaminput= bufHttpEntity.getContent();
Bitmapbitmap= BitmapFactory.decodeStream(input);
ImageActivity.this.i.setImageBitmap(bitmap);
ImageActivity.this.i.refreshDrawableState();
input.close();
} catch (MalformedURLException e) {
Log.e("ImageActivity", "bad url", e);
} catch (Exception e) {
Log.e("ImageActivity", "io error", e);
}
Post a Comment for "Android Filenotfound Exception - Cannot Getinputstream From Image Url That Does Not Have File Format"