AdMob插页式开放2次

时间:2015-06-08 01:17:41

标签: java android admob

我有两个代码用于Interstitial一个用于打开应用程序,第二个用于何时关闭应用程序当问题是第一个代码打开2次我的丈夫pote给某人代码网站onStop(退出应用程序)

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

关闭应用的代码

@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 个答案:

没有答案