com.google.api.services.adsense.model.AdUnits

Here are the examples of the java api class com.google.api.services.adsense.model.AdUnits taken from open source projects.

1. AdSenseClient#getAdUnits()

Project: andlytics
File: AdSenseClient.java
public static Map<String, String> getAdUnits(Context context, String admobAccount) throws IOException {
    AdSense adsense = createForegroundSyncClient(context, admobAccount);
    Account account = getFirstAccount(adsense);
    if (account == null) {
        return new HashMap<String, String>();
    }
    String adClientId = getClientId(adsense, account);
    if (adClientId == null) {
        // XXX throw?
        return new HashMap<String, String>();
    }
    AdUnits units = adsense.accounts().adunits().list(account.getId(), adClientId).setMaxResults(MAX_LIST_PAGE_SIZE).setPageToken(null).execute();
    List<AdUnit> items = units.getItems();
    // preserver order
    Map<String, String> result = new LinkedHashMap<String, String>();
    for (AdUnit unit : items) {
        result.put(unit.getId(), unit.getName());
    }
    return result;
}