Correctly Disable Admob Ads

Correctly disable AdMob ads

In your layout file (eg, main.xml) :

<LinearLayout 
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/adsContainer">

<com.admob.android.ads.AdView
android:id="@+id/admobAds"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
app:backgroundColor="#000000"
app:primaryTextColor="#FFFFFF"
app:secondaryTextColor="#CCCCCC">

</LinearLayout>

Then in your code (eg, inside a "if" block)

(LinearLayout) adscontainer = (LinearLayout) findViewById(R.id.adsContainer);

View admobAds = (View) findViewById(R.id.admobAds);

adscontainer.removeView(admobAds);

This will "permanently" (for the lifecycle of the app) remove the ads from the layou, which means that there will not be any ads requested.

How to stop showing AdMob banner ad correctly?

The question is how to dismiss the bannerView or does not init it on
the next launch up? And how to insure AdMob Sdk will never refresh the
ad content in the background?

There are multiple ways to do this. One way I can think of is to add multiple targets in your Xcode project.

And the easier way, the more practical way - at least for me, is to prevent the requests for ads through GADRequest().

You can even do this even in AppDelegate, when setting Ids to your SDK.

That's it. You may also set nil to the delegate property of your bannerView.

And like what you've mentioned, just hide the bannerView's container, and everything should be perfect. I've worked on lots of applications with Admob, and I believe there should be no problem doing this approach.

How to remove android ads (admob) from the source code

Try it....

http://stackoverflow.com/questions/4549401/correctly-disable-admob-ads
http://stackoverflow.com/questions/13323097/in-app-purchase-remove-ads

please check above links it will help you.

Remove below code from your application

AdView adView = (AdView) this.findViewById(R.id.adView);
adView.loadAd(new AdRequest());

<xmlns:ads="http://schemas.android.com/apk/lib/com.google.ads"
android:id="@+id/adView"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
ads:adSize="BANNER"
ads:adUnitId="a1513ffd4f3e17c" />

google Adview in Android - how to set disabled in xml

How can i disable this ?

As long as you don't call the method to load ad it is similar to disabled. Will not display any ad.

one way is to wrap it around a linearlayout and then hide that layout but i want to disable the actual network call too, so is there a attribute in adview i can use etc ?

It is just a view. Common attributes like visibility, width, height, gravity etc are applicable to this as well.

Its necessary to do it by xml because im going to incorporate data binding to turn the ad on and off.

No you can do it without XML. Just create the adview in your Java code and attach it to your layout. Similarly you can also detach it.



Related Topics



Leave a reply



Submit