如何在libGDX中显示Admob interstitial

时间:2014-05-29 15:44:01

标签: java android libgdx admob

我的应用无法显示插页式广告。如果我使用测试设备ID运行应用程序,而不是向我显示谷歌的插页式测试窗口。但没有测试设备ID它没有显示任何东西。我做了同样的步骤,如整合smart_banner。我的应用显示了smart_banner但不显示插页式广告。我可能会使用错误的类...还存在插页式类,但我使用的是AdView类。我不知道有没有人知道在libgdx中包含插页式广告的好教程?

public class MainActivity extends AndroidApplication {

private AdView adView;
private AdView fullAdView;
private RelativeLayout layout;
private final String ADCODE = "XXX";
private final String FULLADCODE = "XXX";

@Override
public void onCreate(Bundle savedInstanceState) {
    ...

    // Create the layout
    layout = new RelativeLayout(this);

    // AdMob View 
    fullAdView = new AdView(this);
    fullAdView.setAdUnitId(FULLADCODE);
    fullAdView.setAdSize(AdSize.MEDIUM_RECTANGLE);

    View gameView = initializeForView(new FPGame(new RequestHandler(adView, fullAdView)), cfg);
    ...
    AdRequest fadRequest = new AdRequest.Builder().build();
    fullAdView.loadAd(fadRequest);

    fullAdView.setAdListener(new AdListener(){
        @Override
        public void onAdLoaded() {
            super.onAdLoaded();

            MainActivity.this.runOnUiThread(new Runnable(){

                @Override
                public void run() {
                    layout.requestLayout();
                }

            });
        }
    });

1 个答案:

答案 0 :(得分:1)

您应该使用InterstitialAd代替AdView班级 关注this tutorial