我在我的游戏中安装了广告, 但我的游戏用地表视图来显示图形。
我该如何从地表的视野中 " 进入" AdMob View?
<强 > EDIT2: 强 >
试图执行回调:
< 强度 > 主要活动性. class 强度 >
interface AdMobInterface {
public void HideAd();
public void ShowAd();
}
public class MainActivity extends Activity implements AdListener {
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
layout = new RelativeLayout(this);
engine = new Engine(this);
layout.addView(engine);
if(engine.IsDemoVersion) {
SetupAdMob();
}
setContentView(layout);
}
public void ShowAd() {
///Execute this from Engine.class
}
public void HideAd() {
///Execute this from Engine.class
}
private void SetupAdMob() {
String AdMobPublisherID = "XXXXXXXXXX";
adView = new AdView(this, AdSize.BANNER, AdMobPublisherID);
RelativeLayout.LayoutParams params = new RelativeLayout.LayoutParams(RelativeLayout.LayoutParams.FILL_PARENT, RelativeLayout.LayoutParams.WRAP_CONTENT);
params.addRule(RelativeLayout.ALIGN_PARENT_BOTTOM);
layout.addView(adView, params);
layout.bringChildToFront(layout.getChildAt(1));
adView.loadAd(new AdRequest());
}
}
< 强力 > 引擎. class 强 >
public class Engine extends SurfaceView implements
SurfaceHolder.Callback, SensorEventListener, AdMobInterface {
AdMobInterface AdMob;
public Engine(Context context, AdMobInterface admob) {
super(context);
AdMob = admob;
}
}