Java 类com.google.android.gms.ads.AdListener 实例源码

项目:SnakeWear    文件:Game.java   
private void gotoMenu(Context context) {
    timer.cancel();

    // Save highscore
    SharedPreferences prefs = context.getSharedPreferences(MainActivity.class.getSimpleName(), MODE_PRIVATE);
    int highscore = Math.max(prefs.getInt("highscore", 0), game.getScore());
    SharedPreferences.Editor edit = prefs.edit();
    edit.putInt("highscore", highscore);
    edit.apply();

    Intent goBack = new Intent(context, MainActivity.class);
    goBack.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);

    if (random.nextBoolean()) {
        bigAd.setAdListener(new AdListener() {
            @Override
            public void onAdClosed() {
                context.startActivity(goBack);
            }
        });
        bigAd.show();
    } else {
        context.startActivity(goBack);
    }
}
项目:justintrain-client-android    文件:Ads.java   
public static void initializeAds(Context context, View bannerPlaceholder, NativeExpressAdView adView, AnalyticsHelper analyticsHelper, String screenName) {
    initializeAds(context, adView);

    adView.setAdListener(new AdListener() {
        @Override
        public void onAdLoaded() {
            apply(bannerPlaceholder, GONE);
            apply(adView, VISIBLE);
        }

        @Override
        public void onAdFailedToLoad(int i) {
            analyticsHelper.logScreenEvent(screenName, AD_FAILED_TO_LOAD);
        }

        @Override
        public void onAdClicked() {
            analyticsHelper.logScreenEvent(screenName, AD_CLICKED);
        }
    });
}
项目:justintrain-client-android    文件:Ads.java   
public static void initializeAds(Context context, View bannerPlaceholder, AdView adView, AnalyticsHelper analyticsHelper, String screenName) {
    initializeAds(context, adView);

    adView.setAdListener(new AdListener() {
        @Override
        public void onAdLoaded() {
            apply(bannerPlaceholder, GONE);
            apply(adView, VISIBLE);
        }

        @Override
        public void onAdFailedToLoad(int i) {
            analyticsHelper.logScreenEvent(screenName, AD_FAILED_TO_LOAD);
        }

        @Override
        public void onAdClicked() {
            analyticsHelper.logScreenEvent(screenName, AD_CLICKED);
        }
    });
}
项目:text_converter    文件:AdsManager.java   
public static void showFullScreenAdsIfRequired(final StateActivity activity) {
    if (Premium.isPremiumUser(activity)) return;
    final InterstitialAd interstitialAd = new InterstitialAd(activity.getApplicationContext());
    interstitialAd.setAdUnitId(AdConstants.AdUnitId.AD_UNIT_ID_INTERSTITIAL);
    AdRequest.Builder request = new AdRequest.Builder();
    if (BuildConfig.DEBUG) {
        request.addTestDevice(TEST_DEVICE_ID);
    }
    interstitialAd.loadAd(request.build());
    interstitialAd.setAdListener(new AdListener() {
        @Override
        public void onAdLoaded() {
            super.onAdLoaded();
            if (!activity.isFinishing() && activity.isActivityVisible()) {
                interstitialAd.show();
            }
        }
    });
}
项目:ascii_generate    文件:MainActivity.java   
@Override
public void onBackPressed() {
    if (BuildConfig.IS_PREMIUM_USER) {
        super.onBackPressed();
        return;
    }
    if (interstitialAd != null) {
        if (interstitialAd.isLoaded()) {
            interstitialAd.show();
            interstitialAd.setAdListener(new AdListener() {
                @Override
                public void onAdClosed() {
                    super.onAdClosed();
                    finish();
                }
            });
        } else {
            super.onBackPressed();
        }
    }
}
项目:True-Weather    文件:AdBhai.java   
private InterstitialAd createNewIntAd() {
    InterstitialAd intAd = new InterstitialAd(context);
    intAd.setAdUnitId(context.getString(R.string.tip_click_int_ad_id));
    intAd.setAdListener(new AdListener() {
        @Override
        public void onAdLoaded() {

        }

        @Override
        public void onAdFailedToLoad(int errorCode) {

        }

        @Override
        public void onAdClosed() {
            // Proceed to the next level.
            //levelTwo();
        }
    });
    return intAd;
}
项目:Ad-Mob    文件:SecondActivity.java   
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_second);
    mInterstitialAd = new InterstitialAd(this);

    // set the ad unit ID
    mInterstitialAd.setAdUnitId(getString(R.string.interstitial_full_screen));

    AdRequest adRequest = new AdRequest.Builder()
            .addTestDevice("DCAB007CDB3101E631F092966F546CC2")
            .build();

    // Load ads into Interstitial Ads
    mInterstitialAd.loadAd(adRequest);

    mInterstitialAd.setAdListener(new AdListener() {
        public void onAdLoaded() {
            showInterstitial();
        }
    });
}
项目:Build-it-Bigger    文件:MainFragment.java   
private void setUpAds() {
    AdRequest adRequest = new AdRequest.Builder().build();
    adView.loadAd(adRequest);
    interstitialAd = new InterstitialAd(getContext());
    interstitialAd.setAdUnitId(interstitialAdUnitId);
    interstitialAd.setAdListener(new AdListener() {
        @Override
        public void onAdFailedToLoad(int i) {
            super.onAdFailedToLoad(i);
            requestNewInterstitial();
        }

        @Override
        public void onAdClosed() {
            super.onAdClosed();
            requestNewInterstitial();
        }

        @Override
        public void onAdOpened() {
            super.onAdOpened();
            requestNewInterstitial();
        }
    });
    requestNewInterstitial();
}
项目:quickstart-android    文件:AdViewIdlingResource.java   
public AdViewIdlingResource(AdView adView) {
    if (adView == null) {
        throw new IllegalArgumentException(
                "Can't initialize AdViewIdlingResource with null AdView.");
    }

    this.mAdView = adView;
    this.mAdListener = new AdListener() {
        @Override
        public void onAdFailedToLoad(int i) {
            transitionToIdle();
        }

        @Override
        public void onAdLoaded() {
            transitionToIdle();
        }
    };

    mAdView.setAdListener(mAdListener);
}
项目:mopub-nativead-adapters    文件:AdMobNativeAd.java   
@Override
public void fetchAd() {
    new AdLoader.Builder(this.getContext(), this.adUnitId)
        .forAppInstallAd(AdMobNativeAd.this)
        .forContentAd(AdMobNativeAd.this)
        .withNativeAdOptions(this.getNativeAdOptionsBuilder().build())
        .withAdListener(new AdListener() {
            @Override
            public void onAdOpened() {
                AdMobNativeAd.this.notifyAdClicked();
            }

            @Override
            public void onAdFailedToLoad(final int errorCode) {
                AdMobNativeAd.this.onAdFailedToLoad(errorCode);
            }
        })
        .build()
        .loadAd(this.getAdRequestBuilder().build());
}
项目:BusyBox    文件:MainActivity.java   
private void setupTabInterstitialsAd() {
    String[] ids = getResources().getStringArray(R.array.tabs_interstitials_id);

    for (int i = 0; i < interstitialsTabAd.length; i++) {
        if (!interstitialIsReady(interstitialsTabAd[i])) {
            final int finalI = i;

            AdListener adListener = new AdListener() {
                @Override public void onAdClosed() {
                    super.onAdClosed();
                    interstitialsTabAd[finalI] = null;
                    setupTabInterstitialsAd();
                }
            };

            interstitialsTabAd[i] = newInterstitialAd(ids[i], adListener);
        }
    }
}
项目:BusyBox    文件:MainActivity.java   
private void setupSettingsInterstitialsAd() {
    String[] ids = getResources().getStringArray(R.array.settings_interstitials_id);

    for (int i = 0; i < interstitialsSettingsAd.length; i++) {
        if (!interstitialIsReady(interstitialsSettingsAd[i])) {
            final int finalI = i;

            AdListener adListener = new AdListener() {
                @Override public void onAdClosed() {
                    super.onAdClosed();
                    interstitialsSettingsAd[finalI] = null;
                    setupSettingsInterstitialsAd();
                    startActivity(new Intent(MainActivity.this, SettingsActivity.class));
                }
            };

            interstitialsSettingsAd[i] = newInterstitialAd(ids[i], adListener);
        }
    }
}
项目:BusyBox    文件:MainActivity.java   
private void setupInstallInterstitialsAd() {
    String[] ids = getResources().getStringArray(R.array.install_interstitials_id);

    for (int i = 0; i < interstitialsInstallAd.length; i++) {
        if (!interstitialIsReady(interstitialsInstallAd[i])) {
            final int finalI = i;

            AdListener adListener = new AdListener() {
                @Override public void onAdClosed() {
                    super.onAdClosed();
                    interstitialsInstallAd[finalI] = null;
                    setupInstallInterstitialsAd();
                }
            };

            interstitialsInstallAd[i] = newInterstitialAd(ids[i], adListener);
        }
    }
}
项目:BusyBox    文件:MainActivity.java   
private void setupTabInterstitialsAd() {
    String[] ids = getResources().getStringArray(R.array.tabs_interstitials_id);

    for (int i = 0; i < interstitialsTabAd.length; i++) {
        if (!interstitialIsReady(interstitialsTabAd[i])) {
            final int finalI = i;

            AdListener adListener = new AdListener() {
                @Override public void onAdClosed() {
                    super.onAdClosed();
                    interstitialsTabAd[finalI] = null;
                    setupTabInterstitialsAd();
                }
            };

            interstitialsTabAd[i] = newInterstitialAd(ids[i], adListener);
        }
    }
}
项目:BusyBox    文件:MainActivity.java   
private void setupSettingsInterstitialsAd() {
    String[] ids = getResources().getStringArray(R.array.settings_interstitials_id);

    for (int i = 0; i < interstitialsSettingsAd.length; i++) {
        if (!interstitialIsReady(interstitialsSettingsAd[i])) {
            final int finalI = i;

            AdListener adListener = new AdListener() {
                @Override public void onAdClosed() {
                    super.onAdClosed();
                    interstitialsSettingsAd[finalI] = null;
                    setupSettingsInterstitialsAd();
                    startActivity(new Intent(MainActivity.this, SettingsActivity.class));
                }
            };

            interstitialsSettingsAd[i] = newInterstitialAd(ids[i], adListener);
        }
    }
}
项目:BusyBox    文件:MainActivity.java   
private void setupInstallInterstitialsAd() {
    String[] ids = getResources().getStringArray(R.array.install_interstitials_id);

    for (int i = 0; i < interstitialsInstallAd.length; i++) {
        if (!interstitialIsReady(interstitialsInstallAd[i])) {
            final int finalI = i;

            AdListener adListener = new AdListener() {
                @Override public void onAdClosed() {
                    super.onAdClosed();
                    interstitialsInstallAd[finalI] = null;
                    setupInstallInterstitialsAd();
                }
            };

            interstitialsInstallAd[i] = newInterstitialAd(ids[i], adListener);
        }
    }
}
项目:USB_Mass_Storage_Enabler    文件:MainActivity.java   
void initADs() {

        if(enableADs) {
            //https://firebase.google.com/docs/admob/android/quick-start
            MobileAds.initialize(getApplicationContext(), getString(R.string.ad_app_id));
            AdView mAdView = (AdView) findViewById(R.id.adView);
            AdRequest adRequest = new AdRequest.Builder().build();
            mAdView.loadAd(adRequest);
            Log.d(LOG_TAG, "Ads initialized..");

            mInterstitialAd = new InterstitialAd(this);
            mInterstitialAd.setAdUnitId(getString(R.string.interstitial_ad_unit_id));
            mInterstitialAd.setAdListener(new AdListener() {
                @Override
                public void onAdClosed() {
                    //requestNewInterstitial();
                }
            });

            requestNewInterstitial();
        }
    }
