[英]Interstitial ad not being loaded?
I just created a Interstitial add in my test app. 我刚刚在测试应用中创建了一个非页内广告添加。 Went fairly easy, but now I want to add one to my main application and I cannot seem to load it.
相当容易,但是现在我想在主应用程序中添加一个,但似乎无法加载它。
This is what my android launcher looks like: 这是我的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!");
}
}
});
}
/..
I simply call a interface method in the show
method of my menuScreen to run the same method in the AndroidLauncher. 我只需在menuScreen的
show
方法中调用接口方法即可在AndroidLauncher中运行相同的方法。
resolver.displayInterstitialAd();
It's basically the same as my working test app but there I load the interstitial by pressing a button. 它基本上与我的工作测试应用程序相同,但是我在其中通过按下按钮加载了插页式广告。
This is my manifest: 这是我的清单:
<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>
The only things that are different is that my test app is in portrait mode and it has been uploaded a while ago but remains as a testing app and not published. 唯一不同的是我的测试应用程序处于纵向模式,并且它已经上传了一段时间,但仍保留为测试应用程序且未发布。 My current app has just been uploaded for testing these ads and the play store.
我当前的应用刚刚上传,用于测试这些广告和Play商店。 The play store works fine.
Play商店运作良好。 I also changed the ad ID to the correct ID I got on the Admob website.
我还将广告ID更改为在Admob网站上获得的正确ID。
Add the following in manifest file 在清单文件中添加以下内容
<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>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.