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


Java AdRequest.Builder方法代码示例

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


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

示例1: showFullScreenAdsIfRequired

import com.google.android.gms.ads.AdRequest; //导入方法依赖的package包/类
public static void showFullScreenAdsIfRequired(final StateActivity activity) {
    if (Premium.isPremiumUser(activity)) return;
    final InterstitialAd interstitialAd = new InterstitialAd(activity.getApplicationContext());
    interstitialAd.setAdUnitId(AdConstants.AdUnitId.AD_UNIT_ID_INTERSTITIAL);
    AdRequest.Builder request = new AdRequest.Builder();
    if (BuildConfig.DEBUG) {
        request.addTestDevice(TEST_DEVICE_ID);
    }
    interstitialAd.loadAd(request.build());
    interstitialAd.setAdListener(new AdListener() {
        @Override
        public void onAdLoaded() {
            super.onAdLoaded();
            if (!activity.isFinishing() && activity.isActivityVisible()) {
                interstitialAd.show();
            }
        }
    });
}
 
开发者ID:tranleduy2000,项目名称:text_converter,代码行数:20,代码来源:AdsManager.java

示例2: requestNewRewardedVideo

import com.google.android.gms.ads.AdRequest; //导入方法依赖的package包/类
private void requestNewRewardedVideo() {
	if (_config == null) { return; }

	AdRequest.Builder adRB = new AdRequest.Builder();

	if (BuildConfig.DEBUG) {
		adRB.addTestDevice(AdRequest.DEVICE_ID_EMULATOR);
		adRB.addTestDevice(Utils.getDeviceId(activity));
	}

	String ad_unit_id = _config.optString("RewardedVideoAdId", "");

	if (ad_unit_id.length() <= 0) {
		Utils.d("AdMob:RewardedVideo:UnitId:NotProvided");
		ad_unit_id = activity.getString(R.string.rewarded_video_ad_unit_id);
	}

	mrv.loadAd(ad_unit_id, adRB.build());
}
 
开发者ID:FrogSquare,项目名称:GodotAds,代码行数:20,代码来源:AdMob.java

示例3: createadmob

import com.google.android.gms.ads.AdRequest; //导入方法依赖的package包/类
private AdView createadmob() {
    AdView mAdView = new AdView(this);
    mAdView.setAdSize(AdSize.MEDIUM_RECTANGLE);
    mAdView.setAdUnitId("ca-app-pub-3940256099942544/6300978111");
    mAdView.setLayoutParams(new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT));
    // Create an ad request.
    AdRequest.Builder adRequestBuilder = new AdRequest.Builder();
    if (admob_test_mode)
        // Optionally populate the ad request builder.
        adRequestBuilder.addTestDevice(AdRequest.DEVICE_ID_EMULATOR);
    // Start loading the ad.
    mAdView.loadAd(adRequestBuilder.build());
    return mAdView;
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:15,代码来源:TestAdMobClassicActivity.java

示例4: loadAd

import com.google.android.gms.ads.AdRequest; //导入方法依赖的package包/类
public static void loadAd(final View view){
	final Builder builder = new AdRequest.Builder();		
	builder.addTestDevice(AdRequest.DEVICE_ID_EMULATOR); // Emulator
	
	// Add test devices
	final String[] testDevices = view.getContext().getString(R.string.testDevices).split(",");		
    for (String testDevice:testDevices){
    	builder.addTestDevice(testDevice);
    	
    }
    
    final AdView adView = (AdView) view.findViewById(R.id.adView);
    adView.loadAd(builder.build());
}
 
开发者ID:videgro,项目名称:Ships,代码行数:15,代码来源:Utils.java

示例5: requestNewRewardedVideo

import com.google.android.gms.ads.AdRequest; //导入方法依赖的package包/类
private void requestNewRewardedVideo(RewardedVideoAd mrv, String unitid) {
	Utils.d("AdMob:Loading:RewardedAd:For: "+unitid);
	AdRequest.Builder adRB = new AdRequest.Builder();

	if (BuildConfig.DEBUG) {
		adRB.addTestDevice(AdRequest.DEVICE_ID_EMULATOR);
		adRB.addTestDevice(Utils.getDeviceId(activity));
	}

	mrv.loadAd(unitid, adRB.build());
}
 
开发者ID:FrogSquare,项目名称:GodotFireBase,代码行数:12,代码来源:AdMob.java

示例6: requestNewInterstitial

import com.google.android.gms.ads.AdRequest; //导入方法依赖的package包/类
private void requestNewInterstitial() {
	AdRequest.Builder adRB = new AdRequest.Builder();

	if (BuildConfig.DEBUG) {
		adRB.addTestDevice(AdRequest.DEVICE_ID_EMULATOR);
		adRB.addTestDevice(Utils.getDeviceId(activity));
	}

	AdRequest adRequest = adRB.build();

	mInterstitialAd.loadAd(adRequest);
}
 
开发者ID:FrogSquare,项目名称:GodotFireBase,代码行数:13,代码来源:AdMob.java

示例7: createadmob

import com.google.android.gms.ads.AdRequest; //导入方法依赖的package包/类
private RelativeLayout createadmob() {

        AdSize adSize = AdSize.SMART_BANNER;

        DisplayMetrics dm = getResources().getDisplayMetrics();

        double density = dm.density * 160;
        double x = Math.pow(dm.widthPixels / density, 2);
        double y = Math.pow(dm.heightPixels / density, 2);
        double screenInches = Math.sqrt(x + y);

        if (screenInches > 8) { // > 728 X 90
            adSize = AdSize.LEADERBOARD;
        } else if (screenInches > 6) { // > 468 X 60
            adSize = AdSize.MEDIUM_RECTANGLE;
        } else { // > 320 X 50
            adSize = AdSize.BANNER;
        }

        adSize = AdSize.MEDIUM_RECTANGLE;
        final AdView mAdView = new AdView(this);
        mAdView.setAdSize(adSize);
        mAdView.setAdUnitId("ca-app-pub-3940256099942544/6300978111");
        // Create an ad request.
        AdRequest.Builder adRequestBuilder = new AdRequest.Builder();
        if (admob_test_mode)
            // Optionally populate the ad request builder.
            adRequestBuilder.addTestDevice(AdRequest.DEVICE_ID_EMULATOR);
        // Start loading the ad.
        mAdView.loadAd(adRequestBuilder.build());
        DisplayMetrics displaymetrics = new DisplayMetrics();
        final RelativeLayout layout = AdGoogleDisplaySupport.initialSupport(this, displaymetrics);
        final double ratio = AdGoogleDisplaySupport.ratioMatching(displaymetrics);
        final int ad_height = AdGoogleDisplaySupport.defaultHeight(displaymetrics);
        AdGoogleDisplaySupport.panelAdjust(mAdView, (int) (ad_height * ratio));
        // get display info
        /*  G.display_w = displayMetrics.widthPixels;
        G.display_h = displayMetrics.heightPixels;
        G.scale = Math.max(G.display_w/1280.0f, G.display_h/800.0f);*/
        mAdView.setAdListener(new AdListener() {
            @Override
            public void onAdLoaded() {
                super.onAdLoaded();
                int h = mAdView.getLayoutParams().height;
                AdGoogleDisplaySupport.scale(mAdView, ratio);
                AdGoogleDisplaySupport.panelAdjust(mAdView, (int) (h * ratio));
                //  if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP)
            }
        });
        layout.addView(mAdView);
        return layout;
    }
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:53,代码来源:TestAdvancedAdmobActivity.java


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