Android Question Collapsible banner

joaomoraes83

Member
Licensed User
I received an email from google regarding the collapsible banner.
Do you already support this ad format?
Here's the simple code they sent as an example, I couldn't adapt it to B4A:
Bundle extras = new Bundle();
extras.putString("collapsible", "top");
AdRequest adRequest = new AdRequest.Builder()
.addNetworkExtrasBundle(AdMobAdapter.class, extras)
.build();
adView.loadAd(adRequest);
 

asales

Expert
Licensed User
Longtime User
I got the same email and I'm very interested about this.

1667562812689.png
 
Upvote 0

Erel

B4X founder
Staff member
Licensed User
Longtime User
B4X:
#if java
import android.os.Bundle;
import com.google.ads.mediation.admob.AdMobAdapter;
import com.google.android.gms.ads.AdRequest;
public Object GetCollapsibleRequest() {
    AdRequest.Builder builder = new AdRequest.Builder();
    Bundle extras = new Bundle();
    extras.putString("collapsible", "top");
    builder.addNetworkExtrasBundle(AdMobAdapter.class, extras);
    return builder;
}
#End If

B4X:
Dim request As AdRequestBuilder = Me.As(JavaObject).RunMethod("GetCollapsibleRequest", Null)

And load the ad with LoadAdWithBuilder.
 
Upvote 0

asales

Expert
Licensed User
Longtime User
Thanks, Erel. It worked, but I get the expanded banner only from top to bottom.
If I put the retracted (normal) banner in the bottom of the screen, the expanded banner is open off the screen.
The third screen is show if I put the banner in 50%y and not 100%y (like the 2 first screens):

1667842127927.png
1667842139313.png
1667842224064.png

Somene has implemented this kind of banner?

Thanks in advance for any tip.
 
Upvote 1

benyamin

New Member
B4X:
#if java
import android.os.Bundle;
import com.google.ads.mediation.admob.AdMobAdapter;
import com.google.android.gms.ads.AdRequest;
public Object GetCollapsibleRequest() {
    AdRequest.Builder builder = new AdRequest.Builder();
    Bundle extras = new Bundle();
    extras.putString("collapsible", "top");
    builder.addNetworkExtrasBundle(AdMobAdapter.class, extras);
    return builder;
}
#End If

B4X:
Dim request As AdRequestBuilder = Me.As(JavaObject).RunMethod("GetCollapsibleRequest", Null)

And load the ad with LoadAdWithBuilder.
i get this error

B4X:
java.lang.IllegalArgumentException: Expected receiver of type com.dic.apps.main2, but got java.lang.Class<com.dic.apps.main2>
 
Upvote 0
Top