开发者

how to place admob ad at the bottom in android,without using layout xml

I want to place an admob ad at the bottom of my apk, but the ad never show, and there is no layout xml in my apk,the layout is build up by an gameview class,

LogCat says:onFailedToReceiveAd(Ad request successful,but no ad returned due to lack of ad inventory)

here is my code

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);


Are you using the correct test device id? Check the logcat log (tag "Ads"), there should be a line saying:

Ads: To get test ads on this device, call adRequest.addTestDevice("xyz");
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