Interstitial广告集成说明

插屏(Interstitial)

1. 确定AdHubSDK的主SDK文件已经拷贝到工程文件的libs子目录下参考

2. 添加广告代码,添加广告代码前请确定已初始化SDK

  • 例如:

      InterstitialAd mInterstitialAd = new InterstitialAd(this, false);
      mInterstitialAd.setAdUnitId(adUnitId);       // 设置广告位ID
      mInterstitialAd.setAdListener(new AdListener() {
          @Override
          public void onAdClosed() {
              Log.i("lance", "onAdClosed");
          }
    
          @Override
          public void onAdClicked() {
              super.onAdClicked();
              Log.i("lance", "onAdClicked");
          }
    
          @Override
          public void onAdFailedToLoad(int errorCode) {
              super.onAdFailedToLoad(errorCode);
              Log.i("lance", "onAdFailedToLoad");
          }
    
          @Override
          public void onAdShown() {
              super.onAdShown();
              Log.i("lance", "onAdShown");
          }
    
          @Override
          public void onAdLoaded() {
              super.onAdLoaded();
              Log.i("lance", "onAdLoaded");
              if (mInterstitialAd != null && mInterstitialAd.isLoaded()) {
                  mInterstitialAd.show();
              }
          }
      });
    
      if (!mInterstitialAd.isLoading() && !mInterstitialAd.isLoaded()) {
          AdRequest adRequest = new AdRequest.Builder().build();
          mInterstitialAd.loadAd(adRequest);
      }
    

PS:更多设置请参考Demo中的com.hubcloud.adhubsdkdemo.InterstitialActivity的代码.

results matching ""

    No results matching ""