gogoloi
gogoloi

Reputation: 667

Can't display adMob banners on my activity

I want to display ads on my activity. For this I added next lines on manifest:

<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />

<activity
        android:name="com.google.android.gms.ads.AdActivity"
        android:configChanges="keyboard|keyboardHidden|orientation|screenLayout|uiMode|screenSize|smallestScreenSize"
        android:theme="@android:style/Theme.Translucent" />

on activity xml have:

<com.google.android.gms.ads.AdView
    android:id="@+id/adView"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_centerHorizontal="true"
    android:layout_alignParentBottom="true"
    ads:adSize="BANNER"
    ads:adUnitId="@string/banner_ad">
</com.google.android.gms.ads.AdView>

and on activity:

private AdView mAdView;
....
 mAdView = (AdView) findViewById(R.id.adView);
 if (Utils.IS_ADMOB_IN_DEBUG) {
        adRequest = new AdRequest.Builder().
                addTestDevice(AdRequest.DEVICE_ID_EMULATOR)
                .addTestDevice("00000F800094960000B45A000000D22")
                .build();
    } else {
        adRequest = new AdRequest.Builder().build();
    }
mAdView.setAdListener(new AdListener() {
        @Override
        public void onAdLoaded() {
        }

        @Override
        public void onAdClosed() {
        }

        @Override
        public void onAdFailedToLoad(int errorCode) {
        }

        @Override
        public void onAdLeftApplication() {
        }

        @Override
        public void onAdOpened() {
            super.onAdOpened();
        }
    });

    mAdView.loadAd(adRequest);

I have added unit Ad ID on string banner_ad.

Despite my efforts, I can not show anything on adView. All work perfect for debug mode. Just on debug mode.

Any suggestion please?

Upvotes: 1

Views: 226

Answers (2)

Your account may be not approved. You can know error using:

@Override
public void onAdFailedToLoad(@NonNull LoadAdError loadAdError) {
super.onAdFailedToLoad(loadAdError);
Log.d("ERROR",loadAdError.toString());}

After you know your error you can fix it here: https://support.google.com/admob/answer/9905175

Upvotes: 0

gogoloi
gogoloi

Reputation: 667

When create an adMob account MUST add payment information too.

Upvotes: 1

Related Questions