Reputation: 166
I have a Banner Ad unit which is served only through one ad source i.e. Admob Network. I was trying to have control over it to display ad or not as per my requirement, specifically to pause or enable an Ad unit similar to what one can do with House Ad campaigns but i couldn't find anything without people suggesting me to have server controlled flag on the Ad
I even found a way around it by setting location to the Ad for a different country when i don't want to show the ad: https://firebase.google.com/docs/admob/android/targeting#location but problem is still the same,to have control i need to make a server call to set location to my country to stat displaying the ad
Is there a solution to this? or any better one will be highly appreciated.
Upvotes: 2
Views: 2530
Reputation: 23394
When You dont want to show ad, make the Visibility of banner view to Gone
<com.google.android.gms.ads.AdView
android:id="@+id/adView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
ads:adSize="BANNER"
ads:adUnitId="Your Id"
android:layout_centerHorizontal="true"/>
in main activity
AdView admobBannerView = (AdView) findViewById(R.id.adView);
//when ever you dont want to display ad
admobBannerView.setVisibility(View.GONE);
//when you want to display ad
admobBannerView.setVisibility(View.VISIBLE);
Upvotes: 1