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


Java AdSize类代码示例

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


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

示例1: adSizeFromSize

import com.google.ads.AdSize; //导入依赖的package包/类
/**
 * Gets an AdSize object from the string size passed in from JavaScript.
 * Returns null if an improper string is provided.
 *
 * @param size The string size representing an ad format constant.
 * @return An AdSize object used to create a banner.
 */
public static AdSize adSizeFromSize(String size) {
  if ("BANNER".equals(size)) {
    return AdSize.BANNER;
  } else if ("IAB_MRECT".equals(size)) {
    return AdSize.IAB_MRECT;
  } else if ("IAB_BANNER".equals(size)) {
    return AdSize.IAB_BANNER;
  } else if ("IAB_LEADERBOARD".equals(size)) {
    return AdSize.IAB_LEADERBOARD;
  } else if ("SMART_BANNER".equals(size)) {
    return AdSize.SMART_BANNER;
  } else {
    return null;
  }
}
 
开发者ID:psydrake,项目名称:litecoinEasyCheck,代码行数:23,代码来源:AdMob.java

示例2: executeCreateBannerView

import com.google.ads.AdSize; //导入依赖的package包/类
/**
 * Parses the create banner view input parameters and runs the create banner
 * view action on the UI thread. If this request is successful, the
 * developer should make the requestAd call to request an ad for the banner.
 * 
 * @param inputs
 *            The JSONArray representing input parameters. This function
 *            expects the first object in the array to be a JSONObject with
 *            the input parameters.
 * @return A PluginResult representing whether or not the banner was created
 *         successfully.
 */
private void executeCreateBannerView(JSONArray inputs, CallbackContext callbackContext) {
	String publisherId = "";
	String size = "";

	// Get the input data.
	try {
		JSONObject data = inputs.getJSONObject(0);
		publisherId = data.getString("publisherId");
		size = data.getString("adSize");
		this.positionAtTop = data.getBoolean("positionAtTop");
		Log.w(LOGTAG, "executeCreateBannerView OK");
		Log.w(LOGTAG, "size: " + size);
		Log.w(LOGTAG, "publisherId: " + publisherId);
		Log.w(LOGTAG, "positionAtTop: " + (this.positionAtTop ? "true" : "false"));
	} catch (JSONException exception) {
		Log.w(LOGTAG,
				String.format("Got JSON Exception: %s",
						exception.getMessage()));
		callbackContext.error(exception.getMessage());
	}
	AdSize adSize = adSizeFromSize(size);
	createBannerView(publisherId, adSize, callbackContext);
}
 
开发者ID:rafinskipg,项目名称:BombTouch,代码行数:36,代码来源:AdMobPlugin.java

示例3: adSizeFromSize

import com.google.ads.AdSize; //导入依赖的package包/类
/**
 * Gets an AdSize object from the string size passed in from JavaScript.
 * Returns null if an improper string is provided.
 * 
 * @param size
 *            The string size representing an ad format constant.
 * @return An AdSize object used to create a banner.
 */
public static AdSize adSizeFromSize(String size) {
	if ("BANNER".equals(size)) {
		return AdSize.BANNER;
	} else if ("IAB_MRECT".equals(size)) {
		return AdSize.IAB_MRECT;
	} else if ("IAB_BANNER".equals(size)) {
		return AdSize.IAB_BANNER;
	} else if ("IAB_LEADERBOARD".equals(size)) {
		return AdSize.IAB_LEADERBOARD;
	} else if ("SMART_BANNER".equals(size)) {
		return AdSize.SMART_BANNER;
	} else {
		return null;
	}
}
 
开发者ID:rafinskipg,项目名称:BombTouch,代码行数:24,代码来源:AdMobPlugin.java

示例4: addAdsTo

import com.google.ads.AdSize; //导入依赖的package包/类
public void addAdsTo(ViewGroup container) {
    this.mContainer =container;
    mContainer.setVisibility(View.VISIBLE);
    View v = mContainer.findViewById(R.id.ad_banner);
    if(v==null) {

        AdView ad = new AdView(mContext,AdSize.BANNER, mAdUnitId);
        ad.setId(R.id.ad_banner);

        container.removeAllViews();
        ad.setAdListener(this);
        AdRequest request = new AdRequest();
        if(mTestDevices!=null)
            request.setTestDevices(mTestDevices);
        request.addTestDevice(AdRequest.TEST_EMULATOR);
        ad.loadAd(request);
        container.addView(ad);
    }

}
 
开发者ID:MagicMicky,项目名称:FreemiumLibrary,代码行数:21,代码来源:AdsInstantiator.java

示例5: onCreateView

