Admob广告不会出现在他只能在模拟器中使用的真实设备中

时间:2017-05-14 13:21:09

标签: android admob ads google-admob

您好我正在尝试在我的应用中添加admob广告横幅非页内广告我通过谷歌尝试过test并在真实设备中正常工作我也尝试了我的旧广告在我的应用程序中添加并运行良好。我等了超过1小时30分钟,但广告没有出现。

我的代码:

private AdView mAdView;
InterstitialAd mInterstitialAd;
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
     ....
     .....
    mAdView = (AdView) findViewById(R.id.adView);
    final AdRequest adRequest = new AdRequest.Builder().
            build();
    mAdView.loadAd(adRequest);
    mAdView.setAdListener(new AdListener() {
        @Override
        public void onAdLoaded() {
            super.onAdLoaded();
            mAdView.setVisibility(View.VISIBLE);
        }

        @Override
        public void onAdClosed() {
            super.onAdClosed();
            mAdView.setVisibility(View.GONE);
        }
    });
    mInterstitialAd = new InterstitialAd(this);
    mInterstitialAd.setAdUnitId(getString(R.string.Night_int));


    @Override
public void onPause() {
    if (mAdView != null) {
        mAdView.pause();
    }
    super.onPause();
}
@Override
public void onResume() {
    super.onResume();
    if (mAdView != null) {
        mAdView.resume();
    }
}
@Override
public void onDestroy() {
    if (mAdView != null) {
        mAdView.destroy();
    }
    super.onDestroy();
}

xml:

<com.google.android.gms.ads.AdView
    android:visibility="gone"
    android:id="@+id/adView"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    ads:adSize="SMART_BANNER"
    android:layout_gravity="center|bottom"
    ads:adUnitId="@string/Night_banner"
    android:layout_alignParentBottom="true"
    android:layout_alignParentLeft="true"
    android:layout_alignParentStart="true">
</com.google.android.gms.ads.AdView>

0 个答案:

没有答案