This week only. Pastebin PRO Accounts Christmas Special! Don't miss out!Want more features on Pastebin? Sign Up, it's FREE!
Guest

Untitled

By: a guest on Jan 13th, 2013  |  syntax: None  |  size: 2.09 KB  |  views: 35  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. package YOUR_PACKAGE;
  2.  
  3. import android.app.Activity;
  4.  
  5. import com.applovin.adview.AppLovinAdView;
  6. import com.applovin.sdk.AppLovinAd;
  7. import com.applovin.sdk.AppLovinAdClickListener;
  8. import com.applovin.sdk.AppLovinAdLoadListener;
  9. import com.applovin.sdk.AppLovinAdSize;
  10. import com.applovin.sdk.AppLovinSdk;
  11. import com.google.ads.AdSize;
  12. import com.google.ads.mediation.MediationAdRequest;
  13. import com.google.ads.mediation.customevent.CustomEventBanner;
  14. import com.google.ads.mediation.customevent.CustomEventBannerListener;
  15.  
  16. /**
  17.  * This class must be defined and referenced from AdMob's website for AdMob Mediation
  18.  *
  19.  * @author David Anderson
  20.  * @since 4.2
  21.  */
  22. public class AdMobMediationListener implements CustomEventBanner
  23. {
  24.    
  25.     /**
  26.      * This method will be called by AdMob's Mediation through Custom Event mechanism.
  27.      */
  28.     @Override
  29.     public void requestBannerAd(final CustomEventBannerListener listener,
  30.             final Activity activity,
  31.             String label,
  32.             String serverParameter,
  33.             AdSize adSize,
  34.             MediationAdRequest request)
  35.     {
  36.  
  37.         // Create AppLovin Ad View
  38.         final AppLovinSdk sdk = AppLovinSdk.getInstance(activity);
  39.         final AppLovinAdView adView = new AppLovinAdView(sdk, AppLovinAdSize.BANNER, activity);
  40.         adView.setAdClickListener(new AppLovinAdClickListener() {
  41.             @Override
  42.             public void adClicked(AppLovinAd arg0)
  43.             {
  44.                 listener.onClick();
  45.                 listener.onPresentScreen();
  46.                 listener.onLeaveApplication();
  47.             }
  48.         });
  49.  
  50.         // fetch an ad
  51.         sdk.getAdService().loadNextAd(AppLovinAdSize.BANNER, new AppLovinAdLoadListener() {
  52.  
  53.             @Override
  54.             public void failedToReceiveAd(int errorCode)
  55.             {
  56.                 listener.onFailedToReceiveAd();
  57.             }
  58.  
  59.             @Override
  60.             public void adReceived(AppLovinAd ad)
  61.             {
  62.                 adView.renderAd(ad);
  63.                 listener.onReceivedAd(adView);
  64.             }
  65.         });
  66.     }
  67. }
clone this paste RAW Paste Data