Admob广告没有显示

时间:2015-11-02 08:52:23

标签: android admob

在我的Android应用中,TEST广告显示成功但真正的广告没有显示。 我在logcat中收到此错误: -

 11-02 13:14:21.129: W/Ads(6341): There was a problem getting an ad response. ErrorCode: 0
 11-02 13:14:21.133: W/Ads(6341): Failed to load ad: 0

有人能告诉我为什么会这样吗?

我的广告代码:

来自MainActivity的

我叫

     AdUtils.showAd(context);

然后我的showAd就是这样:

public static void showAd(Context context) {
    try {
        isGooglePlayServiceAvailable = Utils.isGooglePlayServiceAvailable(context);
        if (isGooglePlayServiceAvailable) {
                showInterstitalAd(context);
            } 
         else {

        }
    } catch (ClassCastException e) {
        e.printStackTrace();
        return;
    }

}

public static void showInterstitalAd(Context context) {
    try {
        final InterstitialAd interstitial = new InterstitialAd(context);
        interstitial.setAdUnitId(Constants.INTERSTITIAL_AD_ID);
        AdRequest adRequest = new AdRequest.Builder()
        .build();
        interstitial.loadAd(adRequest);
        interstitial.setAdListener(new AdListener() {
            public void onAdLoaded() {
                super.onAdLoaded();
                if (interstitial.isLoaded()) {
                    interstitial.show();
                }
            };
        });
    } catch (Exception e) {
        Log.i("TEST", "Ad Mob execpt");
        e.printStackTrace();
    }
}

0 个答案:

没有答案