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. JDBC、JDBCTemplate、MyBatis、Hiberante 比较与分析

    JDBC (Java Data Base Connection,java数据库连接) JDBC(Java Data Base Connection,java数据库连接)是一种用于执行SQL语句的Jav ...

  2. ASP跨域调用Webservices方法

    仅用于记录与分享,直接贴代码: <script type="text/javascript"> function check(){ var title=$('#titl ...

  3. 升级xcode7.0 第三方库不能用的解决方法(bitcode是什么鬼?)

    升级完xcode,真机运行发现报错,第三方库错误,微信SDK,高德SDK都报错,如下: ‘/Users/**/Framework/SDKs/PolymerPay/Library/mobStat/lib ...

  4. gdb调试core文件

    本人最近正在学习调试技术,此处对栈溢出做一些总结. gdb的基本使用就不多扯了. 主要针对发行在外的release版本的软件出现问题时的调试. 一般来讲,查看堆栈就是使用bt,这个时候加上bt ful ...

  5. Hadoop 之Hbase命令

    一.常用命令:(hbase shell 进入终端) 1.创建表: create 'users','user_id','address','info' 表users,有三个列族user_id,addre ...

  6. iOS设备 屏幕尺寸、操作系统、摄像头像素、发行时间 汇总

    设备 硬件尺寸 软件尺寸 精密程度 操作系统 摄像头像素 发行时间 iPhone 4s 640 x 960 320 x 480 2x iOS 5 800万 2011.10.04 iPhone 5 64 ...

  7. Mac Pro Office Word 2011 个性化设置

    操作系统:Mac Pro OS X 10.11.5 1.常用的几个操作: (1).视图 -> 功能区 (2).视图 -> 打印版式 (3).视图 -> 大纲 (4).视图 -> ...

  8. mytbatis小问题

    使用mybatis出现以下异常 SQLErrorCodes loaded: [DB2, Derby, H2, HSQL, Informix, MS-SQL, MySQL, Oracle, Postgr ...

  9. 循环执行n次的代码

    var audio = document.createElement("audio");  var index = 0;    audio.src = "piano/3C ...

  10. DEV控件Grid显示行号

    DEV控件Grid的显示行号需要通过一个事件来设置,具体设置代码为: private void gridView1_CustomDrawRowIndicator(object sender, DevE ...