NativeExpressAdView adView = (NativeExpressAdView) findViewById(R.id.adView);
adView.loadAd(new AdRequest.Builder().build());
NativeExpressAdView is working fine but
AdLoader.Builder builder = new AdLoader.Builder(con, ADMOB_AD_UNIT_ID);
/*if (requestAppInstallAds)*/ {
builder.forAppInstallAd(new NativeAppInstallAd.OnAppInstallAdLoadedListener() {
@Override
public void onAppInstallAdLoaded(NativeAppInstallAd ad) {
//FrameLayout frameLayout =(FrameLayout) findViewById(R.id.fl_adplaceholder);
// NativeAppInstallAdView adView = (NativeAppInstallAdView) getLayoutInflater().inflate(R.layout.ad_app_install, null);
}
});
}
adLoader = builder.withAdListener(new AdListener() {
@Override
public void onAdFailedToLoad(int errorCode) {
Toast.makeText(con, "Failed to load native ad: "
+ errorCode, Toast.LENGTH_SHORT).show();
}
@Override
public void onAdClosed() {
super.onAdClosed();
}
}).build();
//adLoader.loadAd(new AdRequest.Builder().addTestDevice("9221FAA48B3F9AD9AA72601953B89E76").build());
adLoader.loadAd(new AdRequest.Builder().build());
如果使用实时广告,则可以正常使用测试广告,因为其展示无法加载错误代码0为什么?
答案 0 :(得分:1)
NativeExpressAdView现在才可用。您可以通过此链接https://support.google.com/admob/contact/account_setup?rd=1
申请原生人答案 1 :(得分:1)
并非每个广告请求都会产生广告。特别是如果您只是进行测试,那么您明确必须将设备ID添加为测试设备,否则您将无法获得广告。