15

Facebook SDK 3.0 を使用しています。ユーザー ログインのプロフィール写真を取得する必要があります。私が使用するコードは次のとおりです。

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

しかし、私は望ましい結果が得られません。

4

8 に答える 8

24

次のコードを変更する必要があります。

URL image_value = new URL("http://graph.facebook.com/"+id+"/picture" );

URL の可能な GET パラメータは、 https ://developers.facebook.com/docs/graph-api/reference/user/picture/ にあります。

于 2013-07-22T18:23:00.867 に答える
16

http: //の代わりにhttps://を使用してください 。同じ問題に直面しました。

URL image_value = new URL("https://graph.facebook.com/"+id+"/picture" );
profPict = BitmapFactory.decodeStream(image_value.openConnection().getInputStream());
于 2014-04-07T10:20:11.623 に答える
12

アプリでプロフィール写真を表示しようとしている場合はProfilePictureView、Facebook SDK から使用してください。

これを参照

それを呼び出すだけsetProfileId(String profileId)です。

画像の表示を処理します。

于 2013-05-04T12:30:41.943 に答える
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();
}
于 2014-06-19T12:10:18.107 に答える
5

ProfilePictureViewfacebook SDK から使用します。

于 2013-09-02T05:39:37.277 に答える
2

これを試して..

 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);
于 2015-08-18T05:40:00.957 に答える
0

Facebook アカウントでアプリケーションにログインしたら、次のようにします。

String url = Profile.getCurrentProfile().getProfilePictureUri(x, y).toString();

x と y は幅と高さです。

ドキュメントを参照してください: https://developers.facebook.com/docs/reference/android/current/class/Profile/

于 2016-05-25T14:13:15.900 に答える