I try to make the same, use native ad as banner without adapters.
I have nearly the same code but impression tracking was stuck to 0.
Thanks for showing that i nee to call prepare on the native ad.
I have another problem now, some native from Applovin and Mopub marketplace don’t react on click.
Facebook test ads and flurry open a new screen.
public void onNativeLoad(NativeAd nativeAd) {
LinearLayout ll = (LinearLayout) findViewById(R.id.bannerNative);
View mView = nativeAd.createAdView(getApplicationContext(), ll);
nativeAd.clear(mView);
nativeAd.renderAdView(mView);
nativeAd.prepare(mView);
ll.removeAllViews();
ll.addView(mView);
mopubHandler.postDelayed(new Runnable() {
@Override
public void run() {
mopubMakeRequest();
}
}, 30 * 1000);
}
I have try to call prepare after or before renderAdView, still nothing on click.
Should i call clear if i remove the view later like in my code ?
Edit: For ApplovinAdapter i have found this commented code but when tested it get the click but don’t open a new screen
@Override
public void prepare(View view) {
mView = view;
mView.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Log.d(TAG, "onClick");
mNativeAd.launchClickTarget(mContext);
notifyAdClicked();
}
});
trackImpression(mNativeAd);
}
Still no idea why the ads from Mopub market place don’t react on click.