import com.google.ads.AdSize; //导入依赖的package包/类
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    RelativeLayout v = (RelativeLayout) super.onCreateView(inflater, container, savedInstanceState);

    LocalBroadcastManager.getInstance(getActivity()).registerReceiver(mHideAds, new IntentFilter(ConstsFree.REMOVE_ADS));
    /**
     * If ads are disabled we don't need to load any
     */
    if (!SharedPreferencesHelperFree.getDisableAds(getActivity())) {
        mAdView = new AdView(getActivity(), AdSize.SMART_BANNER, ConstsFree.ADMOB_ID);

        /**
         * The AdView should be attached to the bottom of the screen, with the GridView position above it
         */
        RelativeLayout.LayoutParams adParams = new RelativeLayout.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT,
                                                                               ViewGroup.LayoutParams.WRAP_CONTENT);
        adParams.addRule(RelativeLayout.ALIGN_PARENT_BOTTOM);
        v.addView(mAdView, adParams);

        mAdView.loadAd(AdUtil.getAdRequest());
    }

    return v;
}
 
开发者ID:antew,项目名称:RedditInPictures,代码行数:25,代码来源:RedditImageListFragmentFree.java

示例6: onCreateView

import com.google.ads.AdSize; //导入依赖的package包/类
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    View view = inflater.inflate(R.layout.pause_layout, container);
    LinearLayout adLayout = (LinearLayout) view.findViewById(R.id.adLayout);

    adView = new AdView(activity, AdSize.BANNER, AdSettings.ADSENSE_ID);
    DisplayMetrics displayMetrics = activity.getResources().getDisplayMetrics();
    int width = Math.round(TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, AdSize.BANNER.getWidth(), displayMetrics));
    int height = Math.round(TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, AdSize.BANNER.getHeight(), displayMetrics));
    adLayout.addView(adView, width, height);
    AdRequest adRequest = new AdRequest();
    adRequest.addTestDevice(AdSettings.TEST_DEVICE_ID);
    adView.loadAd(adRequest);

    getDialog().setTitle(R.string.pause_title);

    Button pauseList = (Button) view.findViewById(R.id.pause_button_list);
    Button pauseRestart = (Button) view.findViewById(R.id.pause_button_restart);
    Button pauseContinue = (Button) view.findViewById(R.id.pause_button_continue);

    pauseContinue.setOnClickListener(new OnContinueClickListener());
    pauseList.setOnClickListener(new OnLevelListClickListener());
    pauseRestart.setOnClickListener(new OnRestartClickListener());

    return view;
}
 
开发者ID:tschut,项目名称:drturbo,代码行数:27,代码来源:PauseMenuFragment.java

示例7: addAD

import com.google.ads.AdSize; //导入依赖的package包/类
/**
 * AdViewを挿入
 */
private void addAD() {
    // for adView
    //
    adView = new AdView(this, AdSize.BANNER, Conf.MY_AD_UNIT_ID);

    LinearLayout layout = (LinearLayout) findViewById(R.id.admobspace);

    // adView処理 --- ここから
    layout.addView(adView);

    // 広告の読み込み
    AdRequest adRequest = new AdRequest();
    if (BuildConfig.DEBUG) {
        // ここから - できればリリース時にコメントアウト
        // エミュレータ
        adRequest.addTestDevice(AdRequest.TEST_EMULATOR);
        // Android端末をテスト
        // "XXXXXX...XX"には、端末の識別IDを指定(指定したIDの端末には広告は表示されない)
        adRequest.addTestDevice("XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX");
        // ここまで
    }
    adView.loadAd(adRequest);
    // adView処理 --- ここまで

}
 
开发者ID:Kyakujin,项目名称:AutoEco,代码行数:29,代码来源:MainActivity.java

示例8: onCreate

import com.google.ads.AdSize; //导入依赖的package包/类
@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    
    AndroidApplicationConfiguration cfg = new AndroidApplicationConfiguration();
    
    RelativeLayout layout = new RelativeLayout(this);
    adView = new AdView(this, AdSize.BANNER, AdMob_Ad_Unit); // Put in your secret key here
    
    View gameView = initializeForView(new AmpelBird(this), cfg);
    
    AdRequest adRequest = new AdRequest();
    adView.loadAd(adRequest);
    
    // Add the libgdx view
    layout.addView(gameView);

    // Add the AdMob view
    RelativeLayout.LayoutParams adParams = 
            new RelativeLayout.LayoutParams(RelativeLayout.LayoutParams.WRAP_CONTENT, 
                            RelativeLayout.LayoutParams.WRAP_CONTENT);
    
    adParams.addRule(RelativeLayout.ALIGN_PARENT_BOTTOM);
    adParams.addRule(RelativeLayout.ALIGN_PARENT_LEFT);
    
    layout.addView(adView, adParams);
    
    setContentView(layout);
}
 
