Discussion:
[SDL] SDL 2.0 and Interstital Ads
Timodor
2016-09-21 02:15:38 UTC
Permalink
Hello people not sure if this is in scope I can get Banners ads working fine coming and going. But Interstitial Ads leave me with black screen. This related to SDL?

mInterstitialAd = new InterstitialAd(SDLActivity.this);

setContentView(R.layout.main);

These might be the issues?
M. Gerhardy
2016-09-21 05:35:36 UTC
Permalink
Even though I can't answer this question in particular, you are welcome to
check out my own android code where I got them working:
https://github.com/mgerhardy/caveexpress - or the direkt link:
https://github.com/mgerhardy/caveexpress/blob/master/android-project/src/org/base/game/BaseGameAdsActivity.java
(I'm activating them them JNI - so you won't find the calling code on the
java side, but here:
https://github.com/mgerhardy/caveexpress/blob/master/src/modules/common/ports/Android.cpp

Hope this helps.
Martin
Post by Timodor
Hello people not sure if this is in scope I can get Banners ads working
fine coming and going. But Interstitial Ads leave me with black screen.
This related to SDL?
mInterstitialAd = new InterstitialAd(SDLActivity.this);
setContentView(R.layout.main);
These might be the issues?
_______________________________________________
SDL mailing list
http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org
--
http://www.caveproductions.org
Timodor
2016-09-21 06:05:00 UTC
Permalink
I end up getting it working, it just came up with trial and error.

I'm using NDK to communicate to Java to tell it when Display the Add or PreCache it.

0 to Cache it, 1 Display it, -1 means it's Cached.

THREAD SAFE

public void ShowInt()
{
runOnUiThread(new Runnable()
{
public void run()
{
reallyShowInt();
}
});
}



private void reallyShowInt()
{
if (inter == 0 ) // NOT CHACHED
mInterstitialAd = new InterstitialAd(SDLActivity.this);

runOnUiThread(new Runnable()
{
public void run()
{

if (inter == 0) // NOT CACHED
{

mInterstitialAd.setAdUnitId("ca-app-pub-3940256099942544/1033173712"); //TEST ADMOB ID


AdRequest adRequest = new AdRequest.Builder()
//.addTestDevice(AdRequest.DEVICE_ID_EMULATOR)
.build();

mInterstitialAd.loadAd(adRequest);

inter = -1; // DO NOT CACHE AGAIN
}


if (inter == 1) // DISPLAY ADD ASSUME CACHED
{
if (mInterstitialAd.isLoaded())
{
mInterstitialAd.show();
//inter = 0;
}

}
}

});
}
Even though I can't answer this question in particular, you are welcome to check out my own android code where I got them working: https://github.com/mgerhardy/caveexpress (https://github.com/mgerhardy/caveexpress) - or the direkt link: https://github.com/mgerhardy/caveexpress/blob/master/android-project/src/org/base/game/BaseGameAdsActivity.java (https://github.com/mgerhardy/caveexpress/blob/master/android-project/src/org/base/game/BaseGameAdsActivity.java) (I'm activating them them JNI - so you won't find the calling code on the java side, but here: https://github.com/mgerhardy/caveexpress/blob/master/src/modules/common/ports/Android.cpp (https://github.com/mgerhardy/caveexpress/blob/master/src/modules/common/ports/Android.cpp)
_______________________________________________
SDL mailing list
http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org (http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org)
--
http://www.caveproductions.org (http://www.caveproductions.org)[/quote]
Timodor
2016-09-21 06:07:20 UTC
Permalink
Also needs Global Variables.

InterstitialAd mInterstitialAd;

Loading...