Java Question raiseEvent2 ERROR

Johnmcenroy

Active Member
Licensed User
Longtime User
I am developing MoPub library for displaying ads. There is an error with interstitial ad. Here is my B4A code:
B4X:
Sub Activity_Create(FirstTime As Boolean)
    interstitial.InitializeMopub_Interstitial ("interstitial","")
    interstitial.PreloadMopub_Interstitial 'preloading interstitial
End Sub

Sub btnShow_Click
    interstitial.ShowMopub_Interstitial 'show interstitial
End Sub

Sub interstitial_mopub_interstitial_dismissed 'on dismissed preload another interstitial
    LogColor("Interstitial Dismissed",Colors.Blue)
    interstitial.PreloadMopub_Interstitial
End Sub

JAVA code:
B4X:
@Override
public void onInterstitialDismissed(MoPubInterstitial arg0) {
  // TODO Auto-generated method stub
  ba.raiseEvent2(this,true, this.eventName + "_mopub_interstitial_dismissed",false, new Object[0]);
}

So when app is loading - interstitial is preloading and with click on button is showing , then I dissmiss interstitial and new interstitial must be preloaded but this gives the following error:
B4X:
Interstitial Dismissed
main_interstitial_mopub_interstitial_dismissed (java line: 1160)
java.lang.NullPointerException
    at christmas.carols.main._interstitial_mopub_interstitial_dismissed(main.java:1160)
    at java.lang.reflect.Method.invokeNative(Native Method)
    at java.lang.reflect.Method.invoke(Method.java:525)
    at anywheresoftware.b4a.BA.raiseEvent2(BA.java:187)
    at anywheresoftware.b4a.BA.raiseEvent2(BA.java:175)
    at com.mopub.Interstitial.onInterstitialDismissed(Interstitial.java:35)
    at com.mopub.mobileads.MoPubInterstitial.onCustomEventInterstitialDismissed(MoPubInterstitial.java:213)
    at com.mopub.mobileads.CustomEventInterstitialAdapter.onInterstitialDismissed(CustomEventInterstitialAdapter.java:221)
    at com.mopub.mobileads.AppTrackerInterstitial$AppTrackerAppModuleListener.onModuleClosed(AppTrackerInterstitial.java:80)
    at com.apptracker.android.module.AppModuleControllerBase.onClosed(u:273)
    at com.apptracker.android.module.AppModuleController.destroyAd(h:1302)
    at com.apptracker.android.module.AppModuleController.onCloseClick(h:371)
    at com.apptracker.android.advert.AppJSInterface$1.run(mb:210)
    at android.os.Handler.handleCallback(Handler.java:730)
    at android.os.Handler.dispatchMessage(Handler.java:92)
    at android.os.Looper.loop(Looper.java:137)
    at android.app.ActivityThread.main(ActivityThread.java:5103)
    at java.lang.reflect.Method.invokeNative(Native Method)
    at java.lang.reflect.Method.invoke(Method.java:525)
    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:737)
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:553)
    at dalvik.system.NativeStart.main(Native Method)
java.lang.NullPointerException

LogColor("Interstitial Dismissed",Colors.Blue) works as usual , all works but when I add interstitial.PreloadMopub_Interstitial it gives an error. Please help with this problem. Thanks.
 
Last edited:

Johnmcenroy

Active Member
Licensed User
Longtime User
Is it possible that the activity is paused at that point?

Change ba.raiseEvent2 with ba.raiseEventFromUI. It will allow the activity to be resumed.

Yes activity is pauses when interstitial is shown, I tried with raiseEventFromUI , but then event don't work, in logs - ignoring event
interstitial_mopub_interstitial_dismissed
 
Top