项目:MoonlightNote    文件:UserFragment.java   
@Override
public void onActivityCreated(@Nullable Bundle savedInstanceState) {
    super.onActivityCreated(savedInstanceState);
    if (!SPUtils.getBoolean(mActivity, "User", "google", false)) {
        mCircleImageView.setOnClickListener(this);
        mNickname.setOnClickListener(this);
        setHasOptionsMenu(true);
    }

    mAdView.setAdListener(new AdListener() {
        @Override
        public void onAdLoaded() {
            super.onAdLoaded();
            CircularRevealUtils.show(mAdView);
        }
    });
}
项目:BuildItBigger    文件:MainActivityFragment.java   
@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    mInterstitialAd = new InterstitialAd(getActivity());
    mInterstitialAd.setAdUnitId("ca-app-pub-3940256099942544/1033173712");

    mInterstitialAd.setAdListener(new AdListener() {
        @Override
        public void onAdClosed() {
            requestNewInterstitial();
            openJokeActivity();
        }
    });

    requestNewInterstitial();
}
项目:Teleport-Ball    文件:AndroidLauncher.java   
@Override
public void showInterstitialAd(final Runnable then) {
    runOnUiThread(new Runnable() {
        @Override
        public void run() {
            if (then != null) {
                interstitialAd.setAdListener(new AdListener() {
                    @Override
                    public void onAdClosed() {
                        Gdx.app.postRunnable(then);
                        AdRequest.Builder builder = new AdRequest.Builder();
                        AdRequest ad = builder.build();
                        interstitialAd.loadAd(ad);
                    }
                });
            }
            interstitialAd.show();
        }
    });
}
项目:Fruit-Destroyer    文件:AndroidLauncher.java   
@Override
public void showGoogleAd() {
    runOnUiThread(new Runnable()
    {
        @Override
        public void run()
        {

            interstitialAd.setAdListener(new AdListener()
            {
                @Override
                public void onAdClosed()
                {
                    AdRequest.Builder builder = new AdRequest.Builder();
                    AdRequest ad = builder.build();
                    interstitialAd.loadAd(ad);
                }
            });
            interstitialAd.show();
        }
    });
}
项目:show-java    文件:BaseActivity.java   
private void setupGoogleAds() {
    mAdView = (AdView) findViewById(R.id.adView);
    if (mAdView != null) {
        mAdView.setVisibility(View.GONE);
        if (!isPro()) {
            AdRequest adRequest = new AdRequest.Builder().addTestDevice(AdRequest.DEVICE_ID_EMULATOR).build();
            mAdView.setAdListener(new AdListener() {
                @Override
                public void onAdFailedToLoad(int errorCode) {
                    super.onAdFailedToLoad(errorCode);
                    mAdView.setVisibility(View.GONE);
                }

                @Override
                public void onAdLoaded() {
                    super.onAdLoaded();
                    mAdView.setVisibility(View.VISIBLE);
                }
            });
            mAdView.loadAd(adRequest);
            if (!checkDataConnection()) {
                mAdView.setVisibility(View.GONE);
            }
        }
    }
}
项目:hack.chat-android    文件:HackChatInterstitialAd.java   
/**
 * Sets up the interstitial ad object.
 */
