AdMob interstitial delay

0

I have a delay problem with some adMob interstitials, which can lead to undue clicks, until these days everything was fine, but I do not know why it started right away.

My code follows the Google standard, I suspect that some advertisements do not load on time causing this delay to show.

The Java code is this:

private void requestNewInterstitial() {
    AdRequest adRequest = new AdRequest.Builder().build();
    interstitial.loadAd(adRequest);
}

No onCreate

   // Criar o anúncio intersticial.
    interstitial = new InterstitialAd(this);
    interstitial.setAdUnitId(ADMOB_INTERSTICIAL); //meu codigo adMob
    // importante colocar este codigo aqui
    interstitial.setAdListener(new AdListener() {
        @Override
        public void onAdClosed() {
            requestNewInterstitial();
        }
    });

    requestNewInterstitial();

The method:

// Chamar displayInterstitial() quando você estiver pronto para exibir um
// intersticial.
public void displayInterstitial() {
    if (interstitial.isLoaded()) {
        interstitial.show();
    }
}

I ran several tests, and I realized that the best way was to remove from AndroidManifest.xml this line here.

android:theme="@android:style/Theme.Translucent" 

On Google's website, ask to stay like this,

android:configChanges="keyboard|keyboardHidden|orientation|
screenLayout|uiMode|screenSize|smallestScreenSize"
    android:theme="@android:style/Theme.Translucent" />

theme , I have some landscape mode apps that look cool with this line, but it's not going to work.

Does anyone know what might be happening?

    
asked by anonymous 05.11.2015 / 17:00

1 answer

0

Try to do this:

 @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);


        interstitialAd = new InterstitialAd(Main.this);
        interstitialAd.setAdUnitId(getString(R.string.adMobInter));
        AdRequest adRequest = new AdRequest.Builder()
                .addTestDevice(AdRequest.DEVICE_ID_EMULATOR)
                .addTestDevice(getString(R.string.adMob_test))
                .build();
        interstitialAd.loadAd(adRequest);

        interstitialAd.setAdListener(new AdListener() {


            @Override
            public void onAdLoaded() {
                
                   displayInterstitial();
                
            }

            @Override
            public void onAdFailedToLoad(int errorCode) {
                
                onMain();


            }

            @Override
            public void onAdClosed() {
                
                onMain();

            }
        });

    }

    public void displayInterstitial() {
      
        if (interstitialAd.isLoaded())  {
            interstitialAd.show();

        }
    }

    public void onMain() {

        setContentView(R.layout.main); }
    
19.06.2016 / 03:43