Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- MobileAds.initialize(getContext(),
- "ca-app-pub-3940256099942544~3347511713");
- mInterstitialAd = new InterstitialAd(getContext());
- mInterstitialAd.setAdUnitId("ca-app-pub-3940256099942544/1033173712");
- mInterstitialAd.loadAd(new AdRequest.Builder().build());
- mInterstitialAd.setAdListener(new AdListener() {
- @Override
- public void onAdLoaded() {
- // Code to be executed when an ad finishes loading.
- Toast.makeText(getContext(), "onAdLoaded Add", Toast.LENGTH_SHORT).show();
- if (mInterstitialAd.isLoaded()) {
- mInterstitialAd.show();
- }
- }
- @Override
- public void onAdFailedToLoad(int errorCode) {
- // Code to be executed when an ad request fails.
- }
- @Override
- public void onAdOpened() {
- // Code to be executed when the ad is displayed.
- }
- @Override
- public void onAdLeftApplication() {
- // Code to be executed when the user has left the app.
- }
- @Override
- public void onAdClosed() {
- // Code to be executed when when the interstitial ad is closed.
- }
- });
Add Comment
Please, Sign In to add comment