我尝试了stackoverflow中的所有内容,但广告未显示。横幅和其他工作,但本地不工作,请帮助我。
inal NativeExpressAdView mAdView2 = (NativeExpressAdView) findViewById(R.id.adView2);
// Set its video options.
mAdView2.setVideoOptions(new VideoOptions.Builder()
.setStartMuted(true)
.build());
// The VideoController can be used to get lifecycle events and info about an ad's video
// asset. One will always be returned by getVideoController, even if the ad has no video
// asset.
mVideoController = mAdView2.getVideoController();
mVideoController.setVideoLifecycleCallbacks(new VideoController.VideoLifecycleCallbacks() {
@Override
public void onVideoEnd() {
Log.d(LOG_TAG, "Video playback is finished.");
super.onVideoEnd();
}
});
// Set an AdListener for the AdView, so the Activity can take action when an ad has finished
// loading.
mAdView2.setAdListener(new AdListener() {
@Override
public void onAdLoaded() {
mAdView2.setVisibility(View.VISIBLE);
if (mVideoController.hasVideoContent()) {
Log.d(LOG_TAG, "Received an ad that contains a video asset.");
} else {
Log.d(LOG_TAG, "Received an ad that does not contain a video asset.");
}
}
});
mAdView2.loadAd(adRequest);
此活动代码
这是xml代码。请帮帮我。
<com.google.android.gms.ads.NativeExpressAdView
android:id="@+id/adView2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
ads:adUnitId="ca-app-pub-000000"
ads:adSize="300x150"
android:visibility="gone"
>
</com.google.android.gms.ads.NativeExpressAdView>
答案 0 :(得分:0)
你只需要稍等一下。您的广告ID是新创建的,因此从Google服务器获取广告需要一些时间。
我也发现错误&#34;无法加载广告0&#34; 但是没有问题等待有时像一小时或2小时甚至5小时等待你将获得广告。