Reputation: 281
Smart banner load Adapting to full screen size ads are loading like following image
how to solve this problem
when video load in smart banner this problem comes
i am used in latest fcm ads dependancy 'com.google.firebase:firebase-ads:18.1.0'
this error comes in android 9.0 devices
my code are following
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);
Upvotes: 1
Views: 368
Reputation: 61
I am not sure but put this code in a menifest file under application tag
<uses-library
android:name="org.apache.http.legacy"
android:required="false" />
Upvotes: 1