fbsamples / audience-network

Open source projects to demonstrate SDK and sample code usages and integration, and to collaborate and support peers in this community.
https://developers.facebook.com/docs/audience-network
Other
318 stars 370 forks source link

Load multiple banner ads in same activty #124

Closed kmrinmoy07 closed 3 years ago

kmrinmoy07 commented 4 years ago

Hello, In my android project I have some fragments inside my main activity and each fragments are scrollable. Now I want to place ads on each fragment and also since my fragments are scrollable so I want to load 5 ads (2 medium rectangle ads and 3 banner ads) in each fragment under the same activity. But all those ads doesn't get loaded together. Only 2 ads (one from banner ad and one from medium rectangle ad) get loaded while the rest doesn't load. Only in very rare case say like about 1 out of 100 attempts all those 5 gets load together. Also if one ad is loaded in one fragments then the ad in other fragments doesn't get loaded.

This is how I am loading my ad-

    // In my application class
    AudienceNetworkAds.initialize(this);       

    //inside fragments
    adView = new AdView(this, "IMG_16_9_APP_INSTALL#MY_PLACEMENT_ID", AdSize.BANNER_HEIGHT_50);   
    adContainer.addView(adView);
    adView.loadAd();

    //in layout 
   <LinearLayout
    android:id="@+id/ad_container1"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    />

Can you please help me how I can load all those ad without any issue.

gwheet commented 3 years ago

Audience Network not always can provide you an ad. You can read more about fill rate here: https://www.facebook.com/business/help/1673395492911956. Also make sure that you are using the latest SDK that has latest fixes.