Bundle params = new Bundle();
params.putString("fields", "id,email,gender,cover,picture.type(large)");
new GraphRequest(token, "me", params, HttpMethod.GET,
new GraphRequest.Callback() {
@Override
public void onCompleted(GraphResponse response) {
if (response != null) {
try {
JSONObject data = response.getJSONObject();
if (data.has("picture")) {
String profilePicUrl = data.getJSONObject("picture").getJSONObject("data").getString("url");
Bitmap profilePic = getFacebookProfilePicture(profilePicUrl);
// set profilePic bitmap to imageview
}
} catch (Exception e) {
e.printStackTrace();
}
}
}
}).executeAsync(); public static Bitmap getFacebookProfilePicture(String url){
Bitmap bitmap = BitmapFactory.decodeStream(url.openConnection().getInputStream());
return bitmap;
}

Or:

GraphJSONObjectCallback mCallback = new GraphJSONObjectCallback()
{
@Override
public void onCompleted(JSONObject mData, GraphResponse mResponse)
{
if(mResponse.getError() == null)
{
try
{
final JSONObject mPicture = mData.getJSONObject("picture");
final JSONObject mPictureData = mPicture.getJSONObject("data");
final boolean mSilhouette = mPictureData.getBoolean("is_silhouette"); **//this is the URL to the image that you want**
final String mImageUrl = mPictureData.getString("url");
} catch (JSONException e)
{
//JSON Error, DEBUG
}
} else
{
//Facebook GraphResponse error, DEBUG
}
}
}; Bundle mBundle = new Bundle();
mBundle.putString("fields", "picture"); GraphRequest mGetUserRequest = GraphRequest.newMeRequest(AccessToken.getCurrentAccessToken(), mCallback);
mGetUserRequest.setParameters(mBundle); //if running this on the MAIN THREAD then use .executeAsync()

  

Or:

private void importFbProfilePhoto() {

    if (AccessToken.getCurrentAccessToken() != null) {

        GraphRequest request = GraphRequest.newMeRequest(
AccessToken.getCurrentAccessToken(), new GraphRequest.GraphJSONObjectCallback() {
@Override
public void onCompleted(JSONObject me, GraphResponse response) { if (AccessToken.getCurrentAccessToken() != null) { if (me != null) { String profileImageUrl = ImageRequest.getProfilePictureUri(me.optString("id"), 500, 500).toString();
Log.i(LOG_TAG, profileImageUrl); }
}
}
});
GraphRequest.executeBatchAsync(request);
}
}

refer to :http://stackoverflow.com/questions/19855072/android-get-facebook-profile-picture

[Android] how to get facebook profile的更多相关文章

  1. Android 应用程序集成FaceBook 登录及二次封装

    1.首先在Facebook 开发者平台注册一个账号 https://developers.facebook.com/ 开发者后台  https://developers.facebook.com/ap ...

  2. 在Android上实现使用Facebook登录(基于Facebook SDK 3.5)

    准备工作: 1.       Facebook帐号,国内开发者需要一个vpn帐号(网页可以浏览,手机可以访问) 2.       使用Facebook的SDK做应用需要一个Key Hashes值. 2 ...

  3. Android之Fresco(facebook的强大Android图片加载的框架)

    Fresco是Facebook最新推出的一款用于Android应用中展示图片的强大图片库,可以从网络.本地存储和本地资源中加载图片.其中的Drawees可以显示占位符,直到图片加载完成.而当图片从屏幕 ...

  4. Android集成友盟facebook分享

    在项目中需要将图片和视频分享到社交平台,所以集成了友盟分享.在集成facebook分享的时候走了不少弯路,现在将过程记录下来. 1.先将友盟facebook的jar包复制到项目的libs文件夹下. 2 ...

  5. Android Facebook和Twitter登录和分享完整版

    最近公司的软件需要改国际版,需要Facebook和Twitter的登录和分享. 本人先用Umeng的第三方社会化分享实现了该功能,但是后来一想问题来了,经过查证.Umeng只在中国和美国有服务器,那也 ...

  6. Android 版 Facebook 登录

    Android 版 Facebook SDK 让用户可以通过 Facebook 登录注册您的应用.通过 Facebook 登录您的应用时,用户可以向应用授予权限,以便您可以检索信息或以用户的身份在 F ...

  7. 【Android】[转] Android Codec默认profile使用的是Baseline

    关于Android默认Codec使用的Profile找了半天没发现,还是Google的时候发现了开源中国有网友写的这边博客,相关的内容很少,便贴了过来做个笔记. 以下内容转自Android Media ...

  8. 【安卓开发】Facebook工程师是如何改进他们Android客户端的

    原文出处: Facebook   译文出处:penkzhou   欢迎分享原创到伯乐头条 作为世界上最大的社交网络,Facebook的Android客户端面临着各种各样的使用环境(地理环境.Andro ...

  9. Facebook工程师是如何改进他们Android客户端的

    from://http://greenrobot.me/devnews/facebook-engineer-improve-android-app/ Facebook工程师是如何改进他们Android ...

随机推荐

  1. MFC CStatic类动态创建

    如果我使用下面风格: m_PictureCtrl.Create(NULL, WS_EX_TRANSPARENT|WS_CHILD|WS_VISIBLE|WS_TABSTOP|SS_OWNERDRAW, ...

  2. protobuf

    1.下载地址:https://code.google.com/p/protobuf/downloads/list 安装 ./configure && make && m ...

  3. lua 学习

    尽管所有的脚本语言在特定领域都有自己的一席之地,但在游戏开发的世界里,Python 和 Lua 是非常适合的,因为它们可以直接调用C++的功能. lua最让人惊喜的地方应该是它的执行速度,目前没有任何 ...

  4. java练手 公约数和公倍数

    Problem D 公约数和公倍数 时间限制:1000 ms  |  内存限制:65535 KB   描述 小明被一个问题给难住了,现在需要你帮帮忙.问题是:给出两个正整数,求出它们的最大公约数和最小 ...

  5. Ruby中Block, Proc, 和Lambda

    Block Blocks就是存放一些可以被执行的代码的块,通常用do...end 或者 {}表示 例如: [1, 2, 3].each do |num| puts num end [1, 2, 3]. ...

  6. mybatis 多个dao重名,根据namespace解析

    在mybatis通过执行sql语句的方式是,用getSqlSession().xxx(param,..)方法来调用, 其中第一个参数就是dao mapper.xml文件的命名空间.id package ...

  7. 在Xcode6.4中使用OpenCV

    XCode版本6.4,OpenCV版本3.0.0 昨天我安装完OpenCV之后,兴奋地按照这篇文章Mac平台上OpenCV开发环境搭建的步骤,在XCode上建了一个Demo工程,结果编译一直不成功.一 ...

  8. loadrunner-27796错误寻求解决办法

    Action.c(58): Error -27796: Failed to connect to server "www.baidu.com:80": [10048] Addres ...

  9. php curl 库使用

    支持http basic认证: curl_setopt($ch, CURLOPT_HTTPAUTH, CURLAUTH_BASIC); curl_setopt($ch, CURLOPT_USERPWD ...

  10. 使用C++扩展Python的功能 转自:http://blog.csdn.net/magictong/article/details/8897568#comments

    使用C++扩展Python的功能 环境 VS2005Python2.5.4 Windows7(32位) 简介 长话短说,这里说的扩展Python功能与直接用其它语言写一个动态链接库,然后让Python ...