0

在我的Android應用中,我想顯示https://graph.facebook.com/photoAlbumId/photos的所有照片,其中photoAlbumId是用戶fb。名稱。如何在Android應用中顯示Facebook照片作爲廚房

我通常會得到用戶個人資料的圖片使用

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

回答

0

第一查詢的網址讓你在瀏覽器

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」,必須redir等並手動處理。

Manually Redirect

+0

雖然此鏈接可以回答這個問題,最好是在這裏有答案的主要部件,並提供鏈接以供參考。如果鏈接頁面更改,則僅鏈接答案可能會失效。 –

+0

我做了一點改變 可以嗎? – depraved

相關問題