2015-08-08 69 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