Exception or error:

Please any one help Now my app has disable by admob due to wrong interstitial code as

“Interstitial ads that load unexpectedly while a user is viewing the
app’s content”.

what to do? Please some one correct me…

    import android.os.Bundle;
    import android.view.Window;
    import android.view.WindowManager;
    import android.webkit.WebSettings;
    import android.webkit.WebView;
    import android.webkit.WebViewClient;


    public class a2 extends AppCompatActivity {

        AdView mAdView;
        InterstitialAd mInterstitialAd;
        WebView WebViewWithCSS;

        protected void onCreate(Bundle savedInstanceState) {
            super.onCreate(savedInstanceState); requestWindowFeature(Window.FEATURE_NO_TITLE); getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);

            WebViewWithCSS = (WebView)findViewById(;

            WebSettings webSetting = WebViewWithCSS.getSettings();

            WebViewWithCSS.setWebViewClient(new WebViewClient());

            mAdView = (AdView) findViewById(;
            AdRequest adRequest = new AdRequest.Builder()

            mInterstitialAd = new InterstitialAd(this);

            // set the ad unit ID

            adRequest = new AdRequest.Builder()

            // Load ads into Interstitial Ads

            mInterstitialAd.setAdListener(new AdListener() {
                public void onAdLoaded() {

        public void onPause() {
            if (mAdView != null) {

        public void onResume() {
            if (mAdView != null) {

        public void onDestroy() {
            if (mAdView != null) {

        private void showInterstitial() {
            if (mInterstitialAd.isLoaded()) {
How to solve:

from admobs own guidelines

“A common issue is that even though you may intend for the ad to load in between page content, the ad itself appears shortly after a new page of content has loaded due to carrier latency.”

Your code shows the interstitial when it has finished loading – this won’t give the user any warning so they’ll be in the middle of looking at the webview and suddenly the interstitial appears. Pre-load it and show it at a natural break.

Your code calls showInterstitial() in onAdLoaded() – it needs to call mInterstitialAd.loadAd() in advance of the ad being needed, and set a flag to say that it is present. It can then call the showInterstitial() before loading the webview and show the web view when the interstitial ad is dismissed


Ads are disabled on my app after a couple of warnings, even I followed AdMob guidelines. I found the following key points in my research:

  • Show Interstitial between pages
  • Show Interstitial when a game level is completed
  • Avoid accidental clicks
  • Show on RIGHT TIME

The only issue I had was with right time. When is the right time for loading Interstitial? It all depends on you but in my case, an Interstitial was loading and showing after few seconds activity. This was happening because of slow internet connection. What basically happens is that activity shows and a user start interaction but Interstitial is not loaded yet. But the Interstitial loads and shows in the mid of interaction which causes an accidental click – which is against the policy.

Here are some corrective measures I took for my app:

  • Limit showing an ad for a person
  • Check if an ad is loaded and then display it while leaving an activity

For the first point, I used AdMob settings to limit the Frequency Cap to limit displaying an ad for a person. I show one ad in five minutes.

Frequency capping: Limits the number of times ads are shown to the same
person per minute, per hour, or per day.
Google AdMob

And I also used counter in an activity to show an ad when a user visits an activity a couple of times.

For the second point, I show an ad when a user goes back to the previous screen.

In the onCreate() method:

counter = sharedPreferences.getInt(AD_COUNT, 0);
editor = sharedPreferences.edit();

if(2 == counter) {
    interstitialAd = new InterstitialAd(this);
} else {
    editor.putInt(AD_COUNT, sharedPreferences.getInt(AD_COUNT, 0) + 1).apply();

And onBackPressed() method:

public void onBackPressed() {
    if (2 == counter && interstitialAd.isLoaded()) {;

        //Reset the counter
        editor.putInt(AD_COUNT, sharedPreferences.getInt(AD_COUNT, 0)).apply();


Here is how to fix “LAYOUT ENCOURAGES ACCIDENTAL CLICKS – INTERSTITIAL ADS” violation and other possible violations

Leave a Reply

Your email address will not be published. Required fields are marked *