I am implementing code for native ads that is given by google. That is working okay with google
ad unit id ADMOB_AD_UNIT_ID = "ca-app-pub-3940256099942544/2247696110"
But when I replace with my id its not showing ad and execute onAdFailedToLoad
method and got Failed to load native ad: 0 error .
I tried two different ad unit id but it didn't load ad.
so what should I do??please help me
I tried below code
final LayoutInflater li = (LayoutInflater) appContext.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
AdLoader.Builder builder = new AdLoader.Builder(appContext, Global.ADMOB_AD_UNIT_ID);
builder.forContentAd(new NativeContentAd.OnContentAdLoadedListener() {
@Override
public void onContentAdLoaded(NativeContentAd ad) {
//viewHolder.rlnativead.setVisibility(View.VISIBLE);
NativeContentAdView adView = (NativeContentAdView)li
.inflate(R.layout.ad_content, null);
populateContentAdView(ad, adView);
viewHolder.fl_adplaceholder.removeAllViews();
viewHolder.fl_adplaceholder.addView(adView);
}
});
AdLoader adLoader = builder.withAdListener(new AdListener() {
@Override
public void onAdFailedToLoad(int errorCode) {
// Toast.makeText(appContext, "Failed to load native ad: "
// + errorCode, Toast.LENGTH_SHORT).show();
Log.e("Call List adapter","Failed to load native ad: "+errorCode);
}
}).build();
adLoader.loadAd(new AdRequest.Builder().build());