【问题标题】:How to display Facebook Photos inside android app as a galley如何在 android 应用程序中将 Facebook 照片显示为厨房
【发布时间】:2015-08-03 14:14:14
【问题描述】:

在我的 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 活动中显示它们 ListView?

我想让它看起来像:here

【问题讨论】:

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


    【解决方案1】:

    首先检查 url 为您提供浏览器中的图像

    【讨论】:

      【解决方案2】:

      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

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 2011-06-22
        • 1970-01-01
        • 2018-12-20
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多