0

I have integrated Admob native ads. I have used same adUnitId in multiple screen to load native ads. In most of the screen my code is working fine but in some screen onAdLoaded overridden method is calling but ads is not displaying. I am using below code to native ads.

 nativeExpressAdView.setAdListener(new AdListener() {
                @Override
                public void onAdFailedToLoad(int i) {
                    super.onAdFailedToLoad(i);
                    nativeExpressAdView.setVisibility(View.GONE);
                }

                @Override
                public void onAdLeftApplication() {
                    super.onAdLeftApplication();
                    nativeExpressAdView.setVisibility(View.GONE);
                }

                @Override
                public void onAdLoaded() {
                    super.onAdLoaded();
                    nativeExpressAdView.setVisibility(View.VISIBLE);
                }


nativeExpressAdView.loadAd(new AdRequest.Builder().build());
                nativeExpressAdView.setVisibility(View.VISIBLE);

View of Nativeexpressview

<com.google.android.gms.ads.NativeExpressAdView
    android:id="@+id/nativeExpressAdView"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_gravity="center"
    app:adSize="300x250"
    android:layout_marginTop="@dimen/card_margin"
    app:adUnitId="@string/ad_unit_id"/>

onAdLoaded() method is firing but ads is not loading. Can any one pls help me to identify the issue.

Chandan Wadhwa
  • 196
  • 2
  • 13
  • you must be getting some error in your logs, check closely. I also faced similar issues recently which was due to network error – Ezio Feb 20 '17 at 09:22
  • I didn't see any error in logs. Could you pls tell me how you resolved the similar issue. – Chandan Wadhwa Feb 20 '17 at 09:38
  • Check that the View has enough space to be displayed. In your case, the parent container must be at least 300dp wide and 250dp high. Check : http://stackoverflow.com/questions/21848532/not-enough-space-to-show-ad-admob – Gordak Feb 20 '17 at 09:53
  • Thanks buddy issue was with view size. I have resolved issue for some screen and working on for rest. – Chandan Wadhwa Feb 20 '17 at 10:51

1 Answers1

-1

After you show an add always bring the banner to front nativeExpressAdView.bringToFront() I do that in onresume as well.

Galeen
  • 169
  • 1
  • 8
  • Why the downvote, please explain? How about your screen is Frame, Relative, Coordinator or similar Layout and you have dinamically changed views? How about you have a view/s on top of your ad? – Galeen Sep 28 '17 at 06:35