Interstitial Ads in my project

I followed this tutorial step by step, and I managed to put advertising banners, but do not get put Interstitial. enter link description here

What happens is that the screen remains black and nothing appears, does not load or something.

I assume that my AndroidManifest is correct because it has already worked with banners, so I put the AndroidLauncher and .java my project:

AndroidLauncher

/* My packages and imports */

public class AndroidLauncher extends AndroidApplication implements AdsController{

    private static final String INTERSTITIAL_UNIT_ID = "My unit ID";
    InterstitialAd interstitialAd;  

    @Override
    protected void onCreate (Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        AndroidApplicationConfiguration config = new AndroidApplicationConfiguration();
        View gameView = initializeForView(new Puzle(this), config);

        setupAds();
    }

    public void setupAds() {

        interstitialAd = new InterstitialAd(this);
        interstitialAd.setAdUnitId(INTERSTITIAL_UNIT_ID);

        AdRequest.Builder builder = new AdRequest.Builder();
        AdRequest ad = builder.build();
        interstitialAd.loadAd(ad);
    }

    public void showInterstitialAd(final Runnable then) {
           runOnUiThread(new Runnable() {
               @Override
               public void run() {
                   if (then != null) {
                       interstitialAd.setAdListener(new AdListener() {
                           @Override
                           public void onAdClosed() {
                               Gdx.app.postRunnable(then);
                               AdRequest.Builder builder = new AdRequest.Builder();
                               AdRequest ad = builder.build();
                               interstitialAd.loadAd(ad);
                           }
                       });
                   }
                   interstitialAd.show();
               }
           });
       }

    @Override
    public boolean isWifiConnected() {

        ConnectivityManager cm = (ConnectivityManager) getSystemService(Context.CONNECTIVITY_SERVICE);
        NetworkInfo ni = cm.getNetworkInfo(ConnectivityManager.TYPE_WIFI);

        return (ni != null && ni.isConnected());
    }


}

.java my project (According to the manual, you must put the call on the render method, as follows:)

public void render() {
    // TODO Auto-generated method stub
    Gdx.gl.glClearColor(0.2f,0.2f,0.2f,1);
    Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT);

    if (adsController != null)
    {
        //System.out.println(adsController);
        //if (adsController.isWifiConnected()) {
            adsController.showInterstitialAd(new Runnable() {
                @Override
                public void run() {
                        System.out.println("Interstitial app closed");
                        Gdx.app.exit();
                }
            });
} else {
            System.out.println("Interstitial ad not (yet) loaded");
        }
    //}

} 

if I show System.out.println (ads Controller); to console me the following message: Interstitial ad not (yet) loaded

No compile errors or anything, but when I play my game, all black screen stays and does nothing.

Please any help!!

Answers


I'm not sure but I think that your screen remains black and nothing happens due to this line in your AndroidLauncher:

View gameView = initializeForView(new Puzle(this), config);

Since this is an Interstitial Ad I think that there is no need to catch the returned view to work on layouts later (this is only needed when we talk about Banner Ads).

Instead of the above line of code try to put:

    initialize(new Puzle(this), config);

Need Your Help

Java get method on twilio

java jsp servlets get twilio

I am using Twilio API for doing few things in my application.

Parse error: syntax error, unexpected T_IF in C:\xampp\htdocs\ci_bc\application\controllers\user.php on line 55

php if-statement social-networking

Im creating a social network site and trying to create a function that will only allow 18 and over to register to the site. but I am getting this error: Parse error: syntax error, unexpected T_IF ...