Banner Integration Guide
Android SDK 2.0 supports banner ads in multiple sizes and includes smart resizing capabilities.
Step 1: Add BannerView to Your Layout
In your XML layout file, add the BannerView
:
<com.appnext.adunits.banner.BannerView
android:id="@+id/bannerView"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:bannerSize="LARGE_BANNER"
app:placementId="YOUR_PLACEMENT_ID" />
Supported Banner Sizes:
Banner name | Size |
---|---|
BANNER | 320x50 |
LARGE_BANNER | 320x100 |
MEDIUM_RECTANGLE | 300x250 |
Step 2: Load the Banner in Your Code
After adding the BannerView
to your layout, you need to load an ad programmatically and set up event callbacks to track the ad’s lifecycle events.
val adCallbacks = object : AdCallbacks {
override fun onAdClicked(packageName: String) {
Toast.makeText(this@MainActivity, "Ad clicked", Toast.LENGTH_SHORT).show()
}
override fun onAdImpressionReceived(packageName: String) {
Toast.makeText(this@MainActivity, "Impression received", Toast.LENGTH_SHORT).show()
}
override fun onViewLoadedSuccessfully() {}
override fun onViewError(error: AppnextError) {
Toast.makeText(this@MainActivity, "View error: ${error.errorMessage}", Toast.LENGTH_SHORT).show()
}
override fun onAdsLoadedSuccessfully() {}
override fun onAdsLoadedError(error: AppnextError) {}
}
// Example with View Binding
binding.bannerView.load(adCallbacks)
Step 3: (Optional) Enable Smart Banner
Smart Banner dynamically resizes the banner to fit the screen width and orientation.
Programmatically:
binding.bannerView.setSmartBanner(true)
Call
setSmartBanner(true)
beforeload()
.
Or in XML:
<com.appnext.adunits.banner.BannerView
android:id="@+id/bannerView"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:placementId="YOUR_PLACEMENT_ID"
app:bannerSize="LARGE_BANNER"
app:isSmartBanner="true" />
Support
If you encounter any technical issues while integrating or using the Android SDK 2.0, our team is here to help.
Contact Us
📧 Email: [email protected]
Please include:
- App package name
- SDK version
- Device and OS info
- Clear description of the issue
- (Optional) Screenshots or logs
Updated 6 days ago