Android Question opting out of edge-to-edge Admob

Douglas Farias

Expert
Licensed User
Longtime User
Hello everyone.

How can I disable Admob's edge-to-edge (interstitial) feature?


The app is already working fine without edge-to-edge.

I'm using it in manifest.
XML:
SetApplicationAttribute(android:theme, "@style/LightTheme")
CreateResource(values, theme.xml,
<resources>
    <style
        name="LightTheme" parent="@android:style/Theme.Material.Light">
       <item name="android:actionMenuTextAppearance">@style/LowerCaseMenu</item>
       <item name="android:windowOptOutEdgeToEdgeEnforcement">true</item>
    </style>
     <style name="LowerCaseMenu" parent="android:TextAppearance.Material.Widget.ActionBar.Menu">
        <item name="android:textAllCaps">false</item>
    </style>
</resources>
)



But Admob uses a separate activity for the interstitial.

How do I disable edge-to-edge interstitial Admob?

Note: The attached image shows an ad (interstitial) cut off at the bottom.

I need to set

XML:

for the interstitial admob.


thxx
 

Attachments

  • 3176ebe8-00a1-4c0a-8206-895c58d244a4.jpg
    3176ebe8-00a1-4c0a-8206-895c58d244a4.jpg
    81.8 KB · Views: 56

Computersmith64

Well-Known Member
Licensed User
Longtime User
Believe it or not, the AdMob SDK is not yet compatible with Edge to Edge. They are saying the compatibility update will be released "early September", but they've been setting & pushing back release dates for a while. Unbelievable that Google would allow a product that makes them $billions to be incompatible with Android 15+ devices. To make matters worse, I've heard of developers being penalised by AdMob because the ads don't display correctly...
 
Upvote 0

Computersmith64

Well-Known Member
Licensed User
Longtime User
EDIT: Actually, if I change my device to use 3 button navigation (vs gestures) the bottom bar does cover the ad, but when the ad is in a cancelable state, pressing the back button will close it.

Having said that, I'm not seeing the issue in any of my apps that I'm running on an Android 16 device. The apps themselves all have edge to edge enabled though.

Using ads v24.4.0
 
Last edited:
Upvote 0

DonManfred

Expert
Licensed User
Longtime User
The apps themselves all have edge to edge enabled though.
Your Apps would not be accepted by Google if you actually not using opt out of edge-to-edge.

Remember that
Starting from B4A v13.4, the default themes (Themes.LightTheme / Themes.DarkTheme) already include the snippet that opts out of edge-edge. You only need this if you use a customize theme.

So you are probably using one of these Themes.
 
Upvote 0

Computersmith64

Well-Known Member
Licensed User
Longtime User
Your Apps would not be accepted by Google if you actually not using opt out of edge-to-edge.

Remember that
Starting from B4A v13.4, the default themes (Themes.LightTheme / Themes.DarkTheme) already include the snippet that opts out of edge-edge. You only need this if you use a customize theme.

So you are probably using one of these Themes.
You can't opt out if you're targeting Android 16. But regardless, these apps aren't written using B4A, so no they don't opt out.
 
Last edited:
Upvote 0

asales

Expert
Licensed User
Longtime User
There is a new version (24.6.0) of the Ads component in the SDK. No mention of this issue:
I updated this options in the B4A SDK:
- com.google.android.gms : play-services-ads
- com.google.android.gms : play-services-ads-api
Make sure that you have a backup of your original B4A SDK.
I made more test and got an error using a SDK install from stratch and update only the options above:
c:\android3\tools\..\extras\b4a_remote\androidx\datastore\datastore-core-android\1.1.7\unpacked-datastore-core-android-1.1.7\jars\classes.zip:classes.dex

Since I only have one tablet with Android 15, I tested it on an emulator.

Sometimes the issue occurs, sometimes it doesn't, as we can see in the screenshots.

Could someone test further and report back?

1757636735463.png
1757636745225.png
1757636766880.png
1757636784216.png
 
