I didn\'t find any help on this topic. The Docs say
Cursor-based pagination is the most efficient method of paging and should always be used where possibl
I use this code:
final String[] afterString = {""};
final Boolean[] noData = {true};
StrictMode.ThreadPolicy policy = new StrictMode.ThreadPolicy.Builder().permitAll().build();
StrictMode.setThreadPolicy(policy);
do{
GraphRequest request = GraphRequest.newGraphPathRequest(
AccessToken.getCurrentAccessToken(),
"/me/likes",
new GraphRequest.Callback() {
@Override
public void onCompleted(GraphResponse response) {
// Insert your code here
JSONObject jsonObject = response.getJSONObject();
try{
if(jsonObject.length() > 1) {
JSONObject jsonFacebook = (JSONObject) new JSONTokener(jsonObject.toString()).nextValue();
JSONObject likes_paging = (JSONObject) new JSONTokener(jsonFacebook.getJSONObject("paging").toString()).nextValue();
ArrayList likes = new ArrayList();
for (int i = 0; i < jsonFacebook.getJSONArray("data").length(); i++) {
likes.add(jsonFacebook.getJSONArray("data").getJSONObject(i).getString("name"));
}
afterString[0] = (String) likes_paging.getJSONObject("cursors").get("after");
}else{
noData[0] = false;
}
} catch (JSONException e) {
e.printStackTrace();
}
}
});
Bundle parameters = new Bundle();
parameters.putString("pretty", "0");
parameters.putString("limit", "100");
parameters.putString("after", afterString[0]);
request.setParameters(parameters);
request.executeAndWait();
}while(noData[0] == true);