【问题标题】:Smart banner loading to full screen size智能横幅加载到全屏大小
【发布时间】:2019-11-28 05:24:00
【问题描述】:

智能横幅加载适应全屏尺寸的广告正在加载,如下图

如何解决这个问题

当智能横幅中的视频加载时,这个问题就来了

我用于最新的 fcm 广告依赖 'com.google.firebase:firebase-ads:18.1.0'

此错误出现在 android 9.0 设备中

我的代码如下

 public static LinearLayout add;
        public static AdView adView;
        public static AdRequest request;

    public void load_add(final LinearLayout addViw) {
            adView = new AdView(Main_open.this);
            adView.setAdSize(AdSize.SMART_BANNER);
            adView.setAdUnitId(BANNAER_ID);
            request = new AdRequest.Builder().build();

            sharedPreference.putInt(getApplicationContext(), "addloded", 0);
            adView.setAdListener(new AdListener() {
                public void onAdLoaded() {
                    sharedPreference.putInt(getApplicationContext(), "addloded", 1);
                    Main_open.load_addFromMain(Main_open.this, add);

                    super.onAdLoaded();
                }

                public void onAdFailedToLoad(int errorcode) {
                    /*load_add(addViw);*/
                }
            });

            adView.loadAd(request);
            if (adView != null) {
                ViewGroup parentViewGroup = (ViewGroup) adView.getParent();
                if (parentViewGroup != null) {
                    parentViewGroup.removeAllViews();
                }
            }
        }

        public static void load_addFromMain(Context context, LinearLayout add_banner) {
            add = add_banner;
            try {
                if (adView != null) {
                    ViewGroup parentViewGroup = (ViewGroup) adView.getParent();
                    if (parentViewGroup != null) {
                        parentViewGroup.removeAllViews();
                    }
                }
                if (sharedPreference.getInt(context, "addloded") == 1) {
                    add_banner.setVisibility(View.VISIBLE);
                    add_banner.removeAllViews();
                    add_banner.addView(adView);
                }

            } catch (Exception e) {
                System.out.println("Ad Exception " + e);
            }

        }
    LinearLayout ads_lay = findViewById(R.id.ads_lay);
    load_addFromMain(CashList_Fragment.this, ads_lay);

【问题讨论】:

  • 您想全屏加载横幅广告吗?
  • 没有我的横幅广告加载全屏@DarShan
  • 您应该为您的 LinearLayout / AdView 添加 LayoutParams 或者您可以在 XML 布局中添加您的 AdView。
  • 你有另一个想法@DarShan

标签: java android admob ads google-ads-api


【解决方案1】:

我不确定,但将此代码放在应用程序标记下的清单文件中

 <uses-library
        android:name="org.apache.http.legacy"
        android:required="false" />

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2015-09-26
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多