2015-08-08 67 views
0

我剛剛在我的測試應用程序中創建了插頁式添加。相當容易,但現在我想添加一個到我的主應用程序,我似乎無法加載它。插頁式廣告未被加載?

這是我的Android啓動的樣子:

../ 

    protected void onCreate (Bundle savedInstanceState) { 
     super.onCreate(savedInstanceState); 
     AndroidApplicationConfiguration config = new AndroidApplicationConfiguration(); 
     initialize(new GameOfClaws(this), config); 

     //initialize ads... 
     interstitialAd = new InterstitialAd(this); 
     interstitialAd.setAdUnitId(getString(R.string.interstitial_ad)); 
     //Load add 
     requestNewInterstitial(); 

     interstitialAd.setAdListener(new AdListener() { 
      @Override 
      public void onAdClosed() { 
       super.onAdClosed(); 
       requestNewInterstitial(); 
      } 
      @Override 
      public void onAdLoaded() 
      { 
       Gdx.app.log(TAG, "Ad loaded!"); 
       //interstitialAd.show(); 
      } 
     }); 
    } 

    private void requestNewInterstitial() 
    { 
     AdRequest adRequest = new AdRequest.Builder() 
       .build(); 
     interstitialAd.loadAd(adRequest); 
    } 

    @Override 
    public void displayInterstitialAd() { 
     runOnUiThread(new Runnable() { 
      @Override 
      public void run() { 
       if (interstitialAd.isLoaded()) { 
        interstitialAd.show(); 
       } 
       else 
       { 
        Gdx.app.log("MainActivity", "Add not loaded!"); 
       } 

      } 
     }); 
    } 

/.. 

我只需調用一個接口方法在我menuScreen的show方法運行在AndroidLauncher同樣的方法。

resolver.displayInterstitialAd(); 

它基本上與我的工作測試應用程序相同,但在那裏我通過按下按鈕加載插頁式廣告。

這是我的清單:

<uses-sdk android:minSdkVersion="9" android:targetSdkVersion="22" /> 
<uses-permission android:name="android.permission.INTERNET" /> 
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" /> 
<uses-permission android:name="android.permission.GET_ACCOUNTS" /> 

<application 
    android:allowBackup="true" 
    android:icon="@drawable/ic_launcher" 
    android:label="@string/app_name" 
    android:theme="@style/GdxTheme" > 

    <meta-data android:name="com.google.android.gms.games.APP_ID" 
     android:value="@string/app_id" /> 

    <meta-data android:name="com.google.android.gms.version" 
     android:value="@integer/google_play_services_version"/> 

    <activity 
     android:name="com.madmenyo.gameofclaws.android.AndroidLauncher" 
     android:label="@string/app_name" 
     android:screenOrientation="landscape" 
     android:configChanges="keyboard|keyboardHidden|orientation|screenSize"> 
     <intent-filter> 
      <action android:name="android.intent.action.MAIN" /> 
      <category android:name="android.intent.category.LAUNCHER" /> 
     </intent-filter> 
    </activity> 
</application> 

唯一的東西是不同的是,我的測試應用程序是在縱向模式下,它已經在不久前載,但仍作爲測試應用程序,並未發佈。我目前的應用剛剛上傳,用於測試這些廣告和Play商店。 Play商店運作良好。我還將廣告ID更改爲Admob網站上提供的正確ID。

回答

1

添加下面的清單文件

<activity 
     android:name="com.google.android.gms.ads.AdActivity" 
     android:configChanges="keyboard|keyboardHidden|orientation|screenLayout|uiMode|screenSize|smallestScreenSize" 
     android:screenOrientation="portrait" 
     android:theme="@android:style/Theme.Translucent" > 
    </activity> 
+0

但它是如何在我的測試應用程序工作,而這一點?我有一個佈局'xml'我認爲它是用於橫幅添加的,所以我沒有在任何地方引用它。 – Madmenyo