samedi 28 mai 2016

Loading an image of a website that contains redirects

I am currently doing a small app for fun while playing around with the UIs and several other things in android studio. I tried to load a image based on an url with this code:

URL urlConnection = new URL(url);

HttpURLConnection connection = (HttpURLConnection) url.openConnection();
connection.setAllowUserInteraction(false);
connection.setRequestMethod("GET");
connection.connect();
InputStream input = connection.getInputStream();
Bitmap myBitmap = BitmapFactory.decodeStream(input);

However this will throw a FileNotFoundException for certain urls. I am guessing that is due to the webpage checking the client for certain conditions. One example is this image: http://ift.tt/22s5CC8 It works fine when loading it via the webbrowser though. I do not own this page, so I do not know what is causing this issues. Is there any way to debug/solve this?




Aucun commentaire:

Enregistrer un commentaire