【问题标题】:android InterstitialAd not showingandroid InterstitialAd 未显示
【发布时间】:2012-11-28 15:21:19
【问题描述】:

我的应用使用了以下 InterstitialAd,以下是从 google 示例中获得的标准编码。但是,我想问一下为什么没有广告显示? (应用正确显示吐司:在 ReceiveAd 上)

我的 main_first_page 布局底部也有一个广告横幅。这会影响 InterstitialAd 吗?

谢谢!!

public class StartUp extends Activity implements AdListener {

    private InterstitialAd interstitialAd;   
    AdView adView;
    private static final String LOG_TAG = "IQ!";

       public static final  String MY_PUBLISHER_ID = "abc"; 

       @Override
       public void onCreate(Bundle savedInstanceState) 
       {
          super.onCreate(savedInstanceState); // call the superclass's method
          setContentView(R.layout.main_first_page); // inflate the GUI


          Button ButtonNum= (Button) findViewById(R.id.buttonB);
          Button ButtonHeart= (Button) findViewById(R.id.buttonC);
          Button ButtonMath= (Button) findViewById(R.id.buttonD);             

           interstitialAd = new InterstitialAd(this, MY_PUBLISHER_ID); // Create an ad.  
              interstitialAd.setAdListener(this); // Set the AdListener.
              AdRequest adRequest = new AdRequest();
              adRequest.addTestDevice(AdRequest.TEST_EMULATOR);
              interstitialAd.loadAd(adRequest);       

              if (interstitialAd.isReady()) {interstitialAd.show();} 
              else {Log.d(LOG_TAG, "Interstitial ad was not ready to be shown.");}            
       }
/** Called when an ad is clicked and about to return to the application. */
          @Override
          public void onDismissScreen(Ad ad) {
            Log.d(LOG_TAG, "onDismissScreen");
            Toast.makeText(this, "onDismissScreen", Toast.LENGTH_SHORT).show();
          }

/** Called when an ad was not received. */
          @Override
          public void onFailedToReceiveAd(Ad ad, AdRequest.ErrorCode error) {
            String message = "onFailedToReceiveAd (" + error + ")";
            Log.d(LOG_TAG, message);
            Toast.makeText(this, message, Toast.LENGTH_SHORT).show();
          }

/** Called when an ad is clicked and going to start a new Activity that will
           * leave the application (e.g. breaking out to the Browser or Maps
           * application).
           */
          @Override
          public void onLeaveApplication(Ad ad) {
            Log.d(LOG_TAG, "onLeaveApplication");
            Toast.makeText(this, "onLeaveApplication", Toast.LENGTH_SHORT).show();
          }

/* Called when an Activity is created in front of the app (e.g. an
           * interstitial is shown, or an ad is clicked and launches a new Activity).
           */         
        @Override
        public void onPresentScreen(Ad arg0) {
            // TODO Auto-generated method stub          
        }

/** Called when an ad is received. */
        @Override
          public void onReceiveAd(Ad ad) {
            Log.d(LOG_TAG, "onReceiveAd");
            Toast.makeText(this, "onReceiveAd", Toast.LENGTH_SHORT).show();
        }

【问题讨论】:

    标签: android layout admob interstitial


    【解决方案1】:

    插页式广告需要一些时间才能加载。您正在检查它是否在加载后直接准备好,所以它肯定还没有准备好。检查您的 logcat 输出,您可能会看到您记录的 "Interstitial ad was not ready to be shown." 消息。

    在调用 onReceiveAd() 回调之前,插页式广告不会准备就绪。您可以安全地将interstitialAd.show() 放在onReceiveAd() 回调中,插页式广告会立即显示。

    另一个用例可能是您希望稍后显示插页式广告,例如游戏关卡的结束。在这种情况下,您需要在关卡开始时预加载插页式广告,并在关卡结束时查看isReady 标志以查看插页式广告是否已准备好。

    【讨论】:

    • 非常感谢您的帮助!我没有想过将 interstitialAd.show() 放在 onReceiveAd() 回调中,这样插页式广告就会立即显示!它有效!
    • 如果您预加载插页式广告(这是减少加载延迟的好方法),但请注意它会影响您的点击率(点击率)。点击率计算为 Number_Of_Clicks/Number_Of_Requests。如果您预加载它但从不显示它(如果玩家没有到达关卡的末尾),那么尽管已经请求,但用户无法点击。 Google 和 Advertiser 使用 CTR 来优化他们发送到您的应用的广告系列。因此,如果您确定(或几乎确定)最终会显示它,我建议您预加载它。我就是这么做的。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多