I try to add Facebook banner to my Android App. It works good with my LG D-405, but returns "Ad was re-loaded too frequently" with Samsung Galaxy S5.
adView = new AdView(getActivity(), "-------", AdSize.BANNER_HEIGHT_50);
adView.setAdListener(new AdListener() {
@Override
public void onError(Ad ad, AdError adError) {
if(getActivity()!=null) {
((MyApplication) getActivity().getApplication()).getDefaultTracker().send(
new HitBuilders.EventBuilder()
.setCategory("Facebook AdView")
.setAction("error")
.setLabel(adError.getErrorMessage())
.setValue((long) adError.getErrorCode())
.build()
);
}
}
@Override
public void onAdLoaded(Ad ad) {
if(!layout.getChildAt(2).equals(adView)) {
layout.addView(adView, 2, new LinearLayout.LayoutParams((int) (AdSize.BANNER_HEIGHT_50.getWidth() * MainActivity.density), (int) (AdSize.BANNER_HEIGHT_50.getHeight() * MainActivity.density)));
}
}
@Override
public void onAdClicked(Ad ad) {
}
});
//adView.disableAutoRefresh();
adView.loadAd();
I too got the same issue and the it seems that you must have the Facebook app installed on the device and have logged in within the last 30 days.
Also, I found this - https://developers.facebook.com/docs/audience-network/faq#a12