AdMob interstitial to open 2 times

595 views Asked by At

I have two codes for Interstitial one for you to open apps, and second for when to close the application when the problem is the first code to open 2 times my husband pote give someone a code for the site onStop (exit app)

@Override
    public void onCreate(Bundle savedInstanceState)
    {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        setupActionBar();
        setupDrawer(savedInstanceState);

        // init analytics tracker
        ((WebViewAppApplication) getApplication()).getTracker();

        mInterstitialAd = new InterstitialAd(this);
        mInterstitialAd.setAdUnitId("ca-app-pub-Code");
        AdRequest adRequest = new AdRequest.Builder()
                .addTestDevice("Cod")
                .build();

        mInterstitialAd.loadAd(adRequest);

        mInterstitialAd.setAdListener(new AdListener() {
            public void onAdLoaded() {
                // If Ads are loaded, show Interstitial else show nothing.
                if (mInterstitialAd.isLoaded()) {
                    mInterstitialAd.show();
                }
            }
        });
    }

Code for closing apps

@Override
    public void onStop()
    {
        super.onStop();

        mInterstitialAd = new InterstitialAd(this);
        mInterstitialAd.setAdUnitId("ca-app-pub-Code");
        AdRequest adRequest = new AdRequest.Builder()
                .addTestDevice("Cod")
                .build();

        mInterstitialAd.loadAd(adRequest);

        mInterstitialAd.setAdListener(new AdListener() {
            public void onAdLoaded() {
                // If Ads are loaded, show Interstitial else show nothing.
                if (mInterstitialAd.isLoaded()) {
                    mInterstitialAd.show();
                }
            }
        });
0

There are 0 answers