我正在使用最新的 android-simple-facebook 库(https://github.com/sromku/android-simple-facebook),并且想要获取带有姓名、图片(个人资料图片)的朋友列表。
但我根本无法得到朋友的照片..
下面是我的代码...
在登录监听器
private OnLoginListener mOnLoginListener = new OnLoginListener() {
@Override
public void onFail(String reason) {
Log.w(TAG, "Failed to login");
}
@Override
public void onException(Throwable throwable) {
Log.e(TAG, "Bad thing happened", throwable);
}
@Override
public void onThinking() {
// show progress bar or something to the user while login is
// happening
}
@Override
public void onLogin() {
PictureAttributes pictureAttributes = Attributes.createPictureAttributes();
pictureAttributes.setType(PictureType.NORMAL);
pictureAttributes.setHeight(500);
pictureAttributes.setWidth(500);
// change the state of the button or do whatever you want
Properties properties = new Properties.Builder()
.add(Properties.ID)
.add(Properties.LAST_NAME)
.add(Properties.PICTURE, pictureAttributes)
.add(Properties.BIRTHDAY).build();
mSimpleFacebook.getFriends(properties, mOnFriendsListener);
}
@Override
public void onNotAcceptingPermissions(Permission.Type type) {
}
};
和朋友的听众
// get friends listener
private OnFriendsListener mOnFriendsListener = new OnFriendsListener() {
@Override
public void onFail(String reason) {
// insure that you are logged in before getting the friends
Log.w(TAG, reason);
}
@Override
public void onException(Throwable throwable) {
Log.e(TAG, "Bad thing happened", throwable);
}
@Override
public void onThinking() {
// show progress bar or something to the user while fetching profile
Log.i(TAG, "Thinking...");
}
@Override
public void onComplete(List<Profile> friends) {
for (Profile profile : friends) {
mLists.add(new FriendItem(profile.getName(), profile.getPicture()));
}
mAdapter = new FriendsListAdapter(getActivity());
mFriendsList.setAdapter(mAdapter);
}
};
但配置文件对象仅包含 id 和 name。我应该用异步调用get方法吗?或者我可以用 getFriends() 方法做的任何其他事情。
权限列表如下:
Permission[] permissions = new Permission[] {
Permission.BASIC_INFO,
Permission.USER_CHECKINS,
Permission.USER_EVENTS,
Permission.USER_GROUPS,
Permission.USER_LIKES,
Permission.USER_PHOTOS,
Permission.USER_VIDEOS,
Permission.FRIENDS_EVENTS,
Permission.FRIENDS_PHOTOS,
Permission.PUBLISH_STREAM };