private void setUpInterstitialAd() throws Exception {
    if (!(advertable instanceof  Activity)) {
        throw new Exception("Only Activity class can implement HackChatInterstitialAdvertable.");
    }
    interstitialAd = new InterstitialAd((Activity) advertable);
    interstitialAd.setAdUnitId(adUnitId);

    interstitialAd.setAdListener(new AdListener() {
        @Override
        public void onAdClosed() {
            advertable.onInterstitialAdClosed();
        }
    });

    requestInterstitialAd();
}
项目:SignatureMaker    文件:MainActivity.java   
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    prefs = PreferenceManager.getDefaultSharedPreferences(this);
    load();
    a = (RelativeLayout) findViewById(R.id.lay);
    mAdView = (AdView) findViewById(R.id.adView);
    mAdView.setVisibility(View.GONE);
    AdRequest adRequest = new AdRequest.Builder().build();
    mAdView.loadAd(adRequest);
    mAdView.setAdListener(new AdListener() {
        @Override
        public void onAdLoaded() {
            mAdView.setVisibility(View.VISIBLE);
        }
    });

}
项目:marsTemp    文件:MainActivity.java   
/**
 * Ads for the app.
 */
private void initAdmob() {
    int curTime = App.Instance.getAdsShownTimes();
    int adsTimes = 7;
    if (curTime % adsTimes == 0) {
        // Create an ad.
        mInterstitialAd = new InterstitialAd(this);
        mInterstitialAd.setAdUnitId(getString(R.string.interstitial_ad_unit_id));
        // Create ad request.
        AdRequest adRequest = new AdRequest.Builder().build();
        // Begin loading your interstitial.
        mInterstitialAd.setAdListener(new AdListener() {
            @Override
            public void onAdLoaded() {
                super.onAdLoaded();
                displayInterstitial();
            }
        });
        mInterstitialAd.loadAd(adRequest);
    }
    curTime++;
    App.Instance.setAdsShownTimes(curTime);
}
项目:admobadapter    文件:AdmobFetcherExpress.java   
/**
 * Subscribing to the native ads events
 * @param adView
 */
