1
我試圖升級到谷歌播放服務Admob版本,但我似乎無法找到正確的方式顯示插頁式廣告嘗試幾天後,橫幅視圖似乎顯示正常,其唯一的插頁式一個問題。admob插頁式廣告沒有顯示與谷歌播放服務?
這是我參考google play服務後的當前代碼。
private InterstitialAd interstitial;
public void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
AdView adView = (AdView)this.findViewById(R.id.adView);
AdRequest adRequest = new AdRequest.Builder()
.addTestDevice(AdRequest.DEVICE_ID_EMULATOR)
.addTestDevice("TEST_DEVICE_ID")
.build();
adView.loadAd(adRequest);
// Create the interstitial.
interstitial = new InterstitialAd(this);
interstitial.setAdUnitId("XXXXXXXXXXXXXXXXXXX");
// Create ad request.
AdRequest adRequestIN = new AdRequest.Builder().build();
// Begin loading your interstitial.
interstitial.loadAd(adRequestIN);
}
// 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-sdk
android:minSdkVersion="8"
android:targetSdkVersion="17" />
<supports-screens android:smallScreens="true"
android:normalScreens="true" android:largeScreens="true"
android:anyDensity="true" />
<uses-permission android:name="android.permission.INTERNET"/>
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
<application
android:allowBackup="true"
android:icon="@drawable/logo"
android:label="@string/app_name"
android:theme="@style/AppTheme"
android:hardwareAccelerated="true"
>
<activity android:name="com.google.android.gms.ads.AdActivity"
android:configChanges="keyboard|keyboardHidden|orientation|screenLayout|uiMode|screenSize|smallestScreenSize"
android:theme="@android:style/Theme.Translucent"/>
<meta-data android:name="com.google.android.gms.version"
android:value="@integer/google_play_services_version"
/>
我將它添加到onCreate和onStart因爲我希望它顯示應用程序啓動時,仍然沒有好處。 – 2014-09-21 21:59:33
檢查我的編輯並在oncreate中添加此代碼 – Tony 2014-09-22 09:26:33
是的,謝謝你,我意識到我錯過了setAdListener,你的代碼也完美工作。 – 2014-09-22 15:37:49