开发者ID:onatm,项目名称:Ampel-Bird,代码行数:30,代码来源:MainActivity.java

示例9: InitializeUIThread

import com.google.ads.AdSize; //导入依赖的package包/类
public void InitializeUIThread(String p_key) {
	
	// Create the interstitial
	interstitial = new InterstitialAd(activity, p_key);
	
	// Create banner
	adView = new AdView(activity, AdSize.SMART_BANNER, p_key);

	RelativeLayout layout = ((Godot)activity).layout;
	RelativeLayout.LayoutParams layoutParams = new RelativeLayout.LayoutParams(LayoutParams.WRAP_CONTENT,
        LayoutParams.WRAP_CONTENT);

	layoutParams.addRule(layoutRule1);
	layoutParams.addRule(layoutRule2);
	layout.addView(adView, layoutParams);
	layout.invalidate();

	adView.setVisibility(View.VISIBLE);        
	
	initialized = true;
	
    	adReceived = false;
    	screenDismissed = false;
    	failedToReceiveAd = false;
    	applicationLeaved = false;
    	presentScreen = false;        

	Log.d("godot", "AdMob: Initialized");
}
 
开发者ID:punto-,项目名称:godot_modules,代码行数:30,代码来源:GodotAdMob.java

示例10: onCreate

import com.google.ads.AdSize; //导入依赖的package包/类
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    adView = new AdView(this, AdSize.BANNER, "a14defa59f9a1e7");
    FrameLayout layout = (FrameLayout)findViewById(R.id.frameLayout);
    layout.addView(adView);
    adView.loadAd(new AdRequest());
    setAdView(adView);
}
 
开发者ID:Ruenzuo,项目名称:android-cd-travis-example,代码行数:10,代码来源:CitiesActivity.java

示例11: createBannerView

import com.google.ads.AdSize; //导入依赖的package包/类
private synchronized void createBannerView(final String publisherId,
		final AdSize adSize, final CallbackContext callbackContext) {
	final CordovaInterface cordova = this.cordova;

	// Create the AdView on the UI thread.
	Log.w(LOGTAG, "createBannerView");
	Runnable runnable = new Runnable() {
		public void run() {
			Log.w(LOGTAG, "run");
			Log.w(LOGTAG, String.valueOf(webView));
			// Log.w(LOGTAG, "adSize::" + adSize); calling adSize.toString() with SmartBanner == crash
			if (adSize == null) {
				callbackContext
						.error("AdSize is null. Did you use an AdSize constant?");
				return;
			} else {
				adView = new DfpAdView(cordova.getActivity(), adSize,
						publisherId);
				adView.setAdListener(new BannerListener());
				LinearLayoutSoftKeyboardDetect parentView = (LinearLayoutSoftKeyboardDetect) webView
						.getParent();
				if (positionAtTop) {
					parentView.addView(adView, 0);
				} else {
					parentView.addView(adView);
				}
				// Notify the plugin.
				callbackContext.success();
			}
		}
	};
	this.cordova.getActivity().runOnUiThread(runnable);
}
 
开发者ID:rafinskipg,项目名称:BombTouch,代码行数:34,代码来源:AdMobPlugin.java

示例12: onCreateView

import com.google.ads.AdSize; //导入依赖的package包/类
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    View view = inflater.inflate(R.layout.end_level_layout, container);

    LinearLayout adLayout = (LinearLayout) view.findViewById(R.id.adLayout);

    adView = new AdView(activity, AdSize.BANNER, AdSettings.ADSENSE_ID);
    DisplayMetrics displayMetrics = activity.getResources().getDisplayMetrics();
    int width = Math.round(TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, AdSize.BANNER.getWidth(), displayMetrics));
    int height = Math.round(TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, AdSize.BANNER.getHeight(), displayMetrics));
    adLayout.addView(adView, width, height);
    AdRequest adRequest = new AdRequest();
    adRequest.addTestDevice(AdSettings.TEST_DEVICE_ID);
    adView.loadAd(adRequest);

    getDialog().setTitle(titleResource);
    ((TextView) view.findViewById(R.id.end_level_subtitle)).setText(textResource);
    ((ImageView) view.findViewById(R.id.end_level_star)).setImageResource(imageResource);
    ((TextView) view.findViewById(R.id.end_level_points)).setText(Integer.toString(points));
    ((TextView) view.findViewById(R.id.end_level_points_best)).setText(Integer.toString(best));

    Button next = (Button) view.findViewById(R.id.end_level_button_next);
    Button list = (Button) view.findViewById(R.id.end_level_button_list);
    Button retry = (Button) view.findViewById(R.id.end_level_button_retry);

    next.setEnabled(nextLevelUnlocked);

    next.setOnClickListener(new OnNextLevelClickListener());
    list.setOnClickListener(new OnLevelListClickListener());
    retry.setOnClickListener(new OnRetryClickListener());

    return view;
}
 
