I'm trying to get all friends of a user ID. But I don't understand how to do paging. This is my code:
ResponseList<Friend> results = facebook.getFriends(USER_ID);
ArrayList<String> friendList = new ArrayList<String>();
// Getting Next page
Paging<Friend> paging1 = results.getPaging();
for (int i = 0; i < results.size(); i++) {
Friend f = results.get(i);
String id = f.getId().toString();
friendList.add(id);
System.out.println(id);
}
ResponseList<Friend> page2 = facebook.fetchNext(paging1);
for (int i = 0; i < page2.size(); i++) {
System.out.println(page2.size());
Friend f = page2.get(i);
String id = f.getId().toString();
friendList.add(id);
System.out.println(id);
}
With this code, I can only obtain the first 9 friends' IDs. It seems that the second paging doesn't retrieve anything. What's wrong?