-jio-start-block-type-3
¶ Dynamic Display Ads¶ IntroductionDynamic display ads adapt their content in real time to match the individual viewer's interests and behavior. They are like personalized billboards that create a more relevant and engaging experience for users.
|
![]() |
-jio-end-block-type-3
Complete GETTING STARTED section and INITIALIZE SDK section before starting this section.
-jio-start-block-type-2
-jio-tables
Display Size | Typical Use Cases | API |
---|---|---|
320x50 | Mobile banner ads | jioAdViewDynamicDisplay.setDisplayAdSize(Constants.DynamicDisplaySize.SIZE_320x50) |
300x50 | Mobile banner ads | jioAdViewDynamicDisplay.setDisplayAdSize(Constants.DynamicDisplaySize.SIZE_300x50) |
320x100 | Large mobile banner ads | jioAdViewDynamicDisplay.setDisplayAdSize(Constants.DynamicDisplaySize.SIZE_320x100) |
300x250 | Medium rectangle for sidebar placements | jioAdViewDynamicDisplay.setDisplayAdSize(Constants.DynamicDisplaySize.SIZE_300x250) |
728x90 | Leaderboard, for top of web pages | jioAdViewDynamicDisplay.setDisplayAdSize(Constants.DynamicDisplaySize.SIZE_728x90) |
300x600 | Half-page ad for sidebar placements | jioAdViewDynamicDisplay.setDisplayAdSize(Constants.DynamicDisplaySize.SIZE_300x600) |
970x90 | Large leaderboard for top of web pages | jioAdViewDynamicDisplay.setDisplayAdSize(Constants.DynamicDisplaySize.SIZE_970x90) |
970x250 | Billboard ad for top or bottom of pages | jioAdViewDynamicDisplay.setDisplayAdSize(Constants.DynamicDisplaySize.SIZE_970x250) |
160x600 | Skyscraper ad, for sidebar placement | jioAdViewDynamicDisplay.setDisplayAdSize(Constants.DynamicDisplaySize.SIZE_160x600) |
-jio-style-title
To Pass multiple predefined display sizes, use below code snippet. SDK will show Ads from the passed sizes.
jioadView?.setDisplayAdSize(dynamicSizes: List<DynamicDisplaySize>)
Example:
val sizeList: MutableList<DynamicDisplaySize> = ArrayList()
sizeList.add(DynamicDisplaySize.SIZE_300x50)
sizeList.add(DynamicDisplaySize.SIZE_300x250)
sizeList.add(DynamicDisplaySize.SIZE_300x600)
jioAdView?.setDisplayAdSize(sizeList)
-jio-style-title
To make Dynamic display ad Adaptive, pass max width and max height in below API
setDisplayMaxSize(maxWidth: Int, maxHeight: Int)
Example:
jioAdView?. setDisplayMaxSize(adWidth,250)
// Use below function to get device width
private fun adWidth(): Int{
val displayMetrics = context.resources?.displayMetrics
val adWidthPixels =displayMetrics?.widthPixels
val density = displayMetrics?.density
val adWidth = (adWidthPixels/ density!!).toInt()
return adWidth
}
1. In case of Adaptive Dynamic Display Ad passing custom layout before cacheAd is mandatory. Refer Customize Dynamic Display Ads section for ad customization.
2. In case of Adaptive Dynamic Display ad, container width and height should not be fixed. Width should be either “match_parent” or ”wrap-content” and height should be always “wrap-content”.
3. Do not call setDisplayAdSize() and setDisplayMaxSize() APIs with same jioadview object.
-jio-style-title
Cache dynamic display ads by initializing a JioAdView, setting up an ad listener, creating an ad container, adding the ad view, and initiating the caching process with a single call to jioAdView?.cacheAd()
If app is passing Ad container with fixed height and width, then call addView()
API.
frameLayout.addView(jioAdView.getAdView())
Complete CacheAd() code reference
var jioAdViewDynamicDisplay: JioAdView
// context pass here should be Activity context.
jioAdViewDynamicDisplay = JioAdView (this,”<ADSPOT_KEY_GOES_HERE>“, JioAdView.AD_TYPE.DYNAMIC_DISPLAY)
jioAdViewDynamicDisplay!!.setAdListener(object: JioAdListener() {
override fun onAdFailedToLoad(jioAdView: JioAdView?, jioAdError: JioAdError?) {
// Error Callback
}
override fun onAdPrepared(jioAdView: JioAdView?) {
// Success callback
}
override fun onAdClosed( jioAdView: JioAdView?,isVideoCompleted: Boolean,isEligibleForReward: Boolean) {
// When Ad is closed
}
override fun onAdRender(jioAdView: JioAdView?){
// When ad is rendered on screen
}
override fun onAdMediaEnd(jioAdView: JioAdView?) {
// When media ended
}
})
val DynamicDisplayAdContainer = findViewById<FrameLayout>(R.id.dynamicAdContainer)
val sizeList: MutableList<DynamicDisplaySize> = ArrayList()
sizeList.add(Constants.DynamicDisplaySize.<ACTUAL_SIZE>)
jioAdView?.setDisplayAdSize(sizeList)
jioAdViewDynamicDisplay?.cacheAd()
-jio-style-title
Upon invoking the loadAd()
API, the SDK dynamically attempts to render the dynamic display Ad within the designated container. This action can be triggered either in response to an app event or integrated within the onAdPrepared() callback, providing flexibility in ad display management.
if(jioAdViewDynamicDisplay?.getAdState() == JioAdView.AdState.PREPARED) {
jioAdViewDynamicDisplay?.addView(jioAdViewDynamicDisplay?.getAdView())
jioAdViewDynamicDisplay?.loadAd()
}
-jio-style-title
-jio-style-title
Lifecycle Management
Ensure proper lifecycle management by calling jioAdViewDynamicDisplay.onDestroy()
within the onDestroy() method of the activity to destroy the dynamic display ad object
override fun onDestroy() {
if (jioAdViewDynamicDisplay != null) {
jioAdViewDynamicDisplay.onDestroy()
}
super.onDestroy()
}
-jio-style-title
Dynamically set the display Ad size by caling setCustomDisplayAdContainer()
jioAdViewDynamicDisplay.setCustomDisplayAdContainer(dynamicdisplyContainer: int, videoContainer: int)
// Example-
jioAdViewDynamic.setCustomDisplayAdContainer(R.layout.custom_dynamic_display_layout,
R.layout.custom_dynamic_video_layout)
1. Customize image ads by passing a custom layout as the 1st argument and customize video ads by passing it as the 2nd argument in the provided API.
2. For detailed information, including TAG and examples, on customizing ads, refer to the Customizing Native Banner Ads section or the Native Billboard Ads section
-jio-end-block-type-2