【发布时间】:2014-02-19 18:40:24
【问题描述】:
问题是:广告没有在第一次请求时显示,但在发出第二次请求时,它显示正确。在它发出第二个请求前大约 2 秒,第一个请求的广告出现了。有任何想法吗? 谢谢,
编辑:我将重力改为 TOP,现在它第一次显示,但只显示广告的上半部分,奇怪,有什么想法吗?
@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();
}
【问题讨论】:
-
另外,当我点击任何按钮或后退按钮时,在活动退出之前,广告会正确显示