开发者ID:tschut,项目名称:drturbo,代码行数:34,代码来源:EndLevelDialogFragment.java

示例13: requestBannerAd

import com.google.ads.AdSize; //导入依赖的package包/类
@Override
public void requestBannerAd(CustomEventBannerListener listener, final Activity activity,
                            String label, String serverParameter, AdSize adSize, MediationAdRequest mediationAdRequest,
                            Object extra) {
    Clog.d(Clog.mediationLogTag, "Initializing ANBanner via AdMob SDK");
    this.listener = listener;

    BannerAdView appNexusAdView = new BannerAdView(activity);
    appNexusAdView.setPlacementID(serverParameter);
    appNexusAdView.setAdSize(adSize.getWidth(), adSize.getHeight());
    appNexusAdView.setShouldServePSAs(false);
    appNexusAdView.setAdListener(this);

    switch (mediationAdRequest.getGender()) {
        case MALE:
            appNexusAdView.setGender(AdView.GENDER.MALE);
            break;
        case FEMALE:
            appNexusAdView.setGender(AdView.GENDER.FEMALE);
            break;
        default:
            // unknown case passes nothing
            break;
    }

    if (mediationAdRequest.getAgeInYears() != null) {
        appNexusAdView.setAge(String.valueOf(mediationAdRequest.getAgeInYears()));
    }
    SDKSettings.setLocation(mediationAdRequest.getLocation());

    Clog.d(Clog.mediationLogTag, "Load ANBanner");
    appNexusAdView.loadAdOffscreen();
}
 
开发者ID:appnexus,项目名称:mobile-sdk-android,代码行数:34,代码来源:AdMobMediationBanner.java

示例14: requestAd

import com.google.ads.AdSize; //导入依赖的package包/类
/**
 * Interface called by the AN SDK to request an ad from the mediating SDK.
 *
 * @param mBC       the object which will be called with events from the 3d party SDK
 * @param activity  the activity from which this is launched
 * @param parameter String parameter received from the server for instantiation of this object
 * @param adUnitID  The 3rd party placement , in adMob this is the adUnitID
 * @param width     Width of the ad
 * @param height    Height of the ad
 */
@Override
public View requestAd(MediatedBannerAdViewController mBC, Activity activity, String parameter, String adUnitID,
                      int width, int height, TargetingParameters targetingParameters) {
    adListener = new AdMobAdListener(mBC, super.getClass().getSimpleName());
    adListener.printToClog(String.format(" - requesting an ad: [%s, %s, %dx%d]",
            parameter, adUnitID, width, height));

    admobAV = new AdView(activity, new AdSize(width, height), adUnitID);
    admobAV.setAdListener(adListener);
    AdRequest ar = new AdRequest();

    switch (targetingParameters.getGender()) {
        case UNKNOWN:
            break;
        case FEMALE:
            ar.setGender(AdRequest.Gender.FEMALE);
            break;
        case MALE:
            ar.setGender(AdRequest.Gender.MALE);
            break;
    }
    AdMobAdapterExtras extras = new AdMobAdapterExtras();
    if (targetingParameters.getAge() != null) {
        extras.addExtra("Age", targetingParameters.getAge());
    }

    for (Pair<String, String> p : targetingParameters.getCustomKeywords()) {
        extras.addExtra(p.first, p.second);
    }
    if (targetingParameters.getLocation() != null) {
        ar.setLocation(targetingParameters.getLocation());
    }
    ar.setNetworkExtras(extras);

    admobAV.loadAd(ar);
    return admobAV;
}
 
开发者ID:appnexus,项目名称:mobile-sdk-android,代码行数:48,代码来源:LegacyAdMobBanner.java

示例15: placeADMobAd

import com.google.ads.AdSize; //导入依赖的package包/类
public static void placeADMobAd(ViewGroup viewGroup, LayoutParams params) {
	AdView adView = new AdView(activity, AdSize.BANNER, "c89f8c998cb3499c");
	AdRequest adRequest = new AdRequest();
	if (params == null)
		viewGroup.addView(adView);
	else
		viewGroup.addView(adView, params);
	adView.loadAd(adRequest);
}
 
开发者ID:jlaws,项目名称:gundog-engine,代码行数:10,代码来源:ADS.java


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