【发布时间】:2014-07-23 10:42:39
【问题描述】:
如何展示插页式广告?
@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 for android,并尝试在我的应用中显示插页式广告,但它没有显示。如果我评论这一行 setContentView(mLayout);并调用 displayinterstitial() 一切正常,除了所有 sdl 原生内容(屏幕为黑色):-)
问题是如何在 android 上使用 sdl 制作插页式广告?
完整的 SDLActivity 代码在这里: http://pastebin.com/DsRRtRS5
【问题讨论】:
-
嘿... @user1888143... Google 的插页式广告?还是 MillennialMedia 或 AdMob?
标签: android admob sdl-2 interstitial