To load a banner, create a BannerView and add it as a subview of your view hierarchy.
You can create banners of either 320x50 or 300x250 size:
//add banners to view
public void addBanner_320x50_to_view(View view, BannerViewDelegate delegate) {
BannerView banner = new BannerView(Activity activity).banner(AdFormat.banner_320x50);
banner.setBannerViewDelegate(bannerShowDelegate)
view.addView(banner);
}
public void addBanner_300x250_to_view(View view, BannerViewDelegate delegate) {
BannerView banner = new BannerView(Activity activity).banner(AdFormat.banner_300x250);
banner.setBannerViewDelegate(bannerShowDelegate)
view.addView(banner);
}
//add banners to view
fun addBanner_320x50_to_view(view:View) {
val banner = BannerView(activity:Activity).banner(AdFormat.banner_320x50)
banner.setBannerViewDelegate(bannerShowDelegate)
view.addView(banner)
}
fun addBanner_300x250_to_view(view:View) {
val banner = BannerView(activity:Activity).banner(AdFormat.banner_300x250)
banner.setBannerViewDelegate(bannerShowDelegate)
view.addView(banner)
}
Implement BannerViewDelegate so that you are notified of when your ad is ready and of other ad-related events.
To determine whether an advertisement banner is currently being displayed or not you can use function, that returns a boolean value, specifically true if an ad is present and visible on the screen, and false otherwise:
banner.isAdDisplayed()
banner.isAdDisplayed()
To check whether the SDK is initialized and if the banner is ready for display or not you can use function, that returns a boolean value (true if the conditions are met and false otherwise).
banner.isReadyToRefresh()
banner.isReadyToRefresh()
Stopping and Starting Auto-Refresh
There may be cases when you would like to stop auto-refresh, for instance, when you hide a banner ad or want to manually refresh.
Stop auto-refresh for a banner ad with the following code:
banner.stopAutorefresh()
banner.stopAutorefresh()
Start auto-refresh for a banner ad with the following code:
banner.startAutorefresh(30.0)
banner.startAutorefresh(30.0)
Manually refresh the contents with the following code. You must stop auto-refresh prior to calling refreshAd.
banner.refreshAd()
banner.refreshAd()
Destroying Banners
Once you're finished with a banner ad, it's essential to clean up its resources by invoking the destroy() method. Neglecting this step could lead to a deterioration in your app's performance