本文整理汇总了Java中com.google.android.gms.ads.AdSize类的典型用法代码示例。如果您正苦于以下问题:Java AdSize类的具体用法?Java AdSize怎么用?Java AdSize使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
AdSize类属于com.google.android.gms.ads包,在下文中一共展示了AdSize类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: setupBannerWithWait
import com.google.android.gms.ads.AdSize; //导入依赖的package包/类
private void setupBannerWithWait(final int waitTime) {
FrameLayout adFrame = (FrameLayout) root.findViewById(R.id.adFrame2);
adFrame.removeAllViews();
adView2 = new PublisherAdView(getActivity());
adView2.setAdUnitId(Constants.DFP_BANNER_ADUNIT_ID_300x250);
adView2.setAdSizes(new AdSize(300, 250));
adView2.setAdListener(adListener);
adFrame.addView(adView2);
//region PriceCheckForDFP API usage
PublisherAdRequest.Builder builder = new PublisherAdRequest.Builder();
PublisherAdRequest request = builder.build();
Prebid.attachBidsWhenReady(request, Constants.BANNER_300x250, this, waitTime, this.getActivity());
//endregion
}
示例2: addAds
import com.google.android.gms.ads.AdSize; //导入依赖的package包/类
private void addAds() {
// add AdMob
AdView adView = new AdView(this);
adView.setAdUnitId(AD_UNIT_ID);
adView.setAdSize(AdSize.SMART_BANNER);
LinearLayout.LayoutParams adLayoutParams = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.WRAP_CONTENT);
adView.setLayoutParams(adLayoutParams);
// 広告表示位置は画面下部
LinearLayout layout = new LinearLayout(this);
layout.addView(adView);
layout.setGravity(Gravity.BOTTOM);
LinearLayout.LayoutParams layoutParams = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.MATCH_PARENT);
addContentView(layout, layoutParams);
// load ad
AdRequest adRequest = new AdRequest.Builder().build();
adView.loadAd(adRequest);
}
示例3: addBannerAds
import com.google.android.gms.ads.AdSize; //导入依赖的package包/类
/**
* Create {@link PublisherAdView} and add to container
*
* @param context - android context
* @param container - parent view for add ad view
* @return true if ads has been added
*/
public static boolean addBannerAds(Context context, @Nullable ViewGroup container) {
if (isPremiumUser(context)) {
if (container != null) {
container.setVisibility(View.GONE);
}
return false;
} else {
if (container == null) return false;
container.setVisibility(View.VISIBLE);
PublisherAdView publisherAdView = new PublisherAdView(context);
publisherAdView.setAdSizes(AdSize.SMART_BANNER, AdSize.FLUID);
publisherAdView.setAdUnitId(AdConstants.AdUnitId.AD_UNIT_ID_NATIVE_MAIN_320_50);
PublisherAdRequest.Builder builder = new PublisherAdRequest.Builder();
if (BuildConfig.DEBUG) builder.addTestDevice(TEST_DEVICE_ID);
publisherAdView.loadAd(builder.build());
container.removeAllViews();
container.addView(publisherAdView);
}
return false;
}
示例4: setUpAndLoadNativeExpressAds
import com.google.android.gms.ads.AdSize; //导入依赖的package包/类
private void setUpAndLoadNativeExpressAds() {
mCoordinatorLayout.post(new Runnable() {
@Override
public void run() {
mNativeExpressAdView = new NativeExpressAdView(getContext());
float scale = getActivity().getResources().getDisplayMetrics().density;
int adWidth = mCoordinatorLayout.getWidth();
AdSize adSize = new AdSize((int) (adWidth / scale), NATIVE_EXPRESS_AD_HEIGHT);
mNativeExpressAdView.setAdSize(adSize);
mNativeExpressAdView.setAdUnitId(getString(R.string.test_ad_unit_id));
mAdViewContainer.addView(mNativeExpressAdView);
// Load the first Native Express ad in the items list.
AdRequest request = new AdRequest.Builder()
.addTestDevice("872EB083722CD10CAB1DB046CEE82A2D")
.build();
mNativeExpressAdView.loadAd(request);
}
});
}
示例5: onCreate
import com.google.android.gms.ads.AdSize; //导入依赖的package包/类
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
final ViewGroup adContainer = findViewById(R.id.adContainer);
adsManager = ((MainApplication) getApplicationContext()).getAdsManager();
adsManager.insertAdView(this, adContainer, R.string.admob_footer, AdSize.BANNER);
adsManager.loadAndShowInterstitial(R.string.admob_interstitial_install)
.subscribe(new Consumer<Boolean>() {
@Override
public void accept(Boolean aBoolean) throws Exception {
}
}, new Consumer<Throwable>() {
@Override
public void accept(Throwable throwable) throws Exception {
}
});
}
示例6: createAdView
import com.google.android.gms.ads.AdSize; //导入依赖的package包/类
private AdView createAdView() {
mAdView = new AdView(this);
mAdView.setAdSize(AdSize.LARGE_BANNER);
// setup "testing" banner type
boolean isStoreBuild = BuildConfig.FLAVOR.equals("playstore") && BuildConfig.BUILD_TYPE.equals("release");
String adUnitId = isStoreBuild ? AD_UNIT_ID : "ca-app-pub-3940256099942544/6300978111";
mAdView.setAdUnitId(adUnitId);
mAdView.setId(View.generateViewId()); // this is an arbitrary id, allows for relative positioning in createGameView()
RelativeLayout.LayoutParams params = new RelativeLayout.LayoutParams(
ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT);
params.addRule(RelativeLayout.ALIGN_PARENT_BOTTOM, RelativeLayout.TRUE);
params.addRule(RelativeLayout.CENTER_HORIZONTAL, RelativeLayout.TRUE);
mAdView.setLayoutParams(params);
mAdView.setBackgroundColor(Color.BLACK);
return mAdView;
}
示例7: AdViewHolder
import com.google.android.gms.ads.AdSize; //导入依赖的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);
}
示例8: request
import com.google.android.gms.ads.AdSize; //导入依赖的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));
}
}
}
示例9: request
import com.google.android.gms.ads.AdSize; //导入依赖的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));
}
}
}
示例10: initAdvertise
import com.google.android.gms.ads.AdSize; //导入依赖的package包/类
private void initAdvertise() {
AdView mAdView = new AdView(this);
RelativeLayout.LayoutParams params = new RelativeLayout.LayoutParams(ViewGroup.LayoutParams.FILL_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT);
params.addRule(RelativeLayout.ALIGN_PARENT_BOTTOM);
mAdView.setAdUnitId("ca-app-pub-3406938862137540/3927782716");
mAdView.setBackgroundColor(Color.BLACK);
AdRequest adRequest = new AdRequest.Builder().build();
double dppxl = (1 * (Resources.getSystem().getDisplayMetrics().densityDpi / 160f));
int v = this.getResources().getDisplayMetrics().heightPixels;
RelativeLayout layout = (RelativeLayout) findViewById(R.id.act_main_baseLayout);
layout.addView(mAdView, params);
if(v/dppxl > 720)
mAdView.setAdSize(AdSize.BANNER);
else
mAdView.setAdSize(AdSize.SMART_BANNER);
mAdView.loadAd(adRequest);
}
示例11: adSetup
import com.google.android.gms.ads.AdSize; //导入依赖的package包/类
private void adSetup() {
nativeAdHolder.post(new Runnable() {
@Override
public void run() {
int maxHeightPixels = nativeAdHolder.getResources().getDimensionPixelSize(R.dimen.admob_ad_height);
// Set the ad target size
int maxWidthInt = nativeAdHolder.getWidth();
maxWidthInt = (int) (maxWidthInt * 1f / itemView.getResources().getDisplayMetrics().density);
int maxHeightInt = (int) (maxHeightPixels * 1f / itemView.getResources().getDisplayMetrics().density);
nativeExpressAdView.setAdSize(new AdSize(maxWidthInt, maxHeightInt));
nativeExpressAdView.setAdUnitId(itemView.getContext().getString(adMobIdResource));
// Setup animation
finalHeight = maxHeightPixels;
}
});
}
示例12: getAdSize
import com.google.android.gms.ads.AdSize; //导入依赖的package包/类
public final AdSize getAdSize()
{
try
{
if (this.zzvb != null)
{
AdSizeParcel localAdSizeParcel = this.zzvb.zzbb();
if (localAdSizeParcel != null)
{
AdSize localAdSize = new AdSize(localAdSizeParcel.width, localAdSizeParcel.height, localAdSizeParcel.zzuA);
return localAdSize;
}
}
}
catch (RemoteException localRemoteException)
{
com.google.android.gms.ads.internal.util.client.zzb.w("Failed to get the current AdSize.", localRemoteException);
if (this.zzuH != null) {
return this.zzuH[0];
}
}
return null;
}
示例13: zza
import com.google.android.gms.ads.AdSize; //导入依赖的package包/类
public final void zza(AdSize... paramVarArgs)
{
this.zzuH = paramVarArgs;
try
{
if (this.zzvb != null)
{
Context localContext = this.zzvd.getContext();
AdSize[] arrayOfAdSize = this.zzuH;
boolean bool = this.zzvi;
new AdSizeParcel(localContext, arrayOfAdSize).zzuF = bool;
}
this.zzvd.requestLayout();
return;
}
catch (RemoteException localRemoteException)
{
for (;;)
{
com.google.android.gms.ads.internal.util.client.zzb.w("Failed to set the ad size.", localRemoteException);
}
}
}
示例14: getAdSize
import com.google.android.gms.ads.AdSize; //导入依赖的package包/类
private com.facebook.ads.AdSize getAdSize(Context context, AdSize adSize) {
if (adSize.getWidth() == com.facebook.ads.AdSize.BANNER_320_50.getWidth()
&& adSize.getHeight() == com.facebook.ads.AdSize.BANNER_320_50.getHeight()) {
return com.facebook.ads.AdSize.BANNER_320_50;
}
// adSize.getHeight will return -2 for smart banner. So we need to use
// adSize.getHeightInPixels here.
int heightInDip = pixelToDip(adSize.getHeightInPixels(context));
if (heightInDip == com.facebook.ads.AdSize.BANNER_HEIGHT_50.getHeight()) {
return com.facebook.ads.AdSize.BANNER_HEIGHT_50;
}
if (heightInDip == com.facebook.ads.AdSize.BANNER_HEIGHT_90.getHeight()) {
return com.facebook.ads.AdSize.BANNER_HEIGHT_90;
}
if (heightInDip == com.facebook.ads.AdSize.RECTANGLE_HEIGHT_250.getHeight()) {
return com.facebook.ads.AdSize.RECTANGLE_HEIGHT_250;
}
return null;
}
示例15: ADView
import com.google.android.gms.ads.AdSize; //导入依赖的package包/类
private void ADView() {
LinearLayout adBannerLayout = (LinearLayout) findViewById(R.id.footerLayout);
adView = new AdView(this);
adView.setAdUnitId(Constant.ADMob_BuddhaVoice);
adView.setAdSize(AdSize.SMART_BANNER);
adBannerLayout.addView(adView);
AdRequest adRequest;
if (BuddhaVoice.APPDEBUG) {
//Test Mode
adRequest = new AdRequest.Builder()
.addTestDevice(AdRequest.DEVICE_ID_EMULATOR)
.addTestDevice(Constant.ADMob_TestDeviceID)
.build();
} else {
adRequest = new AdRequest.Builder().build();
}
adView.loadAd(adRequest);
}