Android Question banner ads in panel, not show

AnandGupta

Expert
Licensed User
Longtime User
I am checking FireBaseAd sample from

Below code I change to show the banner ad in a given panel instead of activity, but the banner ad does not show in panel, (works OK in activity)
B4X:
   BannerAd.Initialize2("BannerAd", "ca-app-pub-3940256099942544/6300978111", BannerAd.SIZE_SMART_BANNER)
   Dim height As Int
   If GetDeviceLayoutValues.ApproximateScreenSize < 6 Then
    'phones
    If 100%x > 100%y Then height = 32dip Else height = 50dip
   Else
    'tablets
    height = 90dip
   End If
   Log("height" & height)
'   Activity.AddView(BannerAd, 0dip, 100%y - height, 100%x, height)
    Panel1.AddView(BannerAd, 0dip, 100%y, 100%x, height)
   BannerAd.LoadAd

What is the correct way to achieve it ?

Regards,

Anand
 

asales

Expert
Licensed User
Longtime User
You put your banner below the panel:
B4X:
Panel1.AddView(BannerAd, 0dip, 100%y, 100%x, height)
Try this:
B4X:
Panel1.AddView(BannerAd, 0dip, 0, 100%x, height)
And check this:
 
Upvote 0

AnandGupta

Expert
Licensed User
Longtime User
And check this:

Thanks a lot @asales ??? for making the example.

I did tried it earlier but it gave error so I left it.
I was wrongly trying to use a sample json downloaded from internet and was getting crashes.

After your suggestion, I decided to create the Firebase project, I was shying from it till now. Well it took time and I had to refer to helps in Google and also in our Forum.
Finally I got the keys and wrote them in your example project.

WOW ! the ads are showing. Thanks again.

I will now study them more closely to understand all the logic and will try them in my project.

Regards,

Anand
 
Upvote 0

AnandGupta

Expert
Licensed User
Longtime User
Hi @asales ,

I studied your code, specially the "Banner_Module.bas". I noticed that the layout used for it do not have any panel, label etc. "layadmob1.bal"
All the banner ads are set on the activity itself, adjusting position.

As I am interested in setting the banner ad on a panel (or any other view other than main activity) so that I can move/adjust the panel on my layout as per my requirement and do not have to tinker the banner size position etc.

So I changed the "layadmob1.bal" and added some panel, label etc.

But the ads is not showing on the panel. I have attached the modified project.

Please help.

Regards,

Anand
 

Attachments

  • admob_example.zip
    42.1 KB · Views: 250
Upvote 0

AnandGupta

Expert
Licensed User
Longtime User
Hmm.. no reply !

So I understand that it can not be done, i.e. ads can not be shown in panel. Ok

Regards,

Anand
 
Upvote 0

asales

Expert
Licensed User
Longtime User
But the ads is not showing on the panel. I have attached the modified project.
So I understand that it can not be done, i.e. ads can not be shown in panel. Ok
It works. Check the imagens of your modified example and this code:
B4X:
Dim size As AdSize = GetAdaptiveAdSize
AdViewAdaptive.Initialize2("adap", "ca-app-pub-3940256099942544/6300978111", size.Native)
Panel4.AddView(AdViewAdaptive, 0, 0, size.Width, size.Height)
AdViewAdaptive.LoadAd
ad_example1.jpg
ad_example2.jpg
 
Upvote 0

AnandGupta

Expert
Licensed User
Longtime User
Thanks a lot. I will check it and revert.

Regards

Anand
 
Upvote 0
Top