2011-06-09 47 views
2

我想在我的apk的底部放置一個admob廣告,但廣告從不顯示,並且在我的apk中沒有佈局xml,佈局是由gameview類建立,如何在Android的底部放置admob廣告,而不使用佈局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); 

回答

-1

您是否使用正確的測試設備ID?檢查logcat日誌(標記「廣告」),應該有一行說:

Ads: To get test ads on this device, call adRequest.addTestDevice("xyz"); 
相關問題