Last edited:
Upvote 0

Douglas Farias

Expert
Licensed User
Longtime User
This is Google's response to reports that the issue is still occuring on v24.6.0 -> https://groups.google.com/g/google-admob-ads-sdk/c/WyGsRV--EoE/m/aXH1lopYAgAJ
Well, at least they're getting closer to solving the problem, which is great.

Now the question remains: how can we convert their proposed solution to b4a?


Java:
  public static void applyAdMobAPI35WorkaroundIfNeeded(Application application) {
        if(Build.VERSION.SDK_INT < 35) {
            return;
        }
        application.registerActivityLifecycleCallbacks(new Application.ActivityLifecycleCallbacks() {
            @Override
            public void onActivityCreated(@NonNull Activity activity, @Nullable Bundle bundle) {}

            @Override
            public void onActivityStarted(@NonNull Activity activity) {
                applyAPI35WorkaroundToActivity(activity);
            }

            @Override
            public void onActivityResumed(@NonNull Activity activity) {
                applyAPI35WorkaroundToActivity(activity);
            }

            @Override
            public void onActivityPaused(@NonNull Activity activity) {}

            @Override
            public void onActivityStopped(@NonNull Activity activity) {}

            @Override
            public void onActivitySaveInstanceState(@NonNull Activity activity, @NonNull Bundle outState) {}

            @Override
            public void onActivityDestroyed(@NonNull Activity activity) {}
        });
    }

    private static void applyAPI35WorkaroundToActivity(Activity activity)  {
        if(!"com.google.android.gms.ads.AdActivity".equals(activity.getClass().getName())) {
            return;
        }
        WindowInsetsController c = activity.getWindow().getInsetsController();
        if(c == null) {
            return;
        }
        c.hide(WindowInsets.Type.systemBars());
        c.setSystemBarsBehavior(WindowInsetsController.BEHAVIOR_DEFAULT);
    }

If anyone knows and can help, I would appreciate it.

Thxx
 
Upvote 0

Erel

B4X founder
Staff member
Licensed User
Longtime User
Start with this code in B4XMainPage:
B4X:
Sub Class_Globals
    Private Root As B4XView
    Private xui As XUI
End Sub

Public Sub Initialize
'    B4XPages.GetManager.LogEvents = True
End Sub

'This event will be called once, before the page becomes visible.
Private Sub B4XPage_Created (Root1 As B4XView)
    Root = Root1
    Root.LoadLayout("MainPage")
    Me.As(JavaObject).RunMethod("registerActivityLifecycle", Null)
End Sub


Private Sub Activity_Lifecycle(State As String, oActivity As Object)
    Log(State & ", " & GetType(oActivity))
End Sub


  
#If Java  
import android.app.Activity;
import android.app.Application;
import android.os.Bundle;
public void registerActivityLifecycle() {
     BA.applicationContext.registerActivityLifecycleCallbacks(new Application.ActivityLifecycleCallbacks() {
        @Override
        public void onActivityCreated( Activity activity,  Bundle bundle) {
            getBA().raiseEvent(this, "activity_lifecycle", "onActivityCreated", activity);
        }

        @Override
        public void onActivityStarted( Activity activity) {
            getBA().raiseEvent(this, "activity_lifecycle", "onActivityStarted", activity);
        }

        @Override
        public void onActivityResumed( Activity activity) {
            getBA().raiseEvent(this, "activity_lifecycle", "onActivityResumed", activity);
        }

        @Override
        public void onActivityPaused( Activity activity) {
            getBA().raiseEvent(this, "activity_lifecycle", "onActivityPaused", activity);
        }

        @Override
        public void onActivityStopped( Activity activity) {}

        @Override
        public void onActivitySaveInstanceState( Activity activity,  Bundle outState) {}

        @Override
        public void onActivityDestroyed( Activity activity) {
            getBA().raiseEvent(this, "activity_lifecycle", "onActivityDestroyed", activity);
        }
    });
}
#End If
 
Upvote 0
Top