1. Register with AppBrain: https://www.appbrain.com/
2. Download their AAR and copy it to the additional libraries folder: https://github.com/swisscodemonkeys/appbrain-sdk/releases/latest
3. Add to manifest editor:
4. Add a reference to the downloaded AAR:
5. Code to create an interstitial ad:
Depends on: JavaObject
2. Download their AAR and copy it to the additional libraries folder: https://github.com/swisscodemonkeys/appbrain-sdk/releases/latest
3. Add to manifest editor:
B4X:
'************** AppBrain
AddPermission(android.permission.INTERNET)
AddPermission(android.permission.ACCESS_NETWORK_STATE)
AddApplicationText(
<activity
android:name="com.appbrain.AppBrainActivity"
android:configChanges="keyboard|keyboardHidden|orientation|screenLayout|uiMode|screenSize|smallestScreenSize" />
<provider
android:name="com.appbrain.AppBrainInitProvider"
android:authorities="${applicationId}.AppBrainInitProvider"
android:exported="false" />
<service android:name="com.appbrain.AppBrainService" />
<service
android:name="com.appbrain.AppBrainJobService"
android:enabled="@bool/appbrain_job_service_enabled"
android:permission="android.permission.BIND_JOB_SERVICE" />
<receiver
android:name="com.appbrain.ReferrerReceiver"
android:exported="true" >
<intent-filter>
<action android:name="com.android.vending.INSTALL_REFERRER" />
</intent-filter>
</receiver>
)
'*********************
B4X:
#AdditionalJar: appbrain-sdk-14.10.aar
B4X:
Sub Globals
Private ad As JavaObject
Private ctxt As JavaObject
End Sub
Sub Activity_Create(FirstTime As Boolean)
Activity.LoadLayout("1")
ctxt.InitializeContext
End Sub
'Possible values: DEFAULT, HOME_SCREEN, STARTUP, PAUSE, EXIT, LEVEL_START, LEVEL_COMPLETE, ACHIEVEMENTS, LEADERBOARDS, STORE
Sub CreateAd (AdUnitId As String) As JavaObject
Dim AdId As JavaObject
AdId.InitializeStatic("com.appbrain.AdId")
Dim builder As JavaObject
builder = builder.InitializeStatic("com.appbrain.InterstitialBuilder").RunMethod("create", Null)
builder.RunMethod("setAdId", Array(AdId.GetField(AdUnitId)))
Dim listener As Object = builder.CreateEventFromUI("com.appbrain.InterstitialListener", "listener", Null)
builder.RunMethod("setListener", Array(listener))
builder.RunMethod("preload", Array(ctxt))
Return builder
End Sub
Sub Listener_Event (MethodName As String, Args() As Object) As Object
If Args <> Null Then
Dim largs As List = Args
Log(MethodName & ": " & largs)
Else
Log(MethodName)
End If
Return Null
End Sub
Sub Activity_Resume
ad = CreateAd("DEFAULT")
End Sub
Sub Activity_Click
ad.RunMethod("show", Array(ctxt)) 'show it
End Sub
Depends on: JavaObject
Last edited: