我的广告没有展示
my ads are not showing up
我只是想学习如何在 android 中添加广告 app.but 广告没有显示 up.i 不知道为什么没有显示
这是我的 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>
Mainactivity.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());
否则,如果您的应用已上线且无法显示任何广告,则您需要等待一段时间。
根据Google
"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 中添加广告 app.but 广告没有显示 up.i 不知道为什么没有显示
这是我的 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>
Mainactivity.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());
否则,如果您的应用已上线且无法显示任何广告,则您需要等待一段时间。
根据Google
"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