// Set AdListener adView.setAdListener(new AdListener() { @Override public void onFailedToReceiveAd(Ad ad, ErrorCode error) { System.err.println("Ad failed: " + ad.toString() + error.toString()); } @Override public void onReceiveAd(Ad ad) { System.out.println("Ad received: " + ad.toString()); } });
// Set AdListener adView.setAdListener(new AdListener() { @Override public void onFailedToReceiveAd(Ad ad, ErrorCode error) { System.err.println("Ad failed: " + ad.toString() + error.toString()); } @Override public void onReceiveAd(Ad ad) { System.out.println("Ad received: " + ad.toString()); } });
AdView av = (AdView)findViewById(R.id.adView); // Set AdListener av.setAdListener(new AdListener() { AdView av = (AdView)findViewById(R.id.adView); @Override public void onFailedToReceiveAd(Ad ad, ErrorCode error) { System.err.println("Ad failed: " + ad.toString() + error.toString()); av.setVisibility(AdView.GONE);//By setting visibility to GONE, you hide the AdView, but the AdView won't refresh automaticaly anymore. } @Override public void onReceiveAd(Ad ad) { System.out.println("Ad received: " + ad.toString()); av.setVisibility(AdView.VISIBLE); } }); // Create an ad request. AdRequest adRequest = new AdRequest(); // Start loading the ad in the background. av.loadAd(adRequest);
@Override public void write(final OutputStream output) throws IOException, WebApplicationException { try { final JsonGenerator generator = mapper.getFactory().createGenerator(output); generator.configure(JsonGenerator.Feature.AUTO_CLOSE_TARGET, false); generator.writeStartObject(); while (iterator.hasNext()) { final Tag tag = iterator.next(); final UUID accountId = tag.getObjectId(); try { invoiceUserApi.triggerInvoiceGeneration(accountId, clock.getUTCToday(), callContext); generator.writeStringField(accountId.toString(), OK); } catch (final InvoiceApiException e) { if (e.getCode() != ErrorCode.INVOICE_NOTHING_TO_DO.getCode()) { log.warn("Unable to trigger invoice generation for accountId='{}'", accountId); } generator.writeStringField(accountId.toString(), ErrorCode.fromCode(e.getCode()).toString()); } } generator.writeEndObject(); generator.close(); } finally { // In case the client goes away (IOException), make sure to close the underlying DB connection tags.close(); } } };