use of com.google.ads.AdListener in project Klyph by jonathangerbaud.
the class AdmobBanner method createAdView.
@Override
public View createAdView(Activity activity, ViewGroup adContainer, final IBannerCallback callback) {
// Prevent some crashes in some particular cases
try {
WebViewDatabase.getInstance(activity).clearFormData();
} catch (SQLiteDiskIOException e) {
}
final AdView adView = new AdView(activity, AdSize.BANNER, adMobId);
/*float density = KlyphDevice.getDeviceDensity();
int height = Math.round(AdSize.IAB_MRECT.getHeight() * density);
ViewGroup.LayoutParams params = new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, height);
adView.setLayoutParams(params);*/
adView.setAdListener(new AdListener() {
@Override
public void onReceiveAd(Ad arg0) {
callback.onReceiveAd(adView);
}
@Override
public void onPresentScreen(Ad arg0) {
}
@Override
public void onLeaveApplication(Ad arg0) {
}
@Override
public void onFailedToReceiveAd(Ad arg0, ErrorCode errorCode) {
callback.onFailedToReceiveAd(adView, errorCode.name());
}
@Override
public void onDismissScreen(Ad arg0) {
}
});
return adView;
}
Aggregations