Android Question Collapsible banner ads

hayk

Member
Hi everyone! I received an Email from Google about new ad type, called Collapsible banner ads. Check this.
Does someone know, How to use Collapsible banner ads?

1.gif
 

Erel

B4X founder
Staff member
Licensed User
Longtime User
1. Use B4XPages.
2. Add this to the end of the page:
B4X:
#if java
import android.os.Bundle;
import com.google.ads.mediation.admob.AdMobAdapter;
import com.google.android.gms.ads.AdRequest;
public Object GetCollapsibleRequest(String placement) {
    AdRequest.Builder builder = new AdRequest.Builder();
    Bundle extras = new Bundle();
    extras.putString("collapsible", placement);
    builder.addNetworkExtrasBundle(AdMobAdapter.class, extras);
    return builder;
}
#End If

3.
B4X:
Dim request As AdRequestBuilder = Me.As(JavaObject).RunMethod("GetCollapsibleRequest", Array("bottom"))
BannerAd.LoadAdWithBuilder(request)
 
Upvote 0

asales

Expert
Licensed User
Longtime User
also check this post
If you check this post, you will that I don't get an answer to the problem and I could not fix it.

The banner of page2 (b4xpage formt) is still showing when I close the page. This is not happens if I create the page2 as activity format.

If you solve this, please, share the soluction.
 
Upvote 0

Erel

B4X founder
Staff member
Licensed User
Longtime User
Looks like it creates a dialog and adds it to the activity. All pages share the same activity.
There is no API to close it.
I'm getting the dreaded "no fill" error right now, so can't test it. You might be able to find the close button and programmatically click it (I'm not sure whether this is allowed by Google or not).
 
Upvote 0

asales

Expert
Licensed User
Longtime User
Looks like it creates a dialog and adds it to the activity. All pages share the same activity.
Yes, I think that's it. I found this information:
Collapsible banner ads require you to pass an Activity context
There is no API to close it.
I'm getting the dreaded "no fill" error right now, so can't test it. You might be able to find the close button and programmatically click it (I'm not sure whether this is allowed by Google or not).
I don't found how to close or collapse it automatically and I don't think so is allowed by Google because they are very restricted with the ads now.
I tried several methods (RemoveView, Pause, Resume, Visible = False) without success.
 
Upvote 0

hayk

Member
1. Use B4XPages.
2. Add this to the end of the page:
B4X:
#if java
import android.os.Bundle;
import com.google.ads.mediation.admob.AdMobAdapter;
import com.google.android.gms.ads.AdRequest;
public Object GetCollapsibleRequest(String placement) {
    AdRequest.Builder builder = new AdRequest.Builder();
    Bundle extras = new Bundle();
    extras.putString("collapsible", placement);
    builder.addNetworkExtrasBundle(AdMobAdapter.class, extras);
    return builder;
}
#End If

3.
B4X:
Dim request As AdRequestBuilder = Me.As(JavaObject).RunMethod("GetCollapsibleRequest", Array("bottom"))
BannerAd.LoadAdWithBuilder(request)
Is there any chance to make it work properly without B4XPages?
 
Upvote 0
Top