java - 智能横幅加载到全屏大小
问题描述
如何解决这个问题呢
当智能横幅中的视频加载时出现此问题
我用于最新的 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" />
推荐阅读
- python - exe下载失败
- javascript - Angular 9 不导航到锚点
- google-cloud-functions - 谷歌云http认证函数到函数
- jquery - 引导箱提示使用数据库中的选项进行选择
- node.js - 是否可以在 CENTOS 7.8 上使用 tensorflow.js 部署节点服务器?
- django - 卸载 django 会删除所有迁移和我所做的更改吗?
- docker - 在 docker-letsencrypt-nginx-proxy-companion 中为一个或多个容器启用 CORS
- python - Spyder(Anaconda)的IPython控制台中没有输出
- java - 当我尝试使用 get 方法打印时,Getter 没有返回任何内容
- z3 - Z3 变量名导致“未知”可满足性