Search in sources :

Example 1 with AdListener

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;
}
Also used : IBannerAd(com.abewy.android.ads.IBannerAd) Ad(com.google.ads.Ad) SQLiteDiskIOException(android.database.sqlite.SQLiteDiskIOException) ErrorCode(com.google.ads.AdRequest.ErrorCode) AdView(com.google.ads.AdView) AdListener(com.google.ads.AdListener)

Aggregations

SQLiteDiskIOException (android.database.sqlite.SQLiteDiskIOException)1 IBannerAd (com.abewy.android.ads.IBannerAd)1 Ad (com.google.ads.Ad)1 AdListener (com.google.ads.AdListener)1 ErrorCode (com.google.ads.AdRequest.ErrorCode)1 AdView (com.google.ads.AdView)1