当前位置: 首页>>代码示例>>Java>>正文


Java PublisherInterstitialAd.setAdListener方法代码示例

本文整理汇总了Java中com.google.android.gms.ads.doubleclick.PublisherInterstitialAd.setAdListener方法的典型用法代码示例。如果您正苦于以下问题:Java PublisherInterstitialAd.setAdListener方法的具体用法?Java PublisherInterstitialAd.setAdListener怎么用?Java PublisherInterstitialAd.setAdListener使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.google.android.gms.ads.doubleclick.PublisherInterstitialAd的用法示例。


在下文中一共展示了PublisherInterstitialAd.setAdListener方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: onCreateView

import com.google.android.gms.ads.doubleclick.PublisherInterstitialAd; //导入方法依赖的package包/类
@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;
}
 
开发者ID:prebid,项目名称:prebid-mobile-android,代码行数:40,代码来源:DFPInterstitialFragment.java

示例2: getPopup

import com.google.android.gms.ads.doubleclick.PublisherInterstitialAd; //导入方法依赖的package包/类
private void getPopup(String adCode){
    final PublisherInterstitialAd interstitialAd = new PublisherInterstitialAd(getActivity());
    interstitialAd.setAdUnitId(adCode);
    interstitialAd.setAdListener(new AdListener() {
        @Override
        public void onAdClosed() {
        }

        @Override
        public void onAdLoaded() {
            interstitialAd.show();
        }

        @Override
        public void onAdFailedToLoad(int errorCode) {
        }

        @Override
        public void onAdLeftApplication() {
            super.onAdLeftApplication();
        }

        @Override
        public void onAdOpened() {
            super.onAdOpened();
        }
    });
    PublisherAdRequest adRequest = new PublisherAdRequest.Builder().build();
    interstitialAd.loadAd(adRequest);
}
 
开发者ID:hotmobmobile,项目名称:hotmob-android-sdk,代码行数:31,代码来源:MediationPopupFragment.java

示例3: onCreate

import com.google.android.gms.ads.doubleclick.PublisherInterstitialAd; //导入方法依赖的package包/类
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_my);

    // Create the InterstitialAd and set the adUnitId.
    mInterstitialAd = new PublisherInterstitialAd(this);
    // Defined in res/values/strings.xml
    mInterstitialAd.setAdUnitId(getString(R.string.ad_unit_id));

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

        @Override
        public void onAdLoaded() {
            mAdIsLoading = false;
        }

        @Override
        public void onAdFailedToLoad(int errorCode) {
            mAdIsLoading = false;
        }
    });

    // Create the "retry" button, which tries to show an interstitial between game plays.
    mRetryButton = findViewById(R.id.retry_button);
    mRetryButton.setVisibility(View.INVISIBLE);
    mRetryButton.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            showInterstitial();
        }
    });

    startGame();
}
 
开发者ID:googlesamples,项目名称:android-ads,代码行数:40,代码来源:MyActivity.java

示例4: requestAd

import com.google.android.gms.ads.doubleclick.PublisherInterstitialAd; //导入方法依赖的package包/类
@Override
public void requestAd(MediatedInterstitialAdViewController mIC, Activity activity,
                      String parameter, String adUnitId, TargetingParameters targetingParameters) {
    adListener = new GooglePlayAdListener(mIC, super.getClass().getSimpleName());
    adListener.printToClog(String.format(" - requesting an ad: [%s, %s]", parameter, adUnitId));

    interstitialAd = new PublisherInterstitialAd(activity);
    interstitialAd.setAdUnitId(adUnitId);
    interstitialAd.setAdListener(adListener);

    interstitialAd.loadAd(buildRequest(targetingParameters));
}
 
开发者ID:appnexus,项目名称:mobile-sdk-android,代码行数:13,代码来源:GooglePlayDFPInterstitial.java


注:本文中的com.google.android.gms.ads.doubleclick.PublisherInterstitialAd.setAdListener方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。