如何显示插播式广告? [英] How to show interstitial ads?

查看:98
本文介绍了如何显示插播式广告?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何显示插播式广告?

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        //Log.v("SDL", "onCreate()");
        super.onCreate(savedInstanceState);

        setContentView(R.layout.main);

        interstitial = new InterstitialAd(this);
        interstitial.setAdUnitId("ca-app-pub-2188258702xxxxxxxxxxx");


        AdRequest adRequest = new AdRequest.Builder()
            .addTestDevice(AdRequest.DEVICE_ID_EMULATOR)
                .addTestDevice("XXXXXXXXXXXXX")
                .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);

    }




public void displayInterstitial() {
    if (interstitial.isLoaded()) {
      interstitial.show();
    }
  }

我用SDL2为Android,而我试图证明插播式广告在我的应用程序,但它并不显示。如果我评论这一行的setContentView(mLayout);并调用displayinterstitial()所有工作正常,但所有的SDL本地内容(屏幕是黑的): - )

I use sdl2 for android, and I trying to show interstitial ads in my app, but it's doesn't show. If I comment this line setContentView(mLayout); and call displayinterstitial() all works fine, except all sdl native content(screen is black):-)

和问题是如何使工作插播式广告与SDL在Android?

And question is How to make work interstitial ads with sdl on android?

全SDLActivity code在这里: http://pastebin.com/DsRRtRS5

Full SDLActivity code here: http://pastebin.com/DsRRtRS5

推荐答案

看来你还没有提到:displayInterstitial()中的onCreate()方法的任何地方,你肯定code执行到displayInterstitial()方法?

It seems that you have not mentioned: displayInterstitial(), anywhere in onCreate() Method, You sure the code execution reaches the displayInterstitial() method?

此外,您将有一定的地步广告后的code的回报已经完全加载并可以显示。如:

Also, you will have some point where the code returns after the ad has been fully loaded and ready to display. Such as:

@Override
  public void onReceiveAd(Ad ad) {
    Log.d("OK", "Received ad");
    if (ad == interstitial) {
      interstitial.show();
    }
  }

这篇关于如何显示插播式广告?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