I am integrating AdMob into my app and I wonder how to disable Ads correctly. I want to give the user the ability to disable them. I don\'t want to get any problems with AdM
I also wanted to give users the ability to disable ads - why force people to see them if they don't want to? and why should you expect people to pay for that option?
Anyway, I outlined how I did this in this article. The article goes into more detail but here's the relevant parts:
The code i use to turn off ads:
private void hideAd() {
final AdView adLayout = (AdView) findViewById(R.id.adView1);
runOnUiThread(new Runnable() {
@Override
public void run() {
adLayout.setEnabled(false);
adLayout.setVisibility(View.GONE);
}
});
}
And to turn them back on (in case anyone was feeling generous)
private void showAd() {
final AdView adLayout = (AdView) findViewById(R.id.adView1);
runOnUiThread(new Runnable() {
@Override
public void run() {
adLayout.setEnabled(true);
adLayout.setVisibility(View.VISIBLE);
adLayout.loadAd(new AdRequest());
}
});
}