}
public static void runExample(
AdWordsServices adWordsServices, AdWordsSession session) throws Exception {
// Get the MediaService.
MediaServiceInterface mediaService =
adWordsServices.get(session, MediaServiceInterface.class);
int offset = 0;
// Create selector.
Selector selector = new Selector();
selector.setFields(new String[] {"MediaId", "Width", "Height", "MimeType"});
selector.setPaging(new Paging(offset, PAGE_SIZE));
selector.setOrdering(new OrderBy[] {new OrderBy("MediaId", SortOrder.ASCENDING)});
selector.setPaging(new Paging(offset, PAGE_SIZE));
// Create predicates.
Predicate typePredicate =
new Predicate("Type", PredicateOperator.IN, new String[] {"IMAGE", "VIDEO"});
selector.setPredicates(new Predicate[] {typePredicate});
MediaPage page = null;
do {
// Get all images.
page = mediaService.get(selector);
// Display images.
if (page != null && page.getEntries() != null) {
for (Media media : page.getEntries()) {
Map<MediaSize, Dimensions> dimensions = Maps.toMap(media.getDimensions());