0

In my android project I would like to get a Bitmap image from given URL(htp://....) for this purpose I have used the below code to achieve this concept. But while running my code I am getting java.io.FileNotFoundException. So anyone please provide a better solution to solve this issue or else provide any code snippet to achieve this task.

public static Bitmap getBitmapFromURL(String src) {
        try {
            Log.e("src", src);
            String stringURL = "http://.....";          
            URL url = new URL(stringURL);
            HttpURLConnection connection = (HttpURLConnection) url
                    .openConnection();
            connection.setDoInput(true);
            connection.connect();
            InputStream input = connection.getInputStream();
            Bitmap myBitmap = BitmapFactory.decodeStream(input);
            Log.e("Bitmap", "returned");
            return myBitmap;
        } catch (IOException e) {
            e.printStackTrace();
            Log.e("Exception", e.getMessage());
            return null;
        }
    }
Jamal
  • 976
  • 2
  • 14
  • 39
  • 1
    `String stringURL = "http://....."` is it a **valid URL**? Try this one: `String stringURL = "http://looksok.files.wordpress.com/2011/12/me.jpg";` And this is the tutorial you should follow: http://looksok.wordpress.com/2013/07/06/android-tutorial-download-image-from-the-internet-with-url/ – Phantômaxx Jun 11 '14 at 15:42
  • 1
    have you tried the url in a browser? – Alejandro Cumpa Jun 11 '14 at 15:48

0 Answers0