0

Estou com um problema de delay em alguns anúncios intersticiais do adMob, o que pode ocasionar cliques indevidos, até estes dias estava tudo certo, mais não sei porque de uma hora pra outra começou com isso.

Meu código segue o padrão da Google, desconfio que seja algumas propagandas que não carregam na hora ocasionando este retardo ao mostrar.

O código em Java é este:

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();

O método:

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

Fiz vários testes, e percebi que a melhor forma foi retirar do AndroidManifest.xml esta linha aqui.

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

No site da Google pede pra ficar assim,

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

Mais não esta rolando com esta linha do theme, tenho alguns aplicativos em modo paisagem que fica legal com esta linha ai, mais pelo visto não vai funcionar.

Alguém sabe o que pode estar acontecendo?

1 Resposta 1

0

Tente fazer dessa forma :

 @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); }

Você deve fazer log-in para responder a esta pergunta.

Esta não é a resposta que você está procurando? Pesquise outras perguntas com a tag .