• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Java AdLoader类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



AdLoader类属于com.google.android.gms.ads包,在下文中一共展示了AdLoader类的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: fetchAd

import com.google.android.gms.ads.AdLoader; //导入依赖的package包/类
@Override
public void fetchAd() {
    new AdLoader.Builder(this.getContext(), this.adUnitId)
        .forAppInstallAd(AdMobNativeAd.this)
        .forContentAd(AdMobNativeAd.this)
        .withNativeAdOptions(this.getNativeAdOptionsBuilder().build())
        .withAdListener(new AdListener() {
            @Override
            public void onAdOpened() {
                AdMobNativeAd.this.notifyAdClicked();
            }

            @Override
            public void onAdFailedToLoad(final int errorCode) {
                AdMobNativeAd.this.onAdFailedToLoad(errorCode);
            }
        })
        .build()
        .loadAd(this.getAdRequestBuilder().build());
}
 
开发者ID:ayltai,项目名称:mopub-nativead-adapters,代码行数:21,代码来源:AdMobNativeAd.java


示例2: request

import com.google.android.gms.ads.AdLoader; //导入依赖的package包/类
@Override
protected void request(Context context, Map<String, String> networkData) {
    if (context == null || networkData == null) {
        invokeLoadFail(PNException.ADAPTER_ILLEGAL_ARGUMENTS);
    } else {
        String unitId = networkData.get(AdMob.KEY_UNIT_ID);
        if (TextUtils.isEmpty(unitId)) {
            invokeLoadFail(PNException.ADAPTER_MISSING_DATA);
        } else {

            mAdView = null;
            mWrapper = new AdMobNativeAppInstallAdModel(context, this);
            AdLoader adLoader = new AdLoader.Builder(context, unitId)
                    .forAppInstallAd(mWrapper)
                    .withAdListener(mWrapper.getAdListener())
                    .withNativeAdOptions(AdMob.getNativeAdOptions())
                    .build();
            adLoader.loadAd(AdMob.getAdRequest(context));
        }
    }
}
 
开发者ID:pubnative,项目名称:pubnative-android-sdk,代码行数:22,代码来源:AdMobNetworkAdapter.java


示例3: request

import com.google.android.gms.ads.AdLoader; //导入依赖的package包/类
@Override
protected void request(Context context, Map<String, String> networkData) {
    if (context == null || networkData == null) {
        invokeLoadFail(PNException.ADAPTER_ILLEGAL_ARGUMENTS);
    } else {
        String unitId = networkData.get(AdMob.KEY_UNIT_ID);
        if (TextUtils.isEmpty(unitId)) {
            invokeLoadFail(PNException.ADAPTER_MISSING_DATA);
        } else {

            mAdView = null;
            mWrapper = new AdMobNativeAppInstallAdModel(context, this);
            AdLoader adLoader = new AdLoader.Builder(context, unitId).forAppInstallAd(mWrapper)
                                                                     .withAdListener(mWrapper.getAdListener())
                                                                     .withNativeAdOptions(AdMob.getNativeAdOptions())
                                                                     .build();
            adLoader.loadAd(AdMob.getAdRequest(context));
        }
    }
}
 
开发者ID:pubnative,项目名称:pubnative-android-sdk,代码行数:21,代码来源:AdMobNetworkAdapter.java


示例4: requestNativeAd

import com.google.android.gms.ads.AdLoader; //导入依赖的package包/类
/**
 * AppNexus SDk calls this method to request a native ad from AdMob
 *
 * @param context The context from which this class is instantiated.
 * @param uid     AdMob ad unit id, app developer needs to set up account with AdMob.
 * @param mBC     The controller that passes callbacks to AppNexus SDK
 * @param tp      Targeting parameters that were set in AppNexus API.
 */
@Override
public void requestNativeAd(Context context, String uid, MediatedNativeAdController mBC, TargetingParameters tp) {
    if (mBC != null) {
        if (AdMobNativeSettings.enableAppInstallAd || AdMobNativeSettings.enableContentAd) {
            AdMobNativeListener adMobNativeListener = new AdMobNativeListener(mBC);
            AdLoader.Builder builder = new AdLoader.Builder(context, uid).withAdListener(adMobNativeListener)
                    .withNativeAdOptions(new NativeAdOptions.Builder().setReturnUrlsForImageAssets(true).build());
            if (AdMobNativeSettings.enableAppInstallAd) {
                builder.forAppInstallAd(adMobNativeListener);
            }
            if (AdMobNativeSettings.enableContentAd) {
                builder.forContentAd(adMobNativeListener);
            }
            builder.build().loadAd(GooglePlayServicesBanner.buildRequest(tp));
        } else {
            Clog.w(Clog.mediationLogTag, "Unable to get AdMob Native ad since both AdMobNativeSettings.setEnableContentAd() and AdMobNativeSettings.setEnableAppInstallAd() were not called.");
            mBC.onAdFailed(ResultCode.MEDIATED_SDK_UNAVAILABLE);
        }
    }


}
 
开发者ID:appnexus,项目名称:mobile-sdk-android,代码行数:31,代码来源:AdMobNativeAd.java


示例5: createRequest

import com.google.android.gms.ads.AdLoader; //导入依赖的package包/类
protected void createRequest(Context context, String unitId) {
    mWrapper = new AdMobNativeAppInstallAdModel(context, this);
    AdLoader adLoader = new AdLoader.Builder(context, unitId).forAppInstallAd(mWrapper)
                                                             .withAdListener(mWrapper.getAdListener())
                                                             .withNativeAdOptions(AdMob.getNativeAdOptions())
                                                             .build();
    adLoader.loadAd(AdMob.getAdRequest(context));
}
 
