如何在Android应用程序中显示Facebook照片作为厨房

时间:2013-06-21 03:11:26

标签: android json android-layout facebook-graph-api facebook-android-sdk

在我的Android应用中,我想显示来自https://graph.facebook.com/photoAlbumId/photos的所有照片photoAlbumId是用户fb。名。

我通常使用

获取用户个人资料照片
 ImageView user_picture;
 userpicture=(ImageView)findViewById(R.id.userpicture);
 URL img_value = null;
 img_value = new URL("http://graph.facebook.com/"+id+"/picture?type=large");
 Bitmap mIcon1 = BitmapFactory.decodeStream(img_value.openConnection().getInputStream());
 userpicture.setImageBitmap(mIcon1);

如何获取所有图像,例如https://graph.facebook.com/zoo/photos并在android活动中显示它们?

我想让它看起来像:here

2 个答案:

答案 0 :(得分:0)

首先检查网址是否为您提供了浏览器中的图片

答案 1 :(得分:0)



try
{
    URL url = new URL(imageUrl);
    HttpURLConnection conn = (HttpURLConnection) url.openConnection();
    conn.setInstanceFollowRedirects(true);
    HttpURLConnection.setFollowRedirects(true);

    String con2=conn.getHeaderField("Location");
    conn=(HttpURLConnection)new URL(con2).openConnection();
    conn.connect();
    InputStream input = conn.getInputStream();
    Log.e("link",conn.getURL().toString());

    Bitmap bitmap = BitmapFactory.decodeStream(input);
    Log.e("Image", "get");
    return bitmap;
}
catch (IOException e)
{
   Log.e("Image", "fall");
   e.printStackTrace();
   return null;
}




Facebook profile image not getting displayed in android image view

如果你想从" http://graph.facebook.com/" + id +" / picture?type = large"获取图片,必须手动重定向并处理它。

Manually Redirect