Hi, I'm trying to update my app to targetSdkVersion 36, but this seems to break many things, including AdMob ads - I am noticing the AppOpenAd gets cut out when displayed in landscape mode on the emulator running Android 16, but if I change it back to
targetSdkVersion 34, it is no longer cut out and displays properly. Attached screenshot how it looks like on Android 16 with targetSdkVersion 36.
Shouldn't the code actually be like this?
int adWidth;
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.R) {
WindowInsets windowInsets = activity.getWindow().getDecorView().getRootWindowInsets();
Insets insets = windowInsets.getInsets(WindowInsets.Type.systemBars() | WindowInsets.Type.displayCutout());
Rect rect = activity.getWindowManager().getCurrentWindowMetrics().getBounds();
adWidth = rect.width() - insets.left - insets.right;
} else {
adWidth = Resources.getSystem().getDisplayMetrics().widthPixels;
}
float density = Resources.getSystem().getDisplayMetrics().density;
adWidth = (int) (adWidth / density);
adView.setAdSize(AdSize.getCurrentOrientationAnchoredAdaptiveBannerAdSize(activity, adWidth));
What are we supposed to do? We can no longer release any updates if we don't target Android 16, but if we do, it breaks AdMob ads.
Thanks