【问题标题】:Unable to integrate admob interstitial for googleplay release无法为 googleplay 版本集成 admob 插页式广告
【发布时间】:2015-05-22 15:01:31
【问题描述】:

这是我第一次为我的 Android 应用实施插页式广告。而且我在集成时遇到问题,我已经按照官方的 Google Mobile Ads 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" />

这就是我的毕业作品

 compile 'com.android.support:support-v4:22.1.1'
    compile 'com.google.android.gms:play-services:7.3.0'
    compile fileTree(dir: 'libs', include: ['*.jar'])

【问题讨论】:

  • 发布您的清单文件
  • 我从清单和 gradle 添加了额外的代码。

标签: android admob interstitial


【解决方案1】:

除了 josedlujan 告诉你的内容之外,还有一些事情需要考虑。

displayInterstitial();

应该在应用程序执行一些有趣的事情或完成主要操作时调用。例如,当用户输入大量文本并按下完成时。

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. 
}}

【讨论】:

    【解决方案2】:

    Android Studio 还是 Eclipse?

    Android 工作室:

    添加依赖

    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'
        }
    

    在 Manifest 中添加权限!

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

    文件字符串.xml

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

    【讨论】:

    • 谢谢,但我正在展示一个测试插页式广告,尽管我设置了 AdRequest adRequest = new AdRequest.Builder().build();并设置我的真实单位 ID。我可以上传到商店吗?
    猜你喜欢
    • 2020-09-25
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2020-09-21
    • 1970-01-01
    • 2018-01-03
    相关资源
    最近更新 更多