JustOneMan
JustOneMan

Reputation: 202

How to show full screen ads on Exit?

I using SDL2 project for android. I try created small banner on enter and it works. but I need to show fullscreen ads on exit. I trying diffecent times, but iterstitial ads dosen't work anytime. My test code but it doesn't work:

protected void onCreate(Bundle savedInstanceState) {
        //Log.v("SDL", "onCreate()");
        super.onCreate(savedInstanceState);
    setContentView(R.layout.main);

    interstitial = new InterstitialAd(this);
    interstitial.setAdUnitId(MY_AD_UNIT_ID);

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

    interstitial.loadAd(adRequest);


        // So we can call stuff from static callbacks
        mSingleton = this;

        // Set up the surface
        mEGLSurface = EGL10.EGL_NO_SURFACE;
        mSurface = new SDLSurface(getApplication());

        mLayout = new AbsoluteLayout(this);


    mLayout.addView(mSurface);

        setContentView(mLayout);
    }



 protected void onDestroy() {

       if(interstitial.isLoaded()) {
            interstitial.show();
        }



        super.onDestroy();
        Log.v("SDL", "onDestroy()");
        // Send a quit message to the application
        SDLActivity.nativeQuit();

        // Now wait for the SDL thread to quit
        if (mSDLThread != null) {
            try {
                mSDLThread.join();
            } catch(Exception e) {
                Log.v("SDL", "Problem stopping thread: " + e);
            }
            mSDLThread = null;

            //Log.v("SDL", "Finished waiting for SDL thread");
        }
    }

Upvotes: 0

Views: 1550

Answers (2)

JustOneMan
JustOneMan

Reputation: 202

Ok, I partialy solved this I add testing device and it works.

Upvotes: 0

NarenderNishad
NarenderNishad

Reputation: 1068

Try this

mInterstitial = new InterstitialAd(this);
        mInterstitial.setAdUnitId(getResources().getString(R.string.publisher));
        mInterstitial.loadAd(new AdRequest.Builder().build());

Upvotes: 4

Related Questions