我使用的是facebook SDK 3.0,我必须获取用户登录的个人资料图片.这是我使用的代码



我使用的是facebook SDK 3.0,我必须获得用户登录的个人资料图片。这是我使用的代码

public Bitmap getUserPic(String userID) {
    String imageURL;
    Bitmap bitmap = null;
    imageURL = "http://graph.facebook.com/" + userID + "/picture?type=small";
    try {
        bitmap = BitmapFactory.decodeStream((InputStream) new URL(imageURL).getContent());
    } catch (Exception e) {
        Log.d("TAG", "Loading Picture FAILED");
        e.printStackTrace();
    }       
    return bitmap;
}

如果您想在imageview中设置配置文件图片,只需将此代码与您的userId 一起使用

ProfilePictureView  image=((ProfilePictureView)mMovableListView.findViewById(R.id.imageView1)) ;
image.setProfileId(userid);

最新更新