Android Question Unable to catch some event with JavaObject

FrostCodes

Active Member
Licensed User
Hello everyone, I tried to catch Ironsource events with this code.
It's able to catch most events but it misses events like onInterstitialAdOpened, onInterstitialAdShowSucceeded, etc.
I am wrapping this code

B4X:
     Dim CallBack As Object = IronsourceInstance.CreateEventFromUI("com.ironsource.mediationsdk.sdk.InterstitialListener", "IronSourceAds", Null)

'    Dim CallBack As Object = IronsourceInstance.CreateEvent("com.ironsource.mediationsdk.sdk.InterstitialListener", "IronSourceAds", Null)

IronsourceInstance.RunMethodJO("setInterstitialListener", Array(CallBack))


The event catcher:
Private Sub IronSourceAds_Event(MethodName As String, Args() As Object) As Object
LogColor("IronSourceAds_Event", Colors.Cyan)
    Log(MethodName)

End Sub

instead, I get this in the unfiltered log:

Unfiltered Log:
[OkHttp] sendRequest<<
isInterstitialReady():true
showInterstitial()
showInterstitial(DefaultInterstitial)
MTKProgramCache.generateProgram: 563053037879364
createProgram 0x0002001800500044, binary 0x7afb621f80, length 12956, format 37168 within 1310ns
** Activity (main) Pause, UserClosed = false **
onPause()
NetworkCallback for was not registered or already unregistered
DecorView setVisiblity: visibility = 4, Parent = null, this = DecorView@3c8c1ae[]
[OkHttp] sendRequest<<
onInterstitialAdOpened()
Ignoring event: ironsourceads_event
onInterstitialAdShowSucceeded()
Ignoring event: ironsourceads_event
Setting airplane_mode_on has moved from android.provider.Settings.System to android.provider.Settings.Global, returning read-only value.

Please is anything wrong with my code?
 

DonManfred

Expert
Licensed User
Longtime User
but it misses events like onInterstitialAdOpened
No
NetworkCallback for was not registered or already unregistered DecorView setVisiblity: visibility = 4, Parent = null, this = DecorView@3c8c1ae[] [OkHttp] sendRequest<< onInterstitialAdOpened() Ignoring event: ironsourceads_event onInterstitialAdShowSucceeded() Ignoring event: ironsourceads_event
They are called but the activity is in the background.
Move the networkcode to a service.

Or switch to B4XPages and forget about such issues.
 
Upvote 0

DonManfred

Expert
Licensed User
Longtime User
I want to avoid using services and b4xpages is not an option for now
then you have to live with that.

The activity is in the background and you can not run any event in a activity which is in the background.

The solution is to use B4XPages or using Services
 
Last edited:
Upvote 1
Top