B4A Library AdMob library

This library requires some configuration. Please see the tutorial: http://www.b4x.com/forum/basic4andr...-admob-tutorial-add-ads-your-application.html

Reference: Basic4android - AdMob

AdMob v2.00 - Based on Google Play Services. This version requires B4A v3.20.

AdMob v1.40 - Add support for SIZE_SMART_BANNER.
These ads will fill the whole available width: https://developers.google.com/mobile-ads-sdk/docs/admob/smart-banners

You can use the following code:
Code: Copy
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)

See this post for an additional requirement if using google play services v28: https://www.b4x.com/android/forum/threads/admob-library.7301/page-10#post-381519
 

Attachments

Last edited:
ehhm. Sorry. i made something wrong... I followed the admob tutorial but nothing is shown in the app... There are no errors in compiling and no entries in the logcat...
I have this code:
Code: Copy
AdView1.Initialize2("Ad", "pub-mynumber", 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, 0dip, 100%x, height)
End Sub
Sub Ad_FailedToReceiveAd (ErrorCode As String)
    Log("failed: " & ErrorCode)
End Sub
Sub Ad_ReceiveAd
    Log("received")
End Sub
Sub Ad_AdScreenDismissed
  Log("screen dismissed")
End Sub
and this adview1.pause and resume in the activity event...
But there i nothing in the app and i dont know what to do on the admob website...
i registered my app 2 times and i have some ad banner numbers but its really crazy.
Can somebody help me, please?
 
How long did you wait ?
It seems that it can least SEVERAL HOURS before a images is shown.

Didi you also configured the Block on AdMob with a network in your country ?

Does the Impression counter shows something other then Zero ?

AND: depending on the Lib you are using: try the ca-app-pub-xxxxxxxxxx key !!!

This works @me:
Code: Copy
Activity.LoadLayout("Main")
    AdView1.Initialize("Ad", "ca-app-pub-1234567890123456/1234567890") 'publisher id that you received from AdMob.
    Activity.AddView(AdView1, 0dip, 100%y - 50dip,320dip, 50dip)
AdView1.LoadAd
 
Last edited:
Update:
The ad is shown but there is no click on admob when i click on the banner....
---------
ha! Maybe i forgot loaded and i used the wrong numbers...
Thanks
 
Last edited:
also this leasts some time....keep an eye on that a time.
when it is shown it has to be counted...if you gave your code :cool:
 
Yes - both
 
Don't click too many times when testing! If you are getting impressions and requests then it is working.
 
No, every click. Admob is Pay Per Click. They will give you a RPM or CPM or something metric, but this is more to measure performance. You need to open up the report more to see the Amount generated by actual clicks - it's less intuitive than it used to be.

The Amount per click depends on the tariff associated with the advert being clicked.
 
If you click on Monetize, at the top, it will show you the Clicks and Revenue per day. Then you can work out the ave. revenue per click
 
yep, I saw this...
My only problem is, that this words there don't say anything to me...
Regards
 
My only problem is, that this words there don't say anything to me...
Most important at all is, that you can read the amount you have earned :p

For detailed informations register with GoogleAdSense and/or Google Analytics :D
 
erel ,so if i downloaded it before 1 week i have to update again?
 
Check the library version (it is listed in the libraries tab). The new version is 2.00.

Erel, can you just confirm. What versions of Android does 2.00 support? If we utilise version 2.00 does this mean that our Apps won't support older devices or will it just not serve up an advert? i.e. does this impact on the Google Play listing and devices supported?
 
Back
Top