// Get the ActivityGroupService.
ActivityGroupServiceInterface activityGroupService =
user.getService(DfpService.V201302.ACTIVITY_GROUP_SERVICE);
// Set defaults for page and filterStatement.
ActivityGroupPage page = new ActivityGroupPage();
Statement filterStatement = new Statement();
int offset = 0;
do {
// Create a statement to get all activity groups.
filterStatement.setQuery("LIMIT 500 OFFSET " + offset);
// Get activity groups by statement.
page = activityGroupService.getActivityGroupsByStatement(filterStatement);
if (page.getResults() != null) {
int i = page.getStartIndex();
for (ActivityGroup activityGroup : page.getResults()) {
System.out.printf(
"%s) Activity group with ID \"%d\" and name \"%s\" was found.\n", i++,
activityGroup.getId(), activityGroup.getName());
}
}
offset += 500;
} while (offset < page.getTotalResultSetSize());
System.out.println("Number of results found: " + page.getTotalResultSetSize());
} catch (Exception e) {
e.printStackTrace();
}
}