布局鼓励意外点击 - 插页式广告:

LAYOUT ENCOURAGES ACCIDENTAL CLICKS - INTERSTITIAL ADS:(布局鼓励意外点击 - 插页式广告:)
本文介绍了布局鼓励意外点击 - 插页式广告:的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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.support.v7.app.AppCompatActivity;
    import android.webkit.WebSettings;
    import android.webkit.WebView;
    import android.webkit.WebViewClient;

    import com.google.android.gms.ads.AdListener;
    import com.google.android.gms.ads.AdRequest;
    import com.google.android.gms.ads.AdView;
    import com.google.android.gms.ads.InterstitialAd;

    public class a2 extends AppCompatActivity {

        AdView mAdView;
        InterstitialAd mInterstitialAd;
        WebView WebViewWithCSS;

        @Override
        protected void onCreate(Bundle savedInstanceState) {
            super.onCreate(savedInstanceState); requestWindowFeature(Window.FEATURE_NO_TITLE); getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);
            setContentView(R.layout.activity_a2);

            WebViewWithCSS = (WebView)findViewById(R.id.webView);

            WebSettings webSetting = WebViewWithCSS.getSettings();
            webSetting.setJavaScriptEnabled(true);

            WebViewWithCSS.setWebViewClient(new WebViewClient());
            WebViewWithCSS.loadUrl("file:///android_asset/2.html");

            mAdView = (AdView) findViewById(R.id.adView);
            AdRequest adRequest = new AdRequest.Builder()
                    .build();
            mAdView.loadAd(adRequest);

            mInterstitialAd = new InterstitialAd(this);

            // set the ad unit ID
            mInterstitialAd.setAdUnitId(getString(R.string.interstitial_full_screen));

            adRequest = new AdRequest.Builder()
                    .build();

            // Load ads into Interstitial Ads
            mInterstitialAd.loadAd(adRequest);

            mInterstitialAd.setAdListener(new AdListener() {
                public void onAdLoaded() {
                    showInterstitial();
                }
            });
        }

        @Override
        public void onPause() {
            if (mAdView != null) {
                mAdView.pause();
            }
            super.onPause();
        }

        @Override
        public void onResume() {
            super.onResume();
            if (mAdView != null) {
                mAdView.resume();
            }
        }

        @Override
        public void onDestroy() {
            if (mAdView != null) {
                mAdView.destroy();
            }
            super.onDestroy();
        }


        private void showInterstitial() {
            if (mInterstitialAd.isLoaded()) {
                mInterstitialAd.show();
            }
        }
    }

解决方案

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.

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);
    interstitialAd.setAdUnitId(getString(R.string.interstitial_unitID));
    interstitialAd.loadAd(adRequest);
} else {
    editor.putInt(AD_COUNT, sharedPreferences.getInt(AD_COUNT, 0) + 1).apply();
}

And onBackPressed() method:

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

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

这篇关于布局鼓励意外点击 - 插页式广告:的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!

本站部分内容来源互联网,如果有图片或者内容侵犯您的权益请联系我们删除!

相关文档推荐

How to target newer versions in .gitlab-ci.yml using auto devops (java 11 instead of 8 and Android 31 instead of 29)(如何在.gitlab-ci.yml中使用自动开发工具(Java 11而不是8,Android 31而不是29)瞄准较新的版本)
Android + coreLibraryDesugaring: which Java 11 APIs can I expect to work?(Android+core LibraryDesugering:我可以期待哪些Java 11API能够工作?)
How to render something in an if statement React Native(如何在If语句中呈现某些内容Reaction Native)
How can I sync two flatList scroll position in react native(如何在本机Reaction中同步两个平面列表滚动位置)
Using Firebase Firestore in offline only mode(在仅脱机模式下使用Firebase FiRestore)
Crash on Google Play Pre-Launch Report: java.lang.NoSuchMethodError(Google Play发布前崩溃报告:java.lang.NoSuchMethodError)