1

私のアプリは次の 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();
        }
4

1 に答える 1

6

インタースティシャルの読み込みには時間がかかります。ロードした直後に準備ができているかどうかを確認しているので、まだ準備ができていないことは間違いありません。logcat の出力を確認してください"Interstitial ad was not ready to be shown."。ログに記録したメッセージが表示される可能性があります。

onReceiveAd()インタースティシャルは、コールバックが呼び出されるまで準備ができていません。interstitialAd.show()コールバック内に安全に配置できonReceiveAd()、インタースティシャルがすぐに表示されます。

もう 1 つのユース ケースは、ゲーム レベルの終了時など、後でインタースティシャルを表示する場合です。その場合、レベルの開始時にインタースティシャルをプリロードし、レベルisReadyの終了時にフラグを参照して、インタースティシャルがまだ準備できているかどうかを確認します。

于 2012-11-28T23:42:01.160 に答える