开发者ID:pubnative,项目名称:pubnative-android-sdk,代码行数:9,代码来源:AdMobNetworkAdapter.java


示例6: setupAds

import com.google.android.gms.ads.AdLoader; //导入依赖的package包/类
/**
 * Subscribing to the native ads events
 */
protected synchronized void setupAds() {
    String unitId = getReleaseUnitId() != null ? getReleaseUnitId() : getDefaultUnitId();
    AdLoader.Builder adloaderBuilder = new AdLoader.Builder(mContext.get(), unitId)
            .withAdListener(new AdListener() {
                @Override
                public void onAdFailedToLoad(int errorCode) {
                    // Handle the failure by logging, altering the UI, etc.
                    Log.i(TAG, "onAdFailedToLoad " + errorCode);
                    lockFetch.set(false);
                    mFetchFailCount++;
                    mFetchingAdsCnt--;
                    ensurePrefetchAmount();
                    onAdFailed( mPrefetchedAdList.size(), errorCode, null);
                }
            })
            .withNativeAdOptions(new NativeAdOptions.Builder()
                    // Methods in the NativeAdOptions.Builder class can be
                    // used here to specify individual options settings.
                    .build());
    if(getAdTypeToFetch().contains(EAdType.ADVANCED_INSTALLAPP))
        adloaderBuilder.forAppInstallAd(new NativeAppInstallAd.OnAppInstallAdLoadedListener() {
                @Override
                public void onAppInstallAdLoaded(NativeAppInstallAd appInstallAd) {
                    onAdFetched(appInstallAd);
                }
            });
    if(getAdTypeToFetch().contains(EAdType.ADVANCED_CONTENT))
        adloaderBuilder.forContentAd(new NativeContentAd.OnContentAdLoadedListener() {
                @Override
                public void onContentAdLoaded(NativeContentAd contentAd) {
                    onAdFetched(contentAd);
                }
            });

    adLoader = adloaderBuilder.build();
}
 
开发者ID:clockbyte,项目名称:admobadapter,代码行数:40,代码来源:AdmobFetcher.java


示例7: loadAd

import com.google.android.gms.ads.AdLoader; //导入依赖的package包/类
/**
 * Loads a {@link NativeContentAd} and calls {@link ContentAdViewHolder} methods to
 * display its assets or handle failure by hiding the view.
 */
public void loadAd(Context context, ContentAdViewHolder viewHolder) {
    synchronized (mSyncObject) {
        mViewHolder = viewHolder;

        if ((mAdLoader != null) && mAdLoader.isLoading()) {
            Log.d(MainActivity.LOG_TAG, "ContentAdFetcher is already loading an ad.");
            return;
        }

        // If an ad previously loaded, reuse it instead of requesting a new one.
        if (mContentAd != null) {
            mViewHolder.populateView(mContentAd);
            return;
        }

        NativeContentAd.OnContentAdLoadedListener contentAdListener =
                new NativeContentAd.OnContentAdLoadedListener() {
                    public void onContentAdLoaded(NativeContentAd ad) {
                        mContentAd = ad;
                        mViewHolder.populateView(mContentAd);
                    }
                };

        if (mAdLoader == null) {
            mAdLoader = new AdLoader.Builder(context, mAdUnitId)
                    .forContentAd(contentAdListener)
                    .withAdListener(new AdListener() {
                        @Override
                        public void onAdFailedToLoad(int errorCode) {
                            mViewHolder.hideView();
                            Log.e(MainActivity.LOG_TAG,
                                    "Content Ad Failed to load: " + errorCode);
                        }
                    }).build();
        }

        mAdLoader.loadAd(new PublisherAdRequest.Builder().build());
    }
}
 
开发者ID:googlesamples,项目名称:android-ads,代码行数:44,代码来源:ContentAdFetcher.java


示例8: loadAd

import com.google.android.gms.ads.AdLoader; //导入依赖的package包/类
/**
 * Loads a {@link NativeAppInstallAd} and calls {@link AppInstallAdViewHolder} methods to
 * display its assets or handle failure by hiding the view.
 */
public void loadAd(Context context,
                   AppInstallAdViewHolder viewHolder) {
    synchronized (mSyncObject) {
        mViewHolder = viewHolder;

        if ((mAdLoader != null) && mAdLoader.isLoading()) {
            Log.d(MainActivity.LOG_TAG, "AppInstallAdFetcher is already loading an ad.");
            return;
        }

        // If an ad previously loaded, reuse it instead of requesting a new one.
        if (mAppInstallAd != null) {
            mViewHolder.populateView(mAppInstallAd);
            return;
        }

        NativeAppInstallAd.OnAppInstallAdLoadedListener appInstallAdListener =
                new NativeAppInstallAd.OnAppInstallAdLoadedListener() {
                    public void onAppInstallAdLoaded(NativeAppInstallAd ad) {
                        mAppInstallAd = ad;
                        mViewHolder.populateView(mAppInstallAd);
                    }
                };

        if (mAdLoader == null) {
            mAdLoader = new AdLoader.Builder(context, mAdUnitId)
                    .forAppInstallAd(appInstallAdListener)
                    .withAdListener(new AdListener() {
                        @Override
                        public void onAdFailedToLoad(int errorCode) {
                            mViewHolder.hideView();
                            Log.e(MainActivity.LOG_TAG,
                                    "App Install Ad Failed to load: " + errorCode);
                        }
                    }).build();
        }

        mAdLoader.loadAd(new PublisherAdRequest.Builder().build());
    }
}
 
开发者ID:googlesamples,项目名称:android-ads,代码行数:45,代码来源:AppInstallAdFetcher.java



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java UnmodifiableIterator类代码示例发布时间:2022-05-22
下一篇:
Java CapacitySchedulerInfo类代码示例发布时间:2022-05-22
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap