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


Java NativeExpressAdView.setAdUnitId方法代码示例

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


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

示例1: AdViewHolder

import com.google.android.gms.ads.NativeExpressAdView; //导入方法依赖的package包/类
public AdViewHolder(View v ) {
    super(v);

    AdRequest request = new AdRequest.Builder()
            .addTestDevice(AdRequest.DEVICE_ID_EMULATOR)
            .build();
    NativeExpressAdView adView = new NativeExpressAdView(v.getContext());
    adView.setAdSize(new AdSize(AdSize.FULL_WIDTH, 80));

    // Load ad type based on theme - dark or light
    if (PreferenceManager.getDefaultSharedPreferences(v.getContext())
            .getBoolean(PREF_DARK_THEME, false)) {
        adView.setAdUnitId(DARK_AD_ID);
    } else {
        adView.setAdUnitId(LIGHT_AD_ID);
    }
    ((LinearLayout) v).addView(adView, 1);
    adView.loadAd(request);
}
 
开发者ID:elixsr,项目名称:FwdPortForwardingApp,代码行数:20,代码来源:RuleListAdapter.java

示例2: request

import com.google.android.gms.ads.NativeExpressAdView; //导入方法依赖的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 {

            mIsImpressionConfirmed = false;
            mIsReady = false;
            mAdView = null;
            mNativeAd = new NativeExpressAdView(mContext);
            mNativeAd.setAdSize(new AdSize(WIDTH,HEIGHT));
            mNativeAd.setAdUnitId(unitId);
            mNativeAd.setAdListener(mAdListener);
            mNativeAd.loadAd(AdMob.getAdRequest(context));
        }
    }
}
 
开发者ID:pubnative,项目名称:pubnative-android-sdk,代码行数:23,代码来源:AdMobNativeExpressAdapter.java

示例3: request

import com.google.android.gms.ads.NativeExpressAdView; //导入方法依赖的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 {

            mIsReady = false;
            mAdView = null;
            mIsImpressionConfirmed = false;
            mNativeAd = new NativeExpressAdView(mContext);
            mNativeAd.setAdSize(AdSize.MEDIUM_RECTANGLE);
            mNativeAd.setAdUnitId(unitId);
            mNativeAd.setAdListener(mAdListener);
            mNativeAd.loadAd(AdMob.getAdRequest(context));
        }
    }
}
 
开发者ID:pubnative,项目名称:pubnative-android-sdk,代码行数:22,代码来源:AdMobNativeExpressAdapter.java

示例4: Initialize

import com.google.android.gms.ads.NativeExpressAdView; //导入方法依赖的package包/类
/**
 * Initializes the ad view.
 *EventName - Sets the subs that will handle the events.
 *AdUnitId - Ad unit ID of a native ad.
 *Width - Requested ad width.
 *Height - Requested ad height.
 */
public void Initialize(final BA ba, String EventName, String AdUnitId, float Width, float Height) {
	NativeExpressAdView ad = new NativeExpressAdView(ba.activity);
	ad.setAdSize(new AdSize((int)Math.round(Width / Common.Density), (int)Math.round(Height / Common.Density)));
	ad.setAdUnitId(AdUnitId);
	setObject(ad);
	super.Initialize(ba, EventName);
	final String eventName = EventName.toLowerCase(BA.cul);
	getObject().setAdListener(new AdListener() {

		@Override
		public void onAdFailedToLoad(int e){
			ba.raiseEvent(getObject(), eventName + "_failedtoreceivead", String.valueOf(e));
		}
		@Override
		public void onAdLoaded() {
			ba.raiseEvent(getObject(), eventName + "_receivead");
		}
		@Override
		public void onAdClosed() {
			ba.raiseEventFromDifferentThread(getObject(), null, 0, eventName + "_adscreendismissed", false, null);
		}
		@Override
		public void onAdLeftApplication() {
			//
		}
		@Override
		public void onAdOpened() {
			ba.raiseEventFromDifferentThread(getObject(), null, 0, eventName + "_presentscreen", false, null);

		}
	});
}
 
开发者ID:AnywhereSoftware,项目名称:B4A_FirebaseAdMob,代码行数:40,代码来源:AdViewWrapper.java

示例5: request

import com.google.android.gms.ads.NativeExpressAdView; //导入方法依赖的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 {
            mIsImpressionConfirmed = false;
            mAdView = null;
            mNativeAd = new NativeExpressAdView(mContext);

            DisplayMetrics displayMetrics = new DisplayMetrics();

            if(context instanceof Activity) {
                ((Activity) context).getWindowManager().getDefaultDisplay().getMetrics(displayMetrics);
                int heightDP = PNDeviceUtils.convertPxToDp(displayMetrics.heightPixels, context);
                heightDP = Math.min(Math.max(heightDP, MIN_HEIGHT), MAX_HEIGHT);
                int widthDP = PNDeviceUtils.convertPxToDp(displayMetrics.widthPixels, context);
                widthDP = Math.min(Math.max(widthDP, MIN_WIDTH), MAX_WIDTH);
                mNativeAd.setAdSize(new AdSize(widthDP, heightDP));
                mNativeAd.setAdUnitId(unitId);
                mNativeAd.setAdListener(mAdListener);
                mNativeAd.loadAd(AdMob.getAdRequest(context));
            } else {
                invokeLoadFail(PNException.ADAPTER_ILLEGAL_ARGUMENTS);
            }
        }
    }
}
 
开发者ID:pubnative,项目名称:pubnative-android-sdk,代码行数:32,代码来源:AdMobNativeExpressAdapter.java

示例6: getExpressAdView

import com.google.android.gms.ads.NativeExpressAdView; //导入方法依赖的package包/类
public static NativeExpressAdView getExpressAdView(Context context, ExpressAdPreset expressAdPreset) {
    NativeExpressAdView adView = new NativeExpressAdView(context);
    AdSize adSize = expressAdPreset.getAdSize();
    adView.setAdSize(adSize);
    adView.setAdUnitId(expressAdPreset.getAdUnitId());
    adView.setLayoutParams(new AbsListView.LayoutParams(AbsListView.LayoutParams.MATCH_PARENT,
            adSize.getHeightInPixels(context)));

    //set video options
    if(expressAdPreset.getVideoOptions() != null)
    adView.setVideoOptions(expressAdPreset.getVideoOptions());

    return adView;
}
 
开发者ID:clockbyte,项目名称:admobadapter,代码行数:15,代码来源:AdViewHelper.java

示例7: AdNativeExpress

import com.google.android.gms.ads.NativeExpressAdView; //导入方法依赖的package包/类
public AdNativeExpress(Context context, AttributeSet attrs, int defStyleAttr) {
    super(context, attrs, defStyleAttr);

    LayoutInflater.from(context).inflate(R.layout.ad_native_express_view, this);
    mNativeAdLayout = (FrameLayout) findViewById(R.id.ad_layout);
    mProgress = findViewById(R.id.progress);
    mAdText = findViewById(R.id.ad_text);
    mGHImage = (AppCompatImageView) findViewById(R.id.gh_image);

    findViewById(R.id.remove_ad).setOnClickListener(new OnClickListener() {
        @Override
        public void onClick(View v) {
            ViewUtils.dialogDonate(v.getContext()).show();
        }
    });

    mNativeExpressAdView = new NativeExpressAdView(context);
    mNativeExpressAdView.setLayoutParams(new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT,
            ViewGroup.LayoutParams.WRAP_CONTENT));
    mNativeExpressAdView.setAdUnitId(getContext().getString(Utils.DARK_THEME ?
            R.string.native_express_id_dark : R.string.native_express_id_light));
    mNativeExpressAdView.setAdListener(new AdListener() {
        @Override
        public void onAdFailedToLoad(int i) {
            super.onAdFailedToLoad(i);
            mNativeLoading = false;
            mNativeLoaded = false;
            mNativeFailedLoading = true;
            loadGHAd();
        }

        @Override
        public void onAdLoaded() {
            super.onAdLoaded();
            mNativeLoaded = true;
            mNativeLoading = false;
            mNativeFailedLoading = false;
            mProgress.setVisibility(GONE);
            mNativeAdLayout.addView(mNativeExpressAdView);
        }
    });
}
 
开发者ID:morogoku,项目名称:MTweaks-KernelAdiutorMOD,代码行数:43,代码来源:AdNativeExpress.java


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