Problem with admob 1.40 library

D

Deleted member 30048

Guest
Hello, I hope that the place of the message is here!

Well, I downloaded admob 1.40 lib but I have a problem. I use this code for smart_banners:

Adview1.Initialize2("Ad", "xxxxxxxx", AdView1.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
Activity.AddView(AdView1, 0dip, 100%y - height, 100%x, height)

and the banners show great in phones and tablets but only in portrait mode, in landscape mode does not show any ad.

The only way to show ads in phones in landscape mode that I know is setting "width = 320dip" and "height = 50dip" without smart banners, but I don't know how to do banners in tablets in landscape mode.

Please, can somebody help me?

Sorry for my english if you don't understand anything.

Thanks to everybody!
 
D

Deleted member 30048

Guest
Hello and thanks for answering Erel

I do not use any real tablet because I do not have one, but I use the emulator.

The problem is not only that the above code does not shows the banners on tablets in landscape mode, is also that on phones happens the same problem (on real phones and emulates phones). That is, with the above code the banners is showed ok on phones and tablets but only in portrait mode.

The log that I received when the phone is in landscape mode is the next: "Ad request successful, but no ad returned due to lack of ad inventory."

To solve the problem with the phones, I used this code:

Dim height As Int
If (Activity.height > Activity.Width) Then 'Portrait Mode.
AdView1.Initialize2("Ad", "xxxxx", AdView1.SIZE_SMART_BANNER)
If GetDeviceLayoutValues.ApproximateScreenSize < 6 Then 'Phones
height = 50dip
Else 'Tablets
height = 90dip
End If
Activity.AddView(AdView1, 0dip, 100%y - height, 100%x, height)
Else 'Landscape Mode
AdView1.Initialize("Ad", "xxxxxx")
Activity.AddView(AdView1,50%x - 160dip,100%y-50dip,320dip,50dip)
End If
AdView1.LoadAd

As you can see, I used smart_banner only for portrait mode and I used the normal mode for landscape mode. This method works but only on phones. I tried anything to solve the problem with tablets but allways I received the same log error.

Grettings!
 
Upvote 0

Inman

Well-Known Member
Licensed User
Longtime User
I am also facing a similar issue (though not related to Admob) with emulator (for Nexus 7) in landscape mode. The problem is that GetDeviceLayoutValues.ApproximateScreenSize returns NaN on an emulator in tablet landscape mode (never tried portrait mode).

Looks like I will have to test on emulator separately, without depending on the IF condition. Hopefully all actual devices return the right value for ApproximateScreenSize.
 
Upvote 0

mattekr

Member
Licensed User
Longtime User
Also I have the same error.

With the code found in the example

B4X:
AdView1.Initialize("Ad", "xxxx")
Dim height As Int
If GetDeviceLayoutValues.ApproximateScreenSize < 6 Then
If 100%x > 100%y Then height = 32dip Else height = 50dip
Else
   height = 90dip
End If
Activity.AddView(AdView1, 0dip, 100%y - height, 100%x, height)
ListView1.height = 100%y - AdView1.height
AdView1.LoadAd

ad was shown in the portrait mode but not in landscape mode
 
Upvote 0
Top