Admob的插页式广告将不显示 [英] Admob interstitial ad won't display

查看:315
本文介绍了Admob的插页式广告将不显示的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我曾经对我的未来的应用程序显示AdMob的旗帜,我想给一个尝试到插播式广告。

I used to display AdMob banner on my future apps, and I'd like to give a try to the interstitial ads.

我检查了AdMob的SDK的实施,我复制他们的榜样来源,因为它正是我想要的(如所示的间质活动时推出)。

I checked the AdMob SDK for implementation, and I copied their example source because it was exactly what I want (i.e. the interstitial shown when the activity launch).

我试图在模拟器和我的银河,没有广告已经显示出来。

I tried it on emulator and on my Galaxy, no ad has been displayed.

下面是源$ C ​​$ C:

Here is the source code:

public class Asscreed extends Activity {
    private InterstitialAd interstitial;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_asscreed);

        // Create the interstitial.
        interstitial = new InterstitialAd(this);
        interstitial.setAdUnitId("ca-app-pub-6046034785851961/xxxxxx");

        // Create ad request.
        AdRequest adRequest = new AdRequest.Builder().build();

        // Begin loading your interstitial.
        interstitial.loadAd(adRequest);
    }

    // Invoke displayInterstitial() when you are ready to display an interstitial.
    public void displayInterstitial() {
        if (interstitial.isLoaded()) {
            interstitial.show();
        }
    }
}

的进口是正常和谷歌播放过程中的服务库是进口的。

The imports are OK and the Google Play Services library is of course imported.

我用这个例子:的AdMob Android的指南 - 插播式广告

有人能告诉我什么是错在我的code?

Could someone tell me what's wrong in my code?

推荐答案

您应该等待要加载的广告。只有这样,你可以叫 displayInterstial()的方法,这将显示广告。

You should wait for the ad to be loaded. Only then, you can call displayInterstial() method, which would show the ad.

您可以注册一个监听器,这将让你知道什么时候加载完成。

You can register for a listener, that will let you know when the loading is done.


interstitial.setAdListener(new AdListener(){
          public void onAdLoaded(){
               displayInterstitial();
          }
});

这篇关于Admob的插页式广告将不显示的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