Hello group.
WTF, another Admob lib ??? Well, the more the better.
It has banners & interstitials and is google play services based. Also, it works with older B4A versions, and has a couple more options.
Setup stuff
1. Fire up your android sdk manager, scroll down to "Extras" and make sure "Google Play services" is installed and updated.
2. Goto the folder where you have your Android sdk, and browse this folder :
<Android_sdk_root>\extras\google\google_play_services\libproject\google-play-services_lib
copy google-play-services.jar from "libs" folder into B4A extralibs folder.
make a copy of "res" folder to something else, lets say ResReadOnly and set it's properties to ReadOnly
3. Decompress the attached zip into B4A extralibs folder also.
2. copy the contents of ResReadOnly folder (the one from point 2 of the setup stuff) into Objects\res folder of your B4A project. Also note that if you update the "Google Play services" lib, you must also update your ResReadOnly folder, because they must match.
3. Sample app with a banner and a interstitial :
4. This lib is beerWare. It's usage implies that you paypal me a beer at valeria_pires_@hotmail.com
the sample app can be found here :
https://dl.dropboxusercontent.com/u/57952276/adTest.apk
please try a couple of the ads.
Nelson
WTF, another Admob lib ??? Well, the more the better.
It has banners & interstitials and is google play services based. Also, it works with older B4A versions, and has a couple more options.
Setup stuff
1. Fire up your android sdk manager, scroll down to "Extras" and make sure "Google Play services" is installed and updated.
2. Goto the folder where you have your Android sdk, and browse this folder :
<Android_sdk_root>\extras\google\google_play_services\libproject\google-play-services_lib
copy google-play-services.jar from "libs" folder into B4A extralibs folder.
make a copy of "res" folder to something else, lets say ResReadOnly and set it's properties to ReadOnly
3. Decompress the attached zip into B4A extralibs folder also.
Usage in a B4A project
1. Manifest Editor. Note the minSdkVersion. It's important. Don't set it to a lower version, or your app, if run in a device with it will crash.
B4X:
'This code will be applied to the manifest file during compilation.
'You do not need to modify it in most cases.
'See this link for for more information: http://www.b4x.com/forum/showthread.php?p=78136
AddManifestText(
<uses-sdk android:minSdkVersion="9" android:targetSdkVersion="19"/>
<supports-screens android:largeScreens="true"
android:normalScreens="true"
android:smallScreens="true"
android:anyDensity="true"/>)
SetApplicationAttribute(android:icon, "@drawable/icon")
SetApplicationAttribute(android:label, "$LABEL$")
'End of default text.
AddApplicationText(
<meta-data android:name="com.google.android.gms.version"
android:value="@integer/google_play_services_version"/>
<activity android:name="com.google.android.gms.ads.AdActivity"
android:configChanges="keyboard|keyboardHidden|orientation|screenLayout|uiMode|screenSize|smallestScreenSize"/>
)
2. copy the contents of ResReadOnly folder (the one from point 2 of the setup stuff) into Objects\res folder of your B4A project. Also note that if you update the "Google Play services" lib, you must also update your ResReadOnly folder, because they must match.
3. Sample app with a banner and a interstitial :
B4X:
Sub Process_Globals
End Sub
Sub Globals
Dim aSize As adSize
Dim ad As adView
Dim adBuilder As adRequestBuilder
Dim adFull As interstitialAd
Dim adReq As adRequest
End Sub
Sub Activity_Create(FirstTime As Boolean)
'This works fine, custom banner sizes
'aSize.Initialize(100%x,200dip)
'ad.Initialize("ca-app-pub-265756765047543290673603/5577815741",aSize,"ad")
' or this, more classic
aSize=aSize.SMART_BANNER
ad.Initialize("ca-app-pub-20475678678643290673603/5577815741",aSize,"ad")
adBuilder.Initialize()
adBuilder.Gender = adReq.GENDER_FEMALE
adBuilder.Birthday = DateTime.DateParse("01/01/2003")
adReq.Initialize(adBuilder)
ad.loadAd(adReq)
Dim b As Button
b.Initialize("But")
b.Text="Full Ad"
adFull.Initialize("ca-app-pub-204757687643290673603/6496682146","adFull")
adFull.loadAd(adReq)
Activity.AddView(ad,0,0,aSize.Width,aSize.Height)
Activity.AddView(b,0,100%y-60dip,100%x,50dip)
End Sub
Sub Activity_Resume
ad.resume
End Sub
Sub Activity_Pause (UserClosed As Boolean)
ad.pause
End Sub
Sub But_click
If adFull.isLoaded Then
adFull.show
Else
Msgbox("Sorry. InterstitialAd not available","")
End If
End Sub
' Banner Listeners
Sub ad_onAdLoaded
Log("AD Loaded")
End Sub
Sub ad_onAdClosed
Log("AD closed")
End Sub
Sub ad_onAdFailedToLoad(errorCode As Int)
Log("AD error : " & errorCode)
End Sub
Sub ad_onAdLeftApplication
Log("AD left application")
End Sub
Sub ad_onAdOpened
Log("AD Opened")
End Sub
' Interstitial Listeners
Sub adFull_onAdLoaded
Log("AD Loaded")
End Sub
Sub adFull_onAdClosed
Log("AD closed")
adFull.loadAd(adBuilder.Build) ' Load next ad
End Sub
Sub adFull_onAdFailedToLoad(errorCode As Int)
Log("AD error : " & errorCode)
End Sub
Sub adFull_onAdLeftApplication
Log("AD left application")
End Sub
Sub adFull_onAdOpened
Log("AD Opened")
End Sub
4. This lib is beerWare. It's usage implies that you paypal me a beer at valeria_pires_@hotmail.com
the sample app can be found here :
https://dl.dropboxusercontent.com/u/57952276/adTest.apk
please try a couple of the ads.
Nelson
Attachments
Last edited: