Search code examples
androidfacebookadmobadsheyzap

Heyzap only show a banner on a screen


I try show 2 banner on 1 screen, but it only show 1 banner. Banner 1 loaded and show, but when banner 2 loaded, it is showed and banner 1 is empty. My code can't show both 2 banner. Can you help me.

My CODE:

@BindingAdapter({"bind:initAds"})
public static void initAds(FrameLayout view, MainData data) {
    if (data.getAds() > 0) {
        AdsUtil.addBannerAds(view, data);
    } else {
        view.setVisibility(View.GONE);
    }

    //AdsUtil.addBannerAds(view, data);
}

public static void addBannerAds(final FrameLayout bannerWrapper, final MainData data)
{
    Activity mActivity = IxuApplication.getInstance().getCurrentActivity();
    BannerAdView bannerAdView = new BannerAdView(mActivity);
    HeyzapAds.setNetworkCallbackListener(new HeyzapAds.NetworkCallbackListener() {
        @Override
        public void onNetworkCallback(String network, String event) {
            Log.e("tungtung",network + " " + event);
        }

    });
    HeyzapAds.BannerOptions bannerOptions = bannerAdView.getBannerOptions();
    bannerOptions.setFacebookBannerSize(HeyzapAds.CreativeSize.BANNER);
    bannerOptions.setAdmobBannerSize(HeyzapAds.CreativeSize.BANNER);
    bannerOptions.setGenericBannerSize(HeyzapAds.CreativeSize.BANNER);
    if(bannerWrapper.getChildCount()>0)
        bannerWrapper.removeAllViews();
    bannerWrapper.addView(bannerAdView);
    bannerAdView.setBannerListener(new HeyzapAds.BannerListener() {
        @Override
        public void onAdError(BannerAdView bannerAdView, HeyzapAds.BannerError bannerError) {

        }

        @Override
        public void onAdLoaded(BannerAdView bannerAdView) {
            if(data.getEnable()!=2)
                data.setShowLineForAds(1);
            bannerWrapper.setVisibility(View.VISIBLE);
        }

        @Override
        public void onAdClicked(BannerAdView bannerAdView) {

        }
    });
    bannerAdView.load();
}

Solution

  • Sorry to say that if you are using our new 10.x unified SDK we no longer support multiple simultaneous banner placements. It's a limitation of the new SDK and we will are currently looking into the best solution.

    If you are using the 9.x SDK I can give you a few notes:

    In order to help ad delivery reliability, we suggest you do not modify the View visibility of the BannerAdView on your own and leave the view as VISIBLE throughout the lifecycle of the banner.

    The next note is that the following code is destroying any existing banners when you call addBannerAds.

    if(bannerWrapper.getChildCount() > 0)
        bannerWrapper.removeAllViews();
    

    If you remove this code from your implementation you should be able to add multiple banners to the bannerWrapper at once and hopefully see multiple banners.