private void loadAd(String adId) {
//加载多条广告
final List<NativeAd> nativeAds = new ArrayList<NativeAd>();
final NativeAdsManager nam = new NativeAdsManager(FbAdvertisementActivity.this, "1542807559327931_1609143346027685", 10);
nam.setListener(new Listener() {
@Override
public void onAdsLoaded() {
int count = nam.getUniqueNativeAdCount();
while (count > 0) {
nativeAds.add(nam.nextNativeAd());
count--;
}
FbAdAdapter fba = new FbAdAdapter(nativeAds, FbAdvertisementActivity.this);
lvFbAds.setAdapter(fba);
}
@Override
public void onAdError(AdError paramAdError) {
Log.e(tag, "FbNotificationNativeAdnError:" + paramAdError.getErrorCode() + ", " + paramAdError.getErrorMessage());
}
});
nam.loadAds();
//加载单条广告
final NativeAd nativeAd = new NativeAd(FbAdvertisementActivity.this, adId);