gpt4 book ai didi

android - 我的广告没有展示

转载 作者:行者123 更新时间:2023-11-30 00:33:21 24 4
gpt4 key购买 nike

我只是想学习如何在 android 应用程序中添加广告。但是广告没有显示。我不知道为什么它没有出现

这是我的mainactivity.xml

<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Hello World!" />


<com.google.android.gms.ads.AdView
android:id="@+id/adView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
ads:adSize="BANNER"
ads:adUnitId="@string/banner_ad_unit_id"
android:layout_marginTop="443dp"
android:layout_below="@+id/textView"
android:layout_alignParentEnd="true">
</com.google.android.gms.ads.AdView>
</RelativeLayout>

主 Activity .java

package com.example.a1407268.admob;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;

import com.google.android.gms.ads.AdRequest;
import com.google.android.gms.ads.AdView;

public class MainActivity extends AppCompatActivity {

@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
AdView mAdView = (AdView) findViewById(R.id.adView);
AdRequest adRequest = new AdRequest.Builder().build();
mAdView.loadAd(adRequest);
}
}

最佳答案

如果您正在测试您的应用,请使用 addTestDevice() 检查广告对齐。

AdView adView = new AdView(this);

AdRequest.Builder adRequestBuilder = new AdRequest.Builder();
adRequestBuilder.addTestDevice(AdRequest.DEVICE_ID_EMULATOR);
adView.loadAd(adRequestBuilder.build());

否则,如果您的应用已上线且无法显示任何广告,则您需要等待一段时间。

根据谷歌

"It could be that you have only recently created a new Ad Unit ID and requesting for live ads. It could take a few hours for ads to start getting served if that is that case. If you are receiving test ads then your implementation is fine. Just wait a few hours and see if you are able to receive live ads then. If not, can send us your Ad Unit ID for us to look into."

https://groups.google.com/forum/#!category-topic/google-admob-ads-sdk/android/fBe3YL3ffpo

关于android - 我的广告没有展示,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43868467/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com