tags:

views:

28

answers:

0

I am able to download images from normal http but not from https link ,dont know whats the problem with that...

I used two way to download images from normal http link

I. Using URL to HttpUrlConnection

     public void downloadFile(String fileUrl){

     URL url =null; 
         try {
            url= new URL(fileUrl);
         } catch (MalformedURLException e) {
         // TODO Auto-generated catch block
           e.printStackTrace();
         }
        try {
            HttpURLConnection conn= (HttpURLConnection) url.openConnection();
            conn.setDoInput(true);
            conn.connect();
            InputStream is = conn.getInputStream();

            Bitmap bmImg = BitmapFactory.decodeStream(is);
            imageView.setImageBitmap(bmImg);

          } catch (IOException e) {
         // TODO Auto-generated catch block
           e.printStackTrace();
          }
     }

II. Using normal URL

        public Drawable loadImageFromUrl(String url) {
        Drawable d = null;
        try {
            InputStream is = (InputStream) fetch(url);
            if(is != null)
            System.out.println("Value is not null");

            d = Drawable.createFromStream(is, "src");
            return d;
        } catch (MalformedURLException e) {
            e.printStackTrace();
            return null;
        } catch (IOException e) {
            e.printStackTrace();
            return null;
        }               
    }        

    public Object fetch(String address) throws MalformedURLException,IOException {
        URL url = new URL(address);
        Object content = url.getContent();
        return content;
    }
Please share any code which will download images from https link.
Thanks 
Mintu