综合开发

Admob + Andengine appears only on the second application

微信扫一扫,分享到朋友圈

Admob + Andengine appears only on the second application

the issue is: the ad doesn’t show on first request, but when it makes the second request, it shows right. About 2 seconds before it make the second request, the ad of the first request shows up. Any ideas? Thanks,

EDIT:I changed the gravity to TOP, and now it shows on the first time, but is showing just the top half of the ad, bizarre, any ideas?

@Override
protected void onSetContentView() {
if(adView != null){
return;
}
final FrameLayout frameLayout = new FrameLayout(this);
final FrameLayout.LayoutParams frameLayoutLayoutParams =
new FrameLayout.LayoutParams(FrameLayout.LayoutParams.MATCH_PARENT,
FrameLayout.LayoutParams.MATCH_PARENT);
final FrameLayout.LayoutParams adViewLayoutParams =
new FrameLayout.LayoutParams(FrameLayout.LayoutParams.MATCH_PARENT,
FrameLayout.LayoutParams.WRAP_CONTENT,
Gravity.CENTER_HORIZONTAL|Gravity.BOTTOM);
adView = new AdView(this);
adView.setAdSize(AdSize.BANNER);
adView.setAdUnitId(getResources().getString(R.string.ad_unit_id));
adView.setAdListener(new ToastAdListener(this));
adView.loadAd(new AdRequest.Builder().build());
this.mRenderSurfaceView = new RenderSurfaceView(this);
mRenderSurfaceView.setRenderer(mEngine,this);
final android.widget.FrameLayout.LayoutParams surfaceViewLayoutParams =
new FrameLayout.LayoutParams(super.createSurfaceViewLayoutParams());
frameLayout.addView(this.mRenderSurfaceView, surfaceViewLayoutParams);
frameLayout.addView(adView, adViewLayoutParams);
this.setContentView(frameLayout, frameLayoutLayoutParams);
}
@Override
protected void onPause() {
if(adView!=null){
adView.pause();
}
super.onPause();
}
@Override
protected void onResume() {
super.onResume();
if(adView!=null){
adView.resume();
}
}
@Override
protected void onDestroy() {
if(adView!=null){
adView.destroy();
}
super.onDestroy();
}

方便快捷给 PDF 加水印

上一篇

麦肯锡:开启全速数字化营销打造银行新的增长工厂

下一篇

你也可能喜欢

评论已经被关闭。

插入图片

热门栏目

Admob + Andengine appears only on the second application

长按储存图像,分享给朋友