Java Question Add listener problem (startapp lib)

Douglas Farias

Expert
Licensed User
Longtime User
Hi all.
I'm trying to use the startapp sdk and I'm having some difficulties.

the problem is in adding the interstitial callback

here's the page that talks about it.

here's the initial SDK tutorial, using the .jar file

and here is an example of a java app.


Here's what I've done so far.
B4X:
Sub Init_StartApp
    
    Private ctxt As JavaObject
    ctxt.InitializeContext
    
    'INIT SDK
    Private StartAppSDK As JavaObject
    StartAppSDK.InitializeStatic("com.startapp.sdk.adsbase.StartAppSDK")
    StartAppSDK.RunMethod("init", Array(ctxt,startAppKey,True))
    
    'SET TEST MODE
    StartAppSDK.RunMethod("setTestAdsEnabled", Array(True))
    
    'INIT ADS
    Private StartAppAd As JavaObject
    StartAppAd.InitializeStatic("com.startapp.sdk.adsbase.StartAppAd")
    
    'INIT LISTENER
    Dim AdListenerIntersticial As Object = StartAppAd.CreateEventFromUI("com.startapp.sdk.adsbase.adlisteners.AdEventListener", "AdListenerIntersticial", Null)
    
    'CALL LOAD AD WITH LISTENER
    StartAppAd.RunMethod("loadAd", Array(AdListenerIntersticial)) 'CRASH HERE
    
    
End Sub

The error log


what can i be doing wrong? as the documentation says I must pass the listener on loadAd
Java:
startAppAd.loadAd (new AdEventListener () {
     @Override
     public void onReceiveAd (Ad ad) {
     }
     @Override
     public void onFailedToReceiveAd (Ad ad) {
     }
});


any help is welcome!
thanks
 

Douglas Farias

Expert
Licensed User
Longtime User
Really, i need some coffee .

Working code.
B4X:
    If Not(ctxt.IsInitialized) Then ctxt.InitializeContext
    
    'INIT SDK
    StartAppSDK.InitializeStatic("com.startapp.sdk.adsbase.StartAppSDK")
    StartAppSDK.RunMethod("init", Array(ctxt,startAppKey,True))
    
    'SET TEST MODE
    StartAppSDK.RunMethod("setTestAdsEnabled", Array(True))
    
    'INIT ADS
    StartAppAd.InitializeNewInstance("com.startapp.sdk.adsbase.StartAppAd", Array(ctxt))
    
    'INIT LISTENER
    Dim AdListenerIntersticial As Object = StartAppAd.CreateEventFromUI("com.startapp.sdk.adsbase.adlisteners.AdEventListener", "AdListenerIntersticial", Null)
    
    'CALL LOAD AD WITH LISTENER
    Try
        StartAppAd.RunMethod("loadAd", Array(AdListenerIntersticial))
    Catch
        Log(LastException)
    End Try

thank you!
 
Cookies are required to use this site. You must accept them to continue using the site. Learn more…