[英]Smart banner loading to full screen size
如何解决这个问题呢
在智能横幅中加载视频时,就会出现此问题
我用于最新的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);
我不确定,但是将此代码放在应用标签下的清单文件中
<uses-library
android:name="org.apache.http.legacy"
android:required="false" />
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.