Hello team,
We found that when we rotated our application from Portrait position to Landscape position, the adaptive banner is not being reloaded. The message displayed in Ad Inspector is:
attachment
We downloaded the adaptive banner example from (
https://github.com/googleads/googleads-mobile-android-examples/tree/main/kotlin/admob/BannerExample)
and the same error occurs.
The device tested was a Samsung Galaxy S21.
I found that the problem stopped occurring when I changed the code that calculates the screen width to:
return AdSize.getCurrentOrientationAnchoredAdaptiveBannerAdSize(this, AdSize.FULL_WIDTH)
According to the message on the forum:
https://github.com/googleads/googleads-mobile-unity/issues/1068#issuecomment-1312725741This update occurred in the Admob version:
22.3.0 2023‑08‑22
Added support for creating adaptive sizes using AdSize.FULL_WIDTH as the width. Previously, ad sizes created using AdSize.FULL_WIDTH would be treated as AdSize.SMART_BANNER.
However, the documentation and examples still perform manual width calculation which appears to fail on some devices.
private val adSize: AdSize
get() {
val displayMetrics = resources.displayMetrics
val adWidthPixels =
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.R) {
val windowMetrics: WindowMetrics = this.windowManager.currentWindowMetrics
windowMetrics.bounds.width()
} else {
displayMetrics.widthPixels
}
val density = displayMetrics.density
val adWidth = (adWidthPixels / density).toInt()
return AdSize.getCurrentOrientationAnchoredAdaptiveBannerAdSize(this, adWidth)
}