2013-05-04 10 views
15

Ich benutze Facebook SDK 3.0 Ich muss Profilbild von Benutzeranmeldung erhalten. Hier ist der Code ich benutze:So erhalten Sie Facebook Profilbild des Benutzers in Facebook SDK 3.0 Android

URL image_value = new URL("http://graph.facebook.com/"+id+"/picture"); 
profPict=BitmapFactory.decodeStream(image_value.openConnection().getInputStream()); 

Aber ich habe nicht das gewünschte Ergebnis.

+1

i auch für gleiche Typ Suche und nicht genau Profilbild gleichen Code verwendet bekommen :) – user

Antwort

12

Wenn Sie versuchen, Profilbild in Ihrer App anzuzeigen, verwenden Sie ProfilePictureView von Facebook SDK.

Refer This

Gerade setProfileId(String profileId) auf es nennen.

Es wird darauf geachtet, das Bild anzuzeigen.

+0

Ist es das Problem zu lösen? –

+0

ist es async-lly geladen? –

+0

Ja, es lädt Bilder async-ly :) –

2

Sie können in einem Thread etwas tun:

String url = "http://graph.facebook.com/"+id+"/picture"; 
HttpConnection conn = new HttpConnection(url); 
conn.openConnection(); 

Drawable d = Drawable.createFromStream(new BufferedInputStream(conn.getInputStream()), "image"); 

conn.close(); 

Ich hoffe, dass es Ihnen helfen.

5

Verwenden ProfilePictureView von facebook sdk.

16

Verwenden https: // statt http: // konfrontiert ich das gleiche Problem.

URL image_value = new URL("https://graph.facebook.com/"+id+"/picture"); 
profPict = BitmapFactory.decodeStream(image_value.openConnection().getInputStream()); 
+1

Danke! Die einzige Antwort, die geholfen hat. – Dima

+0

Ich habe das gleiche Problem mit Ihrer Hilfe gelöst. Vielen Dank. – TeachMeJava

6
String id = user.getId(); 
try { 
    URL url = new URL("http://graph.facebook.com/"+ id+ "/picture?type=large"); 
    String image_path = uri.toString(); 
    System.out.println("image::> " + image_path); 
} 
catch (MalformedURLException e) { 
    e.printStackTrace(); 
} 
2

dies versuchen ..

try { 
     imageURL = new URL("https://graph.facebook.com/" + 
               id+ "/picture?type=large"); 
     Log.e("URL", imageURL.toString()); 
     } catch (MalformedURLException e1) { 
       // TODO Auto-generated catch block 
       e1.printStackTrace(); 
      try { 
        bitmap = BitmapFactory.decodeStream(imageURL 
           .openConnection().getInputStream()); 
       } catch (IOException e) { 
         // TODO Auto-generated catch block 
         e.printStackTrace(); 
       } 

     ProfileDp.setImageBitmap(bitmap); 
Verwandte Themen