googleads-mobile-android-examples
googleads-mobile-android-examples copied to clipboard
edgetoedge full screen ad issue
when showing a full screen ads, there's an issue with the ad, it's cut out for devices that have the cut out
Use it like this and this problem will be solved......
if (Build.VERSION.SDK_INT>=Build.VERSION_CODES.VANILLA_ICE_CREAM){ EdgeToEdge.enable(this); } setContentView(R.layout.activity_main);
if (Build.VERSION.SDK_INT>=Build.VERSION_CODES.VANILLA_ICE_CREAM) {
ViewCompat.setOnApplyWindowInsetsListener(findViewById(R.id.main), (v, insets) -> {
Insets systemBars = insets.getInsets(WindowInsetsCompat.Type.systemBars());
v.setPadding(systemBars.left, systemBars.top, systemBars.right, systemBars.bottom);
return insets;
});
}
Use it like this and this problem will be solved......
if (Build.VERSION.SDK_INT>=Build.VERSION_CODES.VANILLA_ICE_CREAM){ EdgeToEdge.enable(this); } setContentView(R.layout.activity_main);
if (Build.VERSION.SDK_INT>=Build.VERSION_CODES.VANILLA_ICE_CREAM) { ViewCompat.setOnApplyWindowInsetsListener(findViewById(R.id.main), (v, insets) -> { Insets systemBars = insets.getInsets(WindowInsetsCompat.Type.systemBars()); v.setPadding(systemBars.left, systemBars.top, systemBars.right, systemBars.bottom); return insets; }); }
The app is only Compose code :/
Reported here about all full-screen-ads and ads-inspector, and also a workaround:
https://www.reddit.com/r/androiddev/comments/1hlctq1/google_pushes_for_edgetoedge_on_android_15_but/
setOnApplyWindowInsetsListener applies to the current activity that we are using.
Your suggestion is good, but the ad visual is a separate activity that overlays the app's activities.
<activity
android:name="com.google.android.gms.ads.AdActivity"
android:theme="@android:style/Theme.Translucent" />
By default, this screen is used, but its theme cannot be changed from the manifest. We have already tried this method.
@rohitraj-khorwal But I've reproduced it and it's different when using the workaround I've suggested.
Perhaps you are using more ad-sources for Admob mediation, and then you don't notice it. If so, you can add it to the Activities that they use, and then it's even a larger workaround...
For example, I've collected these (but I don't use them for now, as it's too many):
<activity
android:name="com.applovin.adview.AppLovinFullscreenActivity"
android:theme="@style/AdInspectorActivityTheme" tools:replace="android:theme" />
<activity
android:name="com.chartboost.sdk.view.CBImpressionActivity" android:exported="false"
android:theme="@style/AdInspectorActivityTheme" tools:replace="android:theme" />
<activity
android:name="com.chartboost.sdk.internal.clickthrough.EmbeddedBrowserActivity"
android:exported="false" android:theme="@style/AdInspectorActivityTheme"
tools:replace="android:theme" />
<activity
android:name="com.inmobi.ads.rendering.InMobiAdActivity" android:exported="false"
android:theme="@style/AdInspectorActivityTheme" tools:replace="android:theme" />
<activity
android:name="com.ironsource.sdk.controller.ControllerActivity" android:exported="false"
android:theme="@style/AdInspectorActivityTheme" tools:replace="android:theme" />
<activity
android:name="com.ironsource.sdk.controller.InterstitialActivity"
android:exported="false" android:theme="@style/AdInspectorActivityTheme"
tools:replace="android:theme" />
<activity
android:name="com.ironsource.sdk.controller.OpenUrlActivity" android:exported="false"
android:theme="@style/AdInspectorActivityTheme" tools:replace="android:theme" />
<activity
android:name="com.ironsource.mediationsdk.testSuite.TestSuiteActivity"
android:exported="false" android:theme="@style/AdInspectorActivityTheme"
tools:replace="android:theme" />
<activity
android:name="com.vungle.ads.internal.ui.VungleActivity" android:exported="false"
android:theme="@style/AdInspectorActivityTheme" tools:replace="android:theme" />
<activity
android:name="com.mbridge.msdk.activity.MBCommonActivity" android:exported="false"
android:theme="@style/AdInspectorActivityTheme" tools:replace="android:theme" />
<activity
android:name="com.mbridge.msdk.reward.player.MBRewardVideoActivity"
android:exported="false" android:theme="@style/AdInspectorActivityTheme"
tools:replace="android:theme" />
<activity
android:name="com.mbridge.msdk.newreward.player.MBRewardVideoActivity"
android:exported="false" android:theme="@style/AdInspectorActivityTheme"
tools:replace="android:theme" />
<activity
android:name="com.mbridge.msdk.out.LoadingActivity" android:exported="false"
android:theme="@style/AdInspectorActivityTheme" tools:replace="android:theme" />