Hello everyone, also posted here.
Tappx
Displayio
Here is an example of how to use StartApp, banner and interstitial with lasted SDK version.
Download the 4.6.1 jar file.
Manifest (the code generated in the startApp goes here in the manifest)
Service
I use it in a service (where all events work correctly), but you can compile it as a library or use it as a class.
Interstitial
Banner
Thx
Tappx
Tappx ads service
1. Register with Tappx and get an app key: https://www.tappx.com 2. Download their AAR library and copy it to the additional libraries folder: https://repo1.maven.org/maven2/com/tappx/sdk/android/tappx-sdk/3.1.3/ 3. Add dependencies: #AdditionalJar: tappx-sdk-3.0.9.aar #AdditionalJar...
www.b4x.com
display.io ads service
1. Register with http://www.display.io/en/, create a new app and an interstitial ad unit. 2. Download their sdk and copy it to the additional libraries folder. 3. Add to manifest editor: AddPermission(android.permission.INTERNET) AddPermission(android.permission.ACCESS_NETWORK_STATE)...
www.b4x.com
Here is an example of how to use StartApp, banner and interstitial with lasted SDK version.
Start.io | Mobile Marketing & Audience Platform for Marketers
We are a mobile data platform that enables organizations to uncover AI-driven insights and make data-driven decisions that enhance strategies and drive growth
www.startapp.com
B4X:
#AdditionalJar: StartAppInApp-4.6.1
XML:
'STARTAPP
AddPermission(android.permission.INTERNET)
AddPermission(android.permission.ACCESS_WIFI_STATE)
AddPermission(android.permission.ACCESS_NETWORK_STATE)
AddPermission(android.permission.ACCESS_COARSE_LOCATION)
AddPermission(android.permission.ACCESS_FINE_LOCATION)
AddPermission(android.permission.RECEIVE_BOOT_COMPLETED)
AddPermission(android.permission.BLUETOOTH)
AddApplicationText(
<provider
android:name="com.startapp.sdk.adsbase.StartAppInitProvider"
android:authorities="${applicationId}.startappinitprovider"
android:exported="false" />
<activity
android:name="com.startapp.sdk.adsbase.consent.ConsentActivity"
android:configChanges="orientation|screenSize|screenLayout|keyboardHidden"
android:theme="@android:style/Theme.Translucent"/>
<activity
android:name="com.startapp.sdk.ads.list3d.List3DActivity"
android:theme="@android:style/Theme"/>
<activity
android:name="com.startapp.sdk.adsbase.activities.OverlayActivity"
android:configChanges="orientation|screenSize|screenLayout|keyboardHidden"
android:theme="@android:style/Theme.Translucent"/>
<activity
android:name="com.startapp.sdk.adsbase.activities.FullScreenActivity"
android:configChanges="orientation|screenSize|screenLayout|keyboardHidden"
android:theme="@android:style/Theme"/>
<service android:name="com.startapp.sdk.adsbase.InfoEventService" />
<service
android:name="com.startapp.sdk.adsbase.PeriodicJobService"
android:permission="android.permission.BIND_JOB_SERVICE" />
<receiver android:name="com.startapp.sdk.adsbase.remoteconfig.BootCompleteListener">
<intent-filter>
<action android:name="android.intent.action.BOOT_COMPLETED"/>
</intent-filter>
</receiver>
<meta-data
android:name="com.startapp.sdk.APPLICATION_ID"
android:value="xxxxxxxxYOUR APP CODE HERExxxxxxxxxxxx" />
)
B4X:
#Region Service Attributes
#StartAtBoot: False
#End Region
Sub Process_Globals
'GENERAL
Private StartAppSDK As JavaObject
Private ctxt As JavaObject
Private appKey As String
Private testMode As Boolean = True
Private retryTime As Int = 30000
'INTER
Private StartAppAd As JavaObject
Public isInterstitialReady As Boolean = False
Private AdListenerInterstitial As Object
Private AdDisplayListener As Object
'BANNER
Private BannerAdListener As Object
Public isBannerReady As Boolean = False
Private bannerAd As JavaObject
Public bannerHeight As Int = 51dip
Public bannerView As JavaObject
End Sub
Sub Service_Create
'INITIALIZE CONTEXT
ctxt.InitializeContext
'GET APP KEY ID
appKey = Get_Key("com.startapp.sdk.APPLICATION_ID")
'INITIALIZE SDK
StartAppSDK.InitializeStatic("com.startapp.sdk.adsbase.StartAppSDK")
StartAppSDK.RunMethod("init", Array(ctxt,appKey,True))
StartAppSDK.RunMethod("setTestAdsEnabled", Array(testMode)) 'TEST MODE ON
'INTER
StartAppAd.InitializeNewInstance("com.startapp.sdk.adsbase.StartAppAd", Array(ctxt))
AdListenerInterstitial = StartAppAd.CreateEventFromUI("com.startapp.sdk.adsbase.adlisteners.AdEventListener", "AdListenerInterstitial", Null)
AdDisplayListener = StartAppAd.CreateEventFromUI("com.startapp.sdk.adsbase.adlisteners.AdDisplayListener", "AdDisplayListener", Null)
Load_Inter
'BANNER
bannerAd.InitializeNewInstance("com.startapp.sdk.ads.banner.Banner", Array(ctxt))
BannerAdListener = bannerAd.CreateEventFromUI("com.startapp.sdk.ads.banner.BannerListener", "BannerAdListener", Null)
bannerAd.RunMethod("setBannerListener", Array(BannerAdListener))
Load_Banner
End Sub
Sub Service_Start (StartingIntent As Intent)
Service.StopAutomaticForeground
End Sub
Sub Service_Destroy
End Sub
#Region INTER
Private Sub AdListenerInterstitial_Event (MethodName As String, Args() As Object) As Object 'INTER EVENTS
Select MethodName
Case "onReceiveAd"
LogColor("onReceiveAd Inter StartApp", Colors.Green)
isInterstitialReady = True
Case "onFailedToReceiveAd"
LogColor("onFailedToReceiveAd Inter StartApp", Colors.Green)
isInterstitialReady = False
Retry_Inter
End Select
Return Null
End Sub
Private Sub AdDisplayListener_Event (MethodName As String, Args() As Object) As Object
Select MethodName
Case "adHidden"
isInterstitialReady = False
LogColor("adHidden Inter StartApp", Colors.Green)
Case "adDisplayed"
isInterstitialReady = False
LogColor("adDisplayed Inter StartApp", Colors.Green)
Case "adClicked"
isInterstitialReady = False
LogColor("adClicked Inter StartApp", Colors.Green)
Case "adNotDisplayed"
LogColor("adNotDisplayed Inter StartApp", Colors.Green)
isInterstitialReady = False
Retry_Inter
End Select
Return Null
End Sub
Sub Load_Inter
Try
StartAppAd.RunMethod("loadAd", Array(AdListenerInterstitial))
Catch
If LastException.IsInitialized Then Log(LastException)
Retry_Inter
End Try
End Sub
Sub Retry_Inter
isInterstitialReady = False
Sleep(retryTime)
Load_Inter
End Sub
Sub Show_Inter
StartAppAd.RunMethod("showAd", Array(AdDisplayListener))
End Sub
#End Region
#Region BANNER
Private Sub BannerAdListener_Event (MethodName As String, Args() As Object) As Object
Select MethodName
Case "onReceiveAd"
LogColor("onReceiveAd Banner StartApp", Colors.Green)
isBannerReady = True
bannerView = Args(0)
Case "onFailedToReceiveAd"
LogColor("onFailedToReceiveAd Banner StartApp", Colors.Green)
isBannerReady = False
Retry_Banner
Case "onClick"
LogColor("onClick Banner StartApp", Colors.Green)
End Select
Return Null
End Sub
Sub Load_Banner
Try
bannerAd.RunMethod("loadAd", Array(320,50))
Catch
If LastException.IsInitialized Then Log(LastException)
Retry_Banner
End Try
End Sub
Sub Retry_Banner
isBannerReady = False
Sleep(retryTime)
Load_Banner
End Sub
#End Region
Private Sub Get_Key(key As String) As String
Dim ApplicationInfo As JavaObject = ctxt.RunMethodJO("getPackageManager", Null).RunMethod("getApplicationInfo", Array(Application.PackageName, 0x00000080))
Dim bundle As JavaObject = ApplicationInfo.GetField("metaData")
Return bundle.RunMethod("getInt", Array(key))
End Sub
Interstitial
B4X:
If Not(IsPaused(StartApp)) And StartApp.isInterstitialReady Then CallSub(StartApp, "Show_Inter")
B4X:
If Not(IsPaused(StartApp)) And StartApp.isBannerReady Then
Private bannerView As View
bannerView = StartApp.bannerView
Activity.AddView(bannerView,0%x, 100%y - 51dip, 100%x, 51dip)
End if
Thx