我一步一步地遵循了这个教程,我设法放了广告横幅,但是没有得到插页式广告。 enter link description here
屏幕仍然是黑色,没有任何显示,没有加载或其他东西。
我认为我的AndroidManifest是正确的,因为它已经使用了横幅,所以我把AndroidLauncher
和.java放到我的项目中:
AndroidLauncher
/* My packages and imports */
public class AndroidLauncher extends AndroidApplication implements AdsController{
private static final String INTERSTITIAL_UNIT_ID = "My unit ID";
InterstitialAd interstitialAd;
@Override
protected void onCreate (Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
AndroidApplicationConfiguration config = new AndroidApplicationConfiguration();
View gameView = initializeForView(new Puzle(this), config);
setupAds();
}
public void setupAds() {
interstitialAd = new InterstitialAd(this);
interstitialAd.setAdUnitId(INTERSTITIAL_UNIT_ID);
AdRequest.Builder builder = new AdRequest.Builder();
AdRequest ad = builder.build();
interstitialAd.loadAd(ad);
}
public void showInterstitialAd(final Runnable then) {
runOnUiThread(new Runnable() {
@Override
public void run() {
if (then != null) {
interstitialAd.setAdListener(new AdListener() {
@Override
public void onAdClosed() {
Gdx.app.postRunnable(then);
AdRequest.Builder builder = new AdRequest.Builder();
AdRequest ad = builder.build();
interstitialAd.loadAd(ad);
}
});
}
interstitialAd.show();
}
});
}
@Override
public boolean isWifiConnected() {
ConnectivityManager cm = (ConnectivityManager) getSystemService(Context.CONNECTIVITY_SERVICE);
NetworkInfo ni = cm.getNetworkInfo(ConnectivityManager.TYPE_WIFI);
return (ni != null && ni.isConnected());
}
}
.java我的项目(根据手册,您必须将调用放在render方法上,如下所示:)
public void render() {
// TODO Auto-generated method stub
Gdx.gl.glClearColor(0.2f,0.2f,0.2f,1);
Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT);
if (adsController != null)
{
//System.out.println(adsController);
//if (adsController.isWifiConnected()) {
adsController.showInterstitialAd(new Runnable() {
@Override
public void run() {
System.out.println("Interstitial app closed");
Gdx.app.exit();
}
});
} else {
System.out.println("Interstitial ad not (yet) loaded");
}
//}
}
如果我显示System.out.println (ads Controller);
为我安排以下消息:Interstitial ad not (yet) loaded
没有编译错误或任何东西,但是当我玩游戏时,所有黑屏都停留并且什么都不做。
请任何帮助!!
答案 0 :(得分:0)
我不确定,但我认为您的屏幕仍然是黑色的,并且由于AndroidLauncher中的这一行没有任何反应:
View gameView = initializeForView(new Puzle(this), config);
由于这是插页式广告,我认为以后无需捕捉返回的视图以处理布局(只有在我们讨论横幅广告时才需要这样做。)
而不是上面的代码行尝试放置:
initialize(new Puzle(this), config);