protected synchronized void setupAd(final NativeExpressAdView adView) {
    if(mFetchFailCount > MAX_FETCH_ATTEMPT)
        return;

    if(!mPrefetchedAds.contains(adView))
        mPrefetchedAds.add(adView);
    adView.setAdListener(new AdListener() {
        @Override
        public void onAdFailedToLoad(int errorCode) {
            super.onAdFailedToLoad(errorCode);
            // Handle the failure by logging, altering the UI, etc.
            onFailedToLoad(adView, errorCode);
        }
        @Override
        public void onAdLoaded() {
            super.onAdLoaded();
            onFetched(adView);
        }
    });
}
项目:GooglePlayServiceLocationSupport    文件:FragmentLocationActivity.java   
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_fragment_location);
    mInterstitialAd = new InterstitialAd(this);
    mInterstitialAd.setAdUnitId(getResources().getString(R.string.interstitial_ad));
    mInterstitialAd.setAdListener(new AdListener() {
        @Override
        public void onAdClosed() {
            finish();
        }
    });
    AdRequest adRequest = new AdRequest.Builder().build();
    mInterstitialAd.loadAd(adRequest);

    Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
    setSupportActionBar(toolbar);
}
项目:Android_ApplicationTemplate    文件:MainActivity.java   
private void handleInterstitialAd() {
    String adId = Preferences.getInstance(this).getAdmobInterstitialId();
    if (adId == null || adId.length() == 0)
        return;

    interstitial = new InterstitialAd(this);
    interstitial.setAdUnitId(adId);
    // Create ad request.
    AdRequest adRequest = new AdRequest.Builder().build();
    // Begin loading your interstitial.
    interstitial.loadAd(adRequest);

    interstitial.setAdListener(new AdListener() {
        public void onAdLoaded() {
            if (interstitial.isLoaded()) {
                interstitial.show();
            }
        }
    });

}
项目:2048-Battles    文件:AdFragmentGame.java   
@Override
public void onActivityCreated(Bundle bundle) {
    super.onActivityCreated(bundle);

    // Gets the ad view defined in layout/ad_fragment.xml with ad unit ID set in
    // values/strings.xml.
    mAdView = (AdView) getView().findViewById(R.id.adView);

    // The current version of AdMob breaks rotation animations on some devices.
    // Setting the layer type of the ad to Software or Hardware fixes it.
    // https://code.google.com/p/android/issues/detail?id=70914
    mAdView.setLayerType(View.LAYER_TYPE_SOFTWARE, null);

    // Create an ad request.
    AdRequest adRequest = new AdRequest.Builder()
            .addTestDevice(AdRequest.DEVICE_ID_EMULATOR)
            .addTestDevice(getString(R.string.test_device_id))
            .build();

    // Start loading the ad in the background.
    mAdView.loadAd(adRequest);
    mAdView.setAdListener(new AdListener() {
        @Override
        public void onAdFailedToLoad(int errorCode) {
            mAdView.setVisibility(View.GONE);
            super.onAdFailedToLoad(errorCode);
        }
    });
}
项目:YouTubePlayerActivity    文件:AdHelper.java   
public static void popUpAd(Context context) {
    final InterstitialAd interstitialAd = getInstance(context);
    AdRequest adRequest = new AdRequest.Builder()
            .addTestDevice("BE5D7D1E701EF21AB93369A353CAA3ED")
            .addTestDevice("921DF5A672991967B9FFE364D0FF8498")
            .addTestDevice("A642C45F5DD4C0E09AA896DDABD36789")
            .addTestDevice("5270E2092AA1F46AC51964363699AB9E")
            .build();
    interstitialAd.loadAd(adRequest);
    interstitialAd.setAdListener(new AdListener() {
        @Override
        public void onAdLoaded() {
            super.onAdLoaded();
            interstitialAd.show();
        }
    });
}
项目:android-dim-block    文件:Admob.java   
public static void initAd(final Context context) {
    if (isAbmobEnabled()) {
        // Create the interstitial.
        sInterstitialAd = new InterstitialAd(context);
        sInterstitialAd.setAdUnitId(Model.getInstance().getConfiguration().getAdmobId());

        // Create ad request.
        final AdRequest adRequest = new AdRequest.Builder().build();

        // Begin loading your interstitial.
        sInterstitialAd.loadAd(adRequest);

        sInterstitialAd.setAdListener(new AdListener() {
            @Override
            public void onAdLoaded() {
                displayInterstitial();
            }
        });
    }
}
项目:TibetanPersonalityTest    文件:Result.java   
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    requestWindowFeature(Window.FEATURE_NO_TITLE);
    getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
            WindowManager.LayoutParams.FLAG_FULLSCREEN);
    setContentView(R.layout.activity_result);

    sp = PreferenceManager.getDefaultSharedPreferences(this);

    adView = (AdView) findViewById(R.id.avViewr);
    tv1 = (TextView) findViewById(R.id.tv1);
    tv2 = (TextView) findViewById(R.id.tv2);
    tv3 = (TextView) findViewById(R.id.tv3);

    Toolbar toolbar = (Toolbar) findViewById(R.id.app_bar);
    toolbar.setTitle("Result");
    setSupportActionBar(toolbar);

    displayAnswer1();
    displayAnswer2();
    displayAnswer3();

    initAds();

    mInterAd = new InterstitialAd(this);
    mInterAd.setAdUnitId(getResources().getString(R.string.finish_inter_ad_id));
    mInterAd.loadAd(new AdRequest.Builder().build());
    mInterAd.setAdListener(new AdListener() {
        @Override
        public void onAdClosed() {
            super.onAdClosed();
            finish();
        }
    });

}
项目:GodotFireBase    文件:AdMob.java   
public void createInterstitial() {
    if (AdMobConfig == null) { return; }

    String ad_unit_id = AdMobConfig.optString("InterstitialAdId", "");

    if (ad_unit_id.length() <= 0) {
        Utils.d("AdMob:Interstitial:UnitId:NotProvided");
        ad_unit_id = activity.getString(R.string.interstitial_ad_unit_id);
    }

    mInterstitialAd = new InterstitialAd(activity);
    mInterstitialAd.setAdUnitId(ad_unit_id);
    mInterstitialAd.setAdListener(new AdListener() {
        @Override
        public void onAdLoaded() {
            Utils.d("AdMob:Interstitial:OnAdLoaded");
            Utils.callScriptFunc("AdMob", "AdMob_Interstitial", "loaded");
        }

        @Override
        public void onAdFailedToLoad(int errorCode) {
            Utils.w("AdMob:Interstitial:onAdFailedToLoad:" + errorCode);
            Utils.callScriptFunc("AdMob", "AdMob_Interstitial", "load_failed");
        }

        @Override
        public void onAdClosed() {
            Utils.w("AdMob:Interstitial:onAdClosed");
            Utils.callScriptFunc("AdMob", "AdMob_Interstitial", "closed");
            requestNewInterstitial();
        }
    });

    requestNewInterstitial();
}
项目:prebid-mobile-android    文件:DFPInterstitialFragment.java   
@Nullable
@Override
public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
    super.onCreateView(inflater, container, savedInstanceState);
    root = inflater.inflate(R.layout.fragment_interstitial, null);
    // interstitial set up
    mPublisherInterstitialAd = new PublisherInterstitialAd(getContext());
    mPublisherInterstitialAd.setAdUnitId(Constants.DFP_INTERSTITIAL_ADUNIT_ID_FULLSCREEN);
    mPublisherInterstitialAd.setAdListener(new AdListener() {
        @Override
        public void onAdFailedToLoad(int i) {
            super.onAdFailedToLoad(i);
            if (i == AdRequest.ERROR_CODE_INTERNAL_ERROR) {
                LogUtil.e("DFP", "Interstitial Ad failed to load internal error");
            } else if (i == AdRequest.ERROR_CODE_INVALID_REQUEST) {
                LogUtil.e("DFP", "Interstitial Ad failed to load internal error");
            } else if (i == AdRequest.ERROR_CODE_NETWORK_ERROR) {
                LogUtil.e("DFP", "Interstitial Ad failed to load network error");
            } else if (i == AdRequest.ERROR_CODE_NO_FILL) {
                LogUtil.e("DFP", "Interstitial Ad failed to load no fill");
            }
        }

        @Override
        public void onAdLoaded() {
            super.onAdLoaded();
            mPublisherInterstitialAd.show();
        }
    });
    request = new PublisherAdRequest.Builder().build();
    Button btnLoad = (Button) root.findViewById(R.id.loadInterstitial);
    btnLoad.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            loadInterstitial(v);
        }
    });
    return root;
}
项目:editor-sql    文件:FeViewUtils.java   
public static AdListener getAdMobClick(final Button btn_bg) {
    return new AdListener() {
        @Override
        public void onAdLoaded() {
            super.onAdLoaded();
            btn_bg.setVisibility(View.GONE);
        }
    };
}
项目:chat-sdk-android-push-firebase    文件:ChatSDKMainActivity.java   
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    exitHelper = new ExitHelper(this);

    if ((getIntent().getFlags() & Intent.FLAG_ACTIVITY_BROUGHT_TO_FRONT) != 0) {
        // Activity was brought to front and not created,
        // Thus finishing this will get us to the last viewed activity
        finish();
        return;
    }

    setContentView(R.layout.chat_sdk_activity_view_pager);

    firstTimeInApp();
    initViews();

    enableCheckOnlineOnResumed(true);

    if (!fromLoginActivity && savedInstanceState != null)
    {
        pager.setCurrentItem(savedInstanceState.getInt(PAGE_ADAPTER_POS));
    }

    mOpenFromPushChecker = new OpenFromPushChecker();
    if(mOpenFromPushChecker.checkOnCreate(getIntent(), savedInstanceState))
    {
        startChatActivityForID(getIntent().getExtras().getLong(ChatSDKAbstractChatActivity.THREAD_ID));
        return;
    }

    //// Added by zhang for interstitial ADS
    MobileAds.initialize(this, "ca-app-pub-2734020869575782/3654782558");

    mInterstitialAd = new InterstitialAd(this);
    mInterstitialAd.setAdUnitId(getString(R.string.full_ad_unit_id));

    mInterstitialAd.setAdListener(new AdListener() {
        @Override
        public void onAdLoaded(){
            super.onAdLoaded();
            if (mInterstitialAd.isLoaded())
                mInterstitialAd.show();
        }

        @Override
        public void onAdClosed() {

        }
    });

}
项目:ExamesGithub    文件:AboutActivity.java   
private Element getCopyRightsElement() {
    Element copyRightsElement = new Element();
    copyRightsElement.setTitle(getString(R.string.copy_right));
    copyRightsElement.setColor(ContextCompat.getColor(this, R.color.greyish_green));
    copyRightsElement.setGravity(Gravity.CENTER);
    copyRightsElement.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            Toast.makeText(AboutActivity.this, "Alguns Direitos Reservados.", Toast.LENGTH_SHORT).show();

            //SHOW AN AD WHEN THE COPY_RIGHT ELEMENT IS CLICKED:
            mInterstitialAd.setAdListener(new AdListener() {
                @Override
                public void onAdLoaded() {
                    if (mInterstitialAd.isLoaded()) {
                        mInterstitialAd.show();
                    } else {
                        Log.d("adMan", "woah, intersticial ad was not loaded man!");
                    }
                }
            });


        }
    });
    return copyRightsElement;
}
项目:2048-TimeKiller    文件:Game.java   
private void initAds() {
    AdRequest adRequest = new AdRequest.Builder().build();
    adView.loadAd(adRequest);

    //Interstitial Ad
    undoB.setVisibility(View.GONE);
    breakB.setVisibility(View.GONE);
    mInterAd = new InterstitialAd(this);
    mInterAd.setAdUnitId(getResources().getString(R.string.interstitial_button));
    mInterAd.loadAd(new AdRequest.Builder().build());
    mInterAd.setAdListener(new AdListener() {
        @Override
        public void onAdLoaded() {
            super.onAdLoaded();
            undoB.setVisibility(View.VISIBLE);
            breakB.setVisibility(View.VISIBLE);
        }

        @Override
        public void onAdClosed() {
            super.onAdClosed();
            undoB.setVisibility(View.GONE);
            breakB.setVisibility(View.GONE);
            mInterAd.loadAd(new AdRequest.Builder().build());
        }
    });
}
项目:B4A_FirebaseAdMob    文件:AdViewWrapper.java   
/**
 * Initializes the AdView.
 *EventName - Name of Subs that will handle the events.
 *AdUnitId - The Ad unit id received from AdMob.
 *Size - One of the SIZE constants.
 */
public void Initialize2(final BA ba, String EventName, String AdUnitId, Object Size) {
    AdView ad = new AdView(ba.activity);
    ad.setAdSize((com.google.android.gms.ads.AdSize)Size);
    ad.setAdUnitId(AdUnitId);
    setObject(ad);
    super.Initialize(ba, EventName);
    final String eventName = EventName.toLowerCase(BA.cul);
    getObject().setAdListener(new AdListener() {

        @Override
        public void onAdFailedToLoad(int e){
            ba.raiseEvent(getObject(), eventName + "_failedtoreceivead", String.valueOf(e));
        }
        @Override
        public void onAdLoaded() {
            ba.raiseEvent(getObject(), eventName + "_receivead");
        }
        @Override
        public void onAdClosed() {
            ba.raiseEventFromDifferentThread(getObject(), null, 0, eventName + "_adscreendismissed", false, null);
        }
        @Override
        public void onAdLeftApplication() {
            //
        }
        @Override
        public void onAdOpened() {
            ba.raiseEventFromDifferentThread(getObject(), null, 0, eventName + "_presentscreen", false, null);

        }
    });
}
项目:B4A_FirebaseAdMob    文件:AdViewWrapper.java   
/**
 * Initializes the ad view.
 *EventName - Sets the subs that will handle the events.
 *AdUnitId - Ad unit ID of a native ad.
 *Width - Requested ad width.
 *Height - Requested ad height.
 */
public void Initialize(final BA ba, String EventName, String AdUnitId, float Width, float Height) {
    NativeExpressAdView ad = new NativeExpressAdView(ba.activity);
    ad.setAdSize(new AdSize((int)Math.round(Width / Common.Density), (int)Math.round(Height / Common.Density)));
    ad.setAdUnitId(AdUnitId);
    setObject(ad);
    super.Initialize(ba, EventName);
    final String eventName = EventName.toLowerCase(BA.cul);
    getObject().setAdListener(new AdListener() {

        @Override
        public void onAdFailedToLoad(int e){
            ba.raiseEvent(getObject(), eventName + "_failedtoreceivead", String.valueOf(e));
        }
        @Override
        public void onAdLoaded() {
            ba.raiseEvent(getObject(), eventName + "_receivead");
        }
        @Override
        public void onAdClosed() {
            ba.raiseEventFromDifferentThread(getObject(), null, 0, eventName + "_adscreendismissed", false, null);
        }
        @Override
        public void onAdLeftApplication() {
            //
        }
        @Override
        public void onAdOpened() {
            ba.raiseEventFromDifferentThread(getObject(), null, 0, eventName + "_presentscreen", false, null);

        }
    });
}