开发者

Unable to retrieve the image of https format for facebook in android?

开发者 https://www.devze.com 2023-03-01 09:27 出处:网络
I am trying to get images from facebook using following method. I\'m getting an error \"SSL denied\". I got the image urls from the facebook API.开发者_C百科 The image urls are of facebook profile pic

I am trying to get images from facebook using following method. I'm getting an error "SSL denied". I got the image urls from the facebook API.开发者_C百科 The image urls are of facebook profile pictures.

ImageView image=(ImageView)view.findViewById(R.id.iView);

String imageurl=https://graph.facebook.com/100000685876576/picture;

Drawable drawable=LoadImageFromWebOperations(imageurl);

image.setImageDrawable(drawable); 

private Drawable LoadImageFromWebOperations(String url) {

    try {   
        InputStream is = (InputStream) new URL(url).getContent();
        Drawable d = Drawable.createFromStream(is, "src name");
        return d;
    } catch (Exception e) {
        //Log.e("DEMO ADAPTER",e.toString());
        return null;
    }
}

can anyone help me out... Thanks.


try this

public static Bitmap downloadfile(String fileurl)
    {
        Bitmap bmImg = null;
        URL myfileurl =null;
        try
        {
            myfileurl= new URL(fileurl);
        }
        catch (MalformedURLException e)
        {
            e.printStackTrace();
        }
        try
        {
            HttpURLConnection conn= 
                    (HttpURLConnection)myfileurl.openConnection();
            conn.setDoInput(true);
            conn.connect();
            int length = conn.getContentLength();
            if(length>0)
            {
                int[] bitmapData =new int[length];
                byte[] bitmapData2 =new byte[length];
                InputStream is = conn.getInputStream();
                BitmapFactory.Options options = new 
                            BitmapFactory.Options();
                options.inSampleSize = 1;

                bmImg = BitmapFactory.decodeStream(is,null,options);

            }
            else
            {

            }

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

精彩评论

暂无评论...
验证码 换一张
取 消