我已经fishished一个Android项目并设置了admob广告,但它没有工作,尝试在模拟器和手机上.那么如何检查admob是否有效?
码:
admobView = new AdView(this, AdSize.BANNER, "Top secret");
RelativeLayout.LayoutParams lp = new RelativeLayout.LayoutParams(
RelativeLayout.LayoutParams.WRAP_CONTENT,
RelativeLayout.LayoutParams.WRAP_CONTENT);
lp.addRule(RelativeLayout.ALIGN_PARENT_BottOM);
admobView.setLayoutParams(lp);
RelativeLayout layout = new RelativeLayout(this);
layout.addView(renderView);
layout.addView(admobView);
admobView.loadAd(new AdRequest());
setContentView(layout);
该应用程序工作正常(renderView),但我不知道adView是否这样做.是的,admob ID是对的.
解决方法:
您也可以在模拟器中测试AdMob.您需要测试模式才能实现这一目标.有关详细信息,请参阅教程步骤6:How to integrate Admob into your app
如果在LogCat中找不到设备ID,也可以尝试添加TEST_EMULATOR常量:
request.addTestDevice(AdRequest.DEVICE_ID_EMULATOR);