我想在我的apk底部放置一个admob广告,但广告从未显示过,而且我的apk中没有布局xml,布局是由游戏视图类构建的,
LogCat说:onFailedToReceiveAd(广告请求成功,但由于广告资源不足而没有返回广告)
这是我的代码
gameView = new GameView(this, display.getWidth(), display.getHeight());
setContentView(gameView);
RelativeLayout viewLayout = new RelativeLayout(GameActivity.this);
RelativeLayout.LayoutParams flLP2 = new RelativeLayout.LayoutParams(
RelativeLayout.LayoutParams.WRAP_CONTENT, RelativeLayout.LayoutParams.WRAP_CONTENT);
// Create the adView
AdView adView = new AdView(this, AdSize.BANNER, "xxxxxx");
// Add the adView to it
viewLayout.addView(adView,flLP2);
// Initiate a generic request to load it with an ad
AdRequest adTest = new AdRequest();
adTest.addTestDevice("xxxxxxxxxx");
adView.loadAd(adTest);
答案 0 :(得分:-1)
您使用的是正确的测试设备ID吗?检查logcat日志(标签“Ads”),应该有一行说:
Ads: To get test ads on this device, call adRequest.addTestDevice("xyz");