插页式广告不会显示

Interstitial Ad Will Not Display

我有一个未发布的 Android 应用程序,我使用 AdMob Interstitial Guide and the ads did not initially show. So, thereafter I referenced Admob interstitial ad won't display 插入了插页式广告,我添加了这个:

interstitial.setAdListener(new AdListener(){
          @Override
          public void onAdLoaded(){
               displayInterstitial();
          }
});

而不是仅使用 displayInterstitial() 加载添加。这样做之后它仍然不会显示广告。然后我引用了“Because Admob interstitial ads won't display”,但这并没有帮助,因为我已经将 .Builder().build() 添加到 new AdRequest

之后我引用了“How to show interstitial ads?" and that was not useful because I am testing on a real device and not an emulator, and it also just repeated what the Google Interstitial Guide (first link) showed me how to do. Then I finally looked at Interstitial Ad's Listener's onAdLoaded() won't run 并在我的清单中添加了 Internet 权限(我已经将 meta-data 属性 作为 [=20= 的子项添加到我的清单中]) 并尝试使用此代码来显示广告:

interstitial.setAdListener(new AdListener() {
    @Override
    public void onAdLoaded() {
        // TODO Auto-generated method stub
        super.onAdLoaded();
        interstitial.show();
    }
});

那也没用。

我有 2 个使用广告的活动(该应用有一个 MainActivity、一个 GameScreen activity 和一个 Redirect activity)

这里是MainActivity(除了涉及广告的代码,我已经排除了所有代码):

    public class MainActivity extends ActionBarActivity {

    private InterstitialAd interstitial;


    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);



        // Create the interstitial.
        interstitial = new InterstitialAd(this);
        interstitial.setAdUnitId("ca-app-pub-3171635XXXXXXXXX/XXXXXXXXXX");
        // Create ad request.
        AdRequest adRequest = new AdRequest.Builder().build();
        // Begin loading your interstitial.
        interstitial.loadAd(adRequest);

        interstitial.setAdListener(new AdListener() {
            @Override
            public void onAdLoaded() {
                super.onAdLoaded();
                interstitial.show();
            }
        });

    }

    // Invoke displayInterstitial() when you are ready to display an interstitial.
    public void displayInterstitial() {
        if (interstitial.isLoaded()) {
            interstitial.show();
        }
    }


}

这里是重定向activity(我已经排除了除广告相关代码之外的所有代码,与MainActivity的广告展示代码相同):

public class Redirect extends ActionBarActivity {


private InterstitialAd interstitial;


@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_redirect);


    // Create the interstitial.
    interstitial = new InterstitialAd(this);
    interstitial.setAdUnitId("ca-app-pub-317163XXXXXXXXXX/XXXXXXXXXX");
    // Create ad request.
    AdRequest adRequest = new AdRequest.Builder().build();
    // Begin loading your interstitial.
    interstitial.loadAd(adRequest);

    interstitial.setAdListener(new AdListener(){
        @Override
        public void onAdLoaded(){
            super.onAdLoaded();
            interstitial.show();
        }
    });       

}    

// Invoke displayInterstitial() when you are ready to display an interstitial.
public void displayInterstitial() {
    if (interstitial.isLoaded()) {
        interstitial.show();
    }
}

}

这是我的清单:

<?xml version="1.0" encoding="utf-8"?>

<uses-permission android:name="android.permission.INTERNET"/>

<application
    android:allowBackup="true"
    android:icon="@drawable/ic_launcher"
    android:label="@string/app_name"
    android:theme="@style/AppTheme" >
    <meta-data android:name="com.google.android.gms.version"
               android:value="@integer/google_play_services_version" />
    <activity
        android:name=".UI.MainActivity"
        android:label="@string/app_name"
        android:screenOrientation="landscape" >
        <intent-filter>
            <action android:name="android.intent.action.MAIN" />

            <category android:name="android.intent.category.LAUNCHER" />
        </intent-filter>
    </activity>
    <activity
        android:name=".UI.GameScreen"
        android:label="@string/title_activity_game_screen"
        android:screenOrientation="landscape"
        android:parentActivityName=".UI.MainActivity" >
        <meta-data
            android:name="android.support.PARENT_ACTIVITY"
            android:value="benyamephrem.tilt.UI.MainActivity" />
    </activity>
    <activity
        android:name=".UI.Redirect"
        android:label="@string/title_activity_redirect"
        android:screenOrientation="landscape"
        android:parentActivityName=".UI.GameScreen" >
        <meta-data
            android:name="android.support.PARENT_ACTIVITY"
            android:value="benyamephrem.tilt.UI.GameScreen" />
    </activity>
</application>

我对此进行了大量研究,但还没有想出任何有效的解决方案。我觉得我遗漏了一些小细节,但我目前不明白为什么这不起作用。

感谢任何帮助!

您的清单中缺少以下 activity:

<!--Include the AdActivity configChanges and theme. -->
<activity android:name="com.google.android.gms.ads.AdActivity"
android:configChanges="keyboard|keyboardHidden|orientation|screenLayout|uiMode|screenSize|smallestScreenSize"
android:theme="@android:style/Theme.Translucent" />