Android 无法为Google Play版本集成admob Interstitual

Android 无法为Google Play版本集成admob Interstitual,android,admob,interstitial,Android,Admob,Interstitial,这是我第一次为我的android应用程序执行中间广告。我在整合方面遇到了一个问题,我遵循了官方的谷歌移动广告SDK教程,但我仍然不明白的是,如何准备首次发布?我只是想设置广告并上传到商店 是否有一些错误或我有一些误解?广告甚至没有出现 interstitial = new InterstitialAd(this); interstitial.setAdUnitId("myunitid"); AdRequest adRequest = new AdRequest.Bui

这是我第一次为我的android应用程序执行中间广告。我在整合方面遇到了一个问题,我遵循了官方的谷歌移动广告SDK教程,但我仍然不明白的是,如何准备首次发布?我只是想设置广告并上传到商店

是否有一些错误或我有一些误解?广告甚至没有出现

 interstitial = new InterstitialAd(this);
      interstitial.setAdUnitId("myunitid");

      AdRequest adRequest = new AdRequest.Builder().build();

      interstitial.loadAd(adRequest);
      displayInterstitial();

}

public void displayInterstitial() {
        if (interstitial.isLoaded()) {
            interstitial.show();
        }
    }
这是清单文件的一部分

  <meta-data
                android:name="com.google.android.gms.version"
                android:value="@integer/google_play_services_version" />
            <!-- Activity required to show ad overlays. -->
            <activity
                android:name="com.google.android.gms.ads.AdActivity"
                android:configChanges="keyboard|keyboardHidden|orientation|screenLayout|uiMode|screenSize|smallestScreenSize" />

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

Android Studio o Eclipse

安卓工作室:

添加依赖项

dependencies {
        compile fileTree(dir: 'libs', include: ['*.jar'])
        compile 'com.android.support:appcompat-v7:21.0.0'
        compile 'com.google.android.gms:play-services:7.0.0'
    }
在清单中添加权限

<!-- Include required permissions for Google Mobile Ads to run-->
    <uses-permission android:name="android.permission.INTERNET"/>
    <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>

也将此添加到清单中

 <!--This meta-data tag is required to use Google Play Services.-->
    <meta-data android:name="com.google.android.gms.version"
    android:value="@integer/google_play_services_version" />

     <!--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" />

文件string.xml

 <string name="banner_ad_unit_id">ca-app-pub-3940256099942544/6300978111</string>
ca-app-pub-3940256099942544/630978111

代码>

除了JoeDouLujun告诉你的还有一些事情要考虑。

displayInterstitial();
应该在应用程序中的某个点调用,当它执行一些有趣的操作或完成一个主要操作时。例如,用户输入大量文本并按done

done.setonClickListener(new View.OnClickListener(){
public void onClick(View v) {
displayinterstitial();
}});
当用户正在快速移动或试图通过按backpress键来避开您的广告或互联网连接速度较慢时,您应该处理这种情况

public void displayInterstitial() {
    if (interstitial.isLoaded()) {
        interstitial.show();
    }else{
//Do something here that will loadad and show a video, an image or a toast while you wait for your ad to load to then try to show interstitial again. 
}}

发布你的清单文件我已经从我的清单和gradle中添加了额外的代码。谢谢,但我有一个测试间隙广告显示,即使我设置了AdRequest AdRequest=new AdRequest.Builder().build();设置我的真实单位id。我可以上传到商店吗?
public void displayInterstitial() {
    if (interstitial.isLoaded()) {
        interstitial.show();
    }else{
//Do something here that will loadad and show a video, an image or a toast while you wait for your ad to load to then try to show interstitial again. 
}}