Guest User

Untitled

a guest
Jun 19th, 2018
69
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.30 KB | None | 0 0
  1. MobileAds.initialize(getContext(),
  2. "ca-app-pub-3940256099942544~3347511713");
  3.  
  4. mInterstitialAd = new InterstitialAd(getContext());
  5. mInterstitialAd.setAdUnitId("ca-app-pub-3940256099942544/1033173712");
  6. mInterstitialAd.loadAd(new AdRequest.Builder().build());
  7.  
  8.  
  9. mInterstitialAd.setAdListener(new AdListener() {
  10. @Override
  11. public void onAdLoaded() {
  12. // Code to be executed when an ad finishes loading.
  13. Toast.makeText(getContext(), "onAdLoaded Add", Toast.LENGTH_SHORT).show();
  14. if (mInterstitialAd.isLoaded()) {
  15. mInterstitialAd.show();
  16. }
  17. }
  18.  
  19. @Override
  20. public void onAdFailedToLoad(int errorCode) {
  21. // Code to be executed when an ad request fails.
  22.  
  23. }
  24.  
  25. @Override
  26. public void onAdOpened() {
  27. // Code to be executed when the ad is displayed.
  28.  
  29. }
  30.  
  31. @Override
  32. public void onAdLeftApplication() {
  33. // Code to be executed when the user has left the app.
  34.  
  35. }
  36.  
  37. @Override
  38. public void onAdClosed() {
  39. // Code to be executed when when the interstitial ad is closed.
  40.  
  41. }
  42. });
Add Comment
Please, Sign In to add comment