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. ActiveMQ 目录

    (1) ActiveMQ简介 (2) JMS基本概念和模型 (3) JMS的可靠性 (4) ActiveMQ结合Spring开发 (5)ActiveMQ支持的传输协议 (6)ActiveMQ消息存储持 ...

  2. php简单实用的操作文件工具类(创建、移动、复制、删除)

    php简单实用好用的文件及文件夹复制函数和工具类(创建.移动.复制.删除) function recurse_copy($src,$dst) {  // 原目录,复制到的目录 $dir = opend ...

  3. 修改PUTTY支持保存密码

    1.从官网下载 Putty 0.60 Release 的 Windows 版源码 http://www.chiark.greenend.org.uk/~sgtatham/putty/download. ...

  4. sqlserver中将某数据库下的所有表字段名称为小写的改为大写

    declare @name varchar(50), @newname varchar(50),@colname varchar(50) declare abc cursor for select ( ...

  5. Windows疑难杂症之开机无法显示桌面。

    开机无法显示桌面可能有以下两种情况. 1.系统故障或病毒引起explorer.exe无法加载启动. 2.注册表故障造成默认的值不是explorer.exe.(可能是安装了某些软件造成此问题) 3,某开 ...

  6. Swift2.1 语法指南——访问控制

    原档:https://developer.apple.com/library/prerelease/ios/documentation/Swift/Conceptual/Swift_Programmi ...

  7. BZOJ4517——[Sdoi2016]排列计数

    求有多少种长度为 n 的序列 A,满足以下条件: 1 ~ n 这 n 个数在序列中各出现了一次 若第 i 个数 A[i] 的值为 i,则称 i 是稳定的.序列恰好有 m 个数是稳定的 满足条件的序列可 ...

  8. [POJ1068]Parencodings

    [POJ1068]Parencodings 试题描述 Let S = s1 s2...s2n be a well-formed string of parentheses. S can be enco ...

  9. Linux之编译需要的文件变化时刻

  10. 补上题代码 hdu1520

    #include<iostream> #include<cmath> #include<algorithm> #include<vector> #inc ...