#Region Service Attributes
#StartAtBoot: False
#End Region
Sub Process_Globals
'GENERAL
Private appKey As String = "pub-xxxxx-android-xxxx"
Private retryTime As Int = 30000
Private reloadTime As Int = 2000
Private ctxt As JavaObject
'INTER
Private tappxIntersticial As JavaObject
Private interListener As Object
Public isInterstitialReady As Boolean = False
'BANNER
Private bannerListener As Object
Public bannerView As JavaObject
Public isBannerReady As Boolean = False
End Sub
Sub Service_Create
'INITIALIZE CONTEXT
ctxt.InitializeContext
'BANNER
bannerView.InitializeNewInstance("com.tappx.sdk.android.TappxBanner", Array(ctxt,appKey))
bannerView.RunMethod("setAdSize", Array("BANNER_320x50"))
bannerListener = bannerView.CreateEventFromUI("com.tappx.sdk.android.TappxBannerListener", "TappxBanner", Null)
bannerView.RunMethod("setListener",Array(bannerListener))
Load_Banner
'INTER
tappxIntersticial.InitializeNewInstance("com.tappx.sdk.android.TappxInterstitial", Array(ctxt, appKey))
interListener = tappxIntersticial.CreateEventFromUI("com.tappx.sdk.android.TappxInterstitialListener", "TappxIntersticial", Null)
tappxIntersticial.RunMethod("setListener",Array(interListener))
Load_Inter
End Sub
Sub Service_Start (StartingIntent As Intent)
Service.StopAutomaticForeground
End Sub
Sub Service_Destroy
bannerView.RunMethod("destroy", Null)
tappxIntersticial.RunMethod("destroy", Null)
End Sub
#Region INTERSTICIAL
Sub Load_Inter
tappxIntersticial.RunMethod("loadAd", Null)
End Sub
Sub TappxIntersticial_Event (MethodName As String, Args() As Object) As Object 'EVENTOS DO INTERSTICIAL
Select MethodName
Case "onInterstitialLoaded"
LogColor("onInterstitialLoaded Inter Tappx", Colors.Red)
isInterstitialReady = True
Case "onInterstitialLoadFailed"
LogColor("onInterstitialLoadFailed Inter Tappx", Colors.Red)
isInterstitialReady = False
Retry_Inter
Case "onInterstitialShown"
LogColor("onInterstitialShown Inter Tappx", Colors.Red)
isInterstitialReady = False
Case "onInterstitialClicked"
LogColor("onInterstitialClicked Inter Tappx", Colors.Red)
isInterstitialReady = False
Case "onInterstitialDismissed"
LogColor("onInterstitialDismissed Inter Tappx", Colors.Red)
isInterstitialReady = False
Reload_Inter
End Select
Return Null
End Sub
Sub Show_Inter
tappxIntersticial.RunMethod("show", Null)
End Sub
Sub Retry_Inter
isInterstitialReady = False
Sleep(retryTime)
Load_Inter
End Sub
Sub Reload_Inter
isInterstitialReady = False
Sleep(reloadTime)
Load_Inter
End Sub
#End Region
#Region BANNER
Sub Load_Banner
bannerView.RunMethod("loadAd", Null)
End Sub
Sub TappxBanner_Event (MethodName As String, Args() As Object) As Object 'EVENTOS DO BANNER
Select MethodName
Case "onBannerLoaded"
LogColor("onBannerLoaded Banner Tappx", Colors.Red)
isBannerReady = True
Case "onBannerLoadFailed"
LogColor("onBannerLoadFailed Banner Tappx", Colors.Red)
isBannerReady = False
Retry_Banner
Case "onBannerClicked"
LogColor("onBannerClicked Banner Tappx", Colors.Red)
isBannerReady = False
Case "onBannerExpanded"
LogColor("onBannerExpanded Banner Tappx", Colors.Red)
Case "onBannerCollapsed"
LogColor("onBannerCollapsed Banner Tappx", Colors.Red)
isBannerReady = False
End Select
Return Null
End Sub
Sub Retry_Banner
isBannerReady = False
Sleep(retryTime)
Load_Banner
End Sub